Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 1 | SUMMARY = "HTTP and reverse proxy server" |
| 2 | |
| 3 | DESCRIPTION = "Nginx is a web server and a reverse proxy server for \ |
| 4 | HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high \ |
| 5 | concurrency, performance and low memory usage." |
| 6 | |
| 7 | HOMEPAGE = "http://nginx.org/" |
| 8 | LICENSE = "BSD-2-Clause" |
| 9 | |
| 10 | SECTION = "net" |
| 11 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 12 | DEPENDS = "libpcre zlib" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 13 | |
| 14 | SRC_URI = " \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 15 | http://nginx.org/download/nginx-${PV}.tar.gz \ |
| 16 | file://nginx-cross.patch \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 17 | file://0001-Allow-the-overriding-of-the-endianness-via-the-confi.patch \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 18 | file://nginx.conf \ |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 19 | file://default_server.site \ |
| 20 | file://proxy_params \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 21 | file://nginx.init \ |
| 22 | file://nginx-volatile.conf \ |
| 23 | file://nginx.service \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 24 | " |
| 25 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 26 | inherit siteinfo update-rc.d useradd systemd |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 27 | |
| 28 | SYSTEMD_SERVICE_${PN} = "nginx.service" |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 29 | |
| 30 | CFLAGS_append = " -fPIE -pie" |
| 31 | CXXFLAGS_append = " -fPIE -pie" |
| 32 | |
| 33 | NGINX_WWWDIR ?= "${localstatedir}/www/localhost" |
| 34 | NGINX_USER ?= "www" |
| 35 | |
| 36 | EXTRA_OECONF = "" |
| 37 | DISABLE_STATIC = "" |
| 38 | |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 39 | PACKAGECONFIG ??= "ssl" |
| 40 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 41 | PACKAGECONFIG[http2] = "--with-http_v2_module,," |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 42 | PACKAGECONFIG[ssl] = "--with-http_ssl_module,,openssl" |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 43 | PACKAGECONFIG[http-auth-request] = "--with-http_auth_request_module,," |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 44 | |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 45 | do_configure () { |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 46 | if [ "${SITEINFO_BITS}" = "64" ]; then |
| 47 | PTRSIZE=8 |
| 48 | else |
| 49 | PTRSIZE=4 |
| 50 | fi |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 51 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 52 | echo $CFLAGS |
| 53 | echo $LDFLAGS |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 54 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 55 | # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH |
| 56 | echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf |
| 57 | |
| 58 | ./configure \ |
| 59 | --crossbuild=Linux:${TUNE_ARCH} \ |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 60 | --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 61 | --with-int=4 \ |
| 62 | --with-long=${PTRSIZE} \ |
| 63 | --with-long-long=8 \ |
| 64 | --with-ptr-size=${PTRSIZE} \ |
| 65 | --with-sig-atomic-t=${PTRSIZE} \ |
| 66 | --with-size-t=${PTRSIZE} \ |
| 67 | --with-off-t=${PTRSIZE} \ |
| 68 | --with-time-t=${PTRSIZE} \ |
| 69 | --with-sys-nerr=132 \ |
| 70 | --conf-path=${sysconfdir}/nginx/nginx.conf \ |
| 71 | --http-log-path=${localstatedir}/log/nginx/access.log \ |
| 72 | --error-log-path=${localstatedir}/log/nginx/error.log \ |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | --http-client-body-temp-path=/run/nginx/client_body_temp \ |
| 74 | --http-proxy-temp-path=/run/nginx/proxy_temp \ |
| 75 | --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \ |
| 76 | --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \ |
| 77 | --http-scgi-temp-path=/run/nginx/scgi_temp \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 78 | --pid-path=/run/nginx/nginx.pid \ |
| 79 | --prefix=${prefix} \ |
Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 80 | --with-threads \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 81 | --with-http_gzip_static_module \ |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 82 | ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | do_install () { |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 86 | oe_runmake 'DESTDIR=${D}' install |
| 87 | rm -fr ${D}${localstatedir}/run ${D}/run |
| 88 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then |
| 89 | install -d ${D}${sysconfdir}/tmpfiles.d |
| 90 | echo "d /run/${BPN} - - - -" \ |
| 91 | > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf |
| 92 | echo "d /${localstatedir}/log/${BPN} 0755 root root -" \ |
| 93 | >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf |
| 94 | fi |
| 95 | install -d ${D}${sysconfdir}/${BPN} |
| 96 | ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run |
| 97 | install -d ${D}${NGINX_WWWDIR} |
| 98 | mv ${D}/usr/html ${D}${NGINX_WWWDIR}/ |
| 99 | chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR} |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 100 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 101 | install -d ${D}${sysconfdir}/init.d |
| 102 | install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx |
| 103 | sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx |
| 104 | sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 105 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 106 | install -d ${D}${sysconfdir}/nginx |
| 107 | install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 108 | sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/nginx/nginx.conf |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 109 | sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf |
| 110 | sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 111 | install -Dm 0644 ${WORKDIR}/default_server.site ${D}${sysconfdir}/nginx/sites-available/default_server |
| 112 | sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/sites-available/default_server |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 113 | install -d ${D}${sysconfdir}/nginx/sites-enabled |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 114 | ln -s ../sites-available/default_server ${D}${sysconfdir}/nginx/sites-enabled/ |
| 115 | |
| 116 | install -m 0644 ${WORKDIR}/proxy_params ${D}${sysconfdir}/nginx/proxy_params |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 117 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 118 | install -d ${D}${sysconfdir}/default/volatiles |
| 119 | install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx |
| 120 | sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 121 | sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 122 | |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 123 | # cleanup configuration folder |
| 124 | rm ${D}${sysconfdir}/nginx/*.default |
| 125 | |
| 126 | # add additional configuration folders |
| 127 | install -d ${D}${sysconfdir}/nginx/modules-available |
| 128 | install -d ${D}${sysconfdir}/nginx/modules-enabled |
| 129 | install -d ${D}${sysconfdir}/nginx/server-conf.d |
| 130 | install -d ${D}${sysconfdir}/nginx/conf.d |
| 131 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 132 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then |
| 133 | install -d ${D}${systemd_unitdir}/system |
| 134 | install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/ |
| 135 | sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \ |
| 136 | -e 's,@LOCALSTATEDIR@,${localstatedir},g' \ |
| 137 | -e 's,@SBINDIR@,${sbindir},g' \ |
Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 138 | -e 's,@BASE_BINDIR@,${base_bindir},g' \ |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 139 | ${D}${systemd_unitdir}/system/nginx.service |
| 140 | fi |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | pkg_postinst_${PN} () { |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 144 | if [ -z "$D" ]; then |
| 145 | if type systemd-tmpfiles >/dev/null; then |
| 146 | systemd-tmpfiles --create |
| 147 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then |
| 148 | ${sysconfdir}/init.d/populate-volatile.sh update |
| 149 | fi |
| 150 | fi |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 151 | } |
| 152 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 153 | FILES_${PN} += " \ |
| 154 | ${localstatedir}/ \ |
| 155 | ${systemd_unitdir}/system/nginx.service \ |
| 156 | " |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 157 | |
Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 158 | CONFFILES_${PN} = " \ |
| 159 | ${sysconfdir}/nginx/nginx.conf \ |
| 160 | ${sysconfdir}/nginx/fastcgi.conf \ |
| 161 | ${sysconfdir}/nginx/fastcgi_params \ |
| 162 | ${sysconfdir}/nginx/koi-utf \ |
| 163 | ${sysconfdir}/nginx/koi-win \ |
| 164 | ${sysconfdir}/nginx/mime.types \ |
| 165 | ${sysconfdir}/nginx/scgi_params \ |
| 166 | ${sysconfdir}/nginx/uwsgi_params \ |
| 167 | ${sysconfdir}/nginx/win-utf \ |
Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 168 | " |
| 169 | |
| 170 | INITSCRIPT_NAME = "nginx" |
| 171 | INITSCRIPT_PARAMS = "defaults 92 20" |
| 172 | |
| 173 | USERADD_PACKAGES = "${PN}" |
| 174 | USERADD_PARAM_${PN} = " \ |
| 175 | --system --no-create-home \ |
| 176 | --home ${NGINX_WWWDIR} \ |
| 177 | --groups www-data \ |
| 178 | --user-group ${NGINX_USER}" |