| 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 \ | 
| Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 24 | file://nginx-fix-pidfile.patch \ | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 25 | " | 
|  | 26 |  | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 27 | inherit siteinfo update-rc.d useradd systemd | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 28 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 29 | SYSTEMD_SERVICE:${PN} = "nginx.service" | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 30 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 31 | CFLAGS:append = " -fPIE -pie" | 
|  | 32 | CXXFLAGS:append = " -fPIE -pie" | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 33 |  | 
|  | 34 | NGINX_WWWDIR ?= "${localstatedir}/www/localhost" | 
|  | 35 | NGINX_USER   ?= "www" | 
|  | 36 |  | 
|  | 37 | EXTRA_OECONF = "" | 
|  | 38 | DISABLE_STATIC = "" | 
|  | 39 |  | 
| Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 40 | PACKAGECONFIG ??= "ssl ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}" | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 41 |  | 
| Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 42 | PACKAGECONFIG[gunzip] = "--with-http_gunzip_module,," | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 43 | PACKAGECONFIG[http2] = "--with-http_v2_module,," | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 44 | PACKAGECONFIG[ssl] = "--with-http_ssl_module,,openssl" | 
| Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 45 | PACKAGECONFIG[http-auth-request] = "--with-http_auth_request_module,," | 
| Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 46 | PACKAGECONFIG[ipv6] = "--with-ipv6,," | 
| Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame] | 47 | PACKAGECONFIG[webdav] = "--with-http_dav_module,," | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 48 |  | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 49 | do_configure () { | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 50 | if [ "${SITEINFO_BITS}" = "64" ]; then | 
|  | 51 | PTRSIZE=8 | 
|  | 52 | else | 
|  | 53 | PTRSIZE=4 | 
|  | 54 | fi | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 55 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 56 | echo $CFLAGS | 
|  | 57 | echo $LDFLAGS | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 58 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 59 | # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH | 
|  | 60 | echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf | 
|  | 61 |  | 
|  | 62 | ./configure \ | 
|  | 63 | --crossbuild=Linux:${TUNE_ARCH} \ | 
| Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 64 | --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 65 | --with-int=4 \ | 
|  | 66 | --with-long=${PTRSIZE} \ | 
|  | 67 | --with-long-long=8 \ | 
|  | 68 | --with-ptr-size=${PTRSIZE} \ | 
|  | 69 | --with-sig-atomic-t=${PTRSIZE} \ | 
|  | 70 | --with-size-t=${PTRSIZE} \ | 
| Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 71 | --with-off-t=8 \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 72 | --with-time-t=${PTRSIZE} \ | 
|  | 73 | --with-sys-nerr=132 \ | 
|  | 74 | --conf-path=${sysconfdir}/nginx/nginx.conf \ | 
|  | 75 | --http-log-path=${localstatedir}/log/nginx/access.log \ | 
|  | 76 | --error-log-path=${localstatedir}/log/nginx/error.log \ | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 77 | --http-client-body-temp-path=/run/nginx/client_body_temp \ | 
|  | 78 | --http-proxy-temp-path=/run/nginx/proxy_temp \ | 
|  | 79 | --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \ | 
|  | 80 | --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \ | 
|  | 81 | --http-scgi-temp-path=/run/nginx/scgi_temp \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 82 | --pid-path=/run/nginx/nginx.pid \ | 
|  | 83 | --prefix=${prefix} \ | 
| Brad Bishop | 1a4b7ee | 2018-12-16 17:11:34 -0800 | [diff] [blame] | 84 | --with-threads \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 85 | --with-http_gzip_static_module \ | 
| Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 86 | ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS} | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
|  | 89 | do_install () { | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 90 | oe_runmake 'DESTDIR=${D}' install | 
|  | 91 | rm -fr ${D}${localstatedir}/run ${D}/run | 
|  | 92 | if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then | 
|  | 93 | install -d ${D}${sysconfdir}/tmpfiles.d | 
|  | 94 | echo "d /run/${BPN} - - - -" \ | 
|  | 95 | > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf | 
| Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 96 | echo "d ${localstatedir}/log/${BPN} 0755 root root -" \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 97 | >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf | 
|  | 98 | fi | 
|  | 99 | install -d ${D}${sysconfdir}/${BPN} | 
| Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 100 | ln -rs ${D}${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 101 | install -d ${D}${NGINX_WWWDIR} | 
| Brad Bishop | 23eaf03 | 2019-11-20 05:15:02 -0500 | [diff] [blame] | 102 | mv ${D}${exec_prefix}/html ${D}${NGINX_WWWDIR}/ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 103 | chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR} | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 104 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 105 | install -d ${D}${sysconfdir}/init.d | 
|  | 106 | install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx | 
|  | 107 | sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx | 
|  | 108 | sed -i 's,/etc/,${sysconfdir}/,g'  ${D}${sysconfdir}/init.d/nginx | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 109 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 110 | install -d ${D}${sysconfdir}/nginx | 
|  | 111 | install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 112 | sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/nginx/nginx.conf | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 113 | sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf | 
|  | 114 | 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] | 115 | install -Dm 0644 ${WORKDIR}/default_server.site ${D}${sysconfdir}/nginx/sites-available/default_server | 
|  | 116 | 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] | 117 | install -d ${D}${sysconfdir}/nginx/sites-enabled | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 118 | ln -s ../sites-available/default_server ${D}${sysconfdir}/nginx/sites-enabled/ | 
|  | 119 |  | 
|  | 120 | install -m 0644 ${WORKDIR}/proxy_params ${D}${sysconfdir}/nginx/proxy_params | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 121 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 122 | install -d ${D}${sysconfdir}/default/volatiles | 
|  | 123 | install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx | 
|  | 124 | sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx | 
| Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 125 | 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] | 126 |  | 
| Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame] | 127 | # cleanup configuration folder | 
|  | 128 | rm ${D}${sysconfdir}/nginx/*.default | 
|  | 129 |  | 
|  | 130 | # add additional configuration folders | 
|  | 131 | install -d ${D}${sysconfdir}/nginx/modules-available | 
|  | 132 | install -d ${D}${sysconfdir}/nginx/modules-enabled | 
|  | 133 | install -d ${D}${sysconfdir}/nginx/server-conf.d | 
|  | 134 | install -d ${D}${sysconfdir}/nginx/conf.d | 
|  | 135 |  | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 136 | if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then | 
|  | 137 | install -d ${D}${systemd_unitdir}/system | 
|  | 138 | install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/ | 
|  | 139 | sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \ | 
|  | 140 | -e 's,@LOCALSTATEDIR@,${localstatedir},g' \ | 
|  | 141 | -e 's,@SBINDIR@,${sbindir},g' \ | 
| Brad Bishop | 15ae250 | 2019-06-18 21:44:24 -0400 | [diff] [blame] | 142 | -e 's,@BASE_BINDIR@,${base_bindir},g' \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 143 | ${D}${systemd_unitdir}/system/nginx.service | 
|  | 144 | fi | 
| Andrew Geissler | 7f40b71 | 2020-05-15 14:09:53 -0500 | [diff] [blame] | 145 |  | 
|  | 146 | rm -rf ${D}${localstatedir}/log/ | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 147 | } | 
|  | 148 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 149 | pkg_postinst:${PN} () { | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 150 | if [ -z "$D" ]; then | 
| Patrick Williams | 8e7b46e | 2023-05-01 14:19:06 -0500 | [diff] [blame] | 151 | if type systemd-tmpfiles >/dev/null 2>&1; then | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 152 | systemd-tmpfiles --create | 
|  | 153 | elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then | 
|  | 154 | ${sysconfdir}/init.d/populate-volatile.sh update | 
|  | 155 | fi | 
|  | 156 | fi | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 157 | } | 
|  | 158 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 159 | FILES:${PN} += " \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 160 | ${localstatedir}/ \ | 
|  | 161 | ${systemd_unitdir}/system/nginx.service \ | 
|  | 162 | " | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 163 |  | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 164 | CONFFILES:${PN} = " \ | 
| Patrick Williams | ddad1a1 | 2017-02-23 20:36:32 -0600 | [diff] [blame] | 165 | ${sysconfdir}/nginx/nginx.conf \ | 
|  | 166 | ${sysconfdir}/nginx/fastcgi.conf \ | 
|  | 167 | ${sysconfdir}/nginx/fastcgi_params \ | 
|  | 168 | ${sysconfdir}/nginx/koi-utf \ | 
|  | 169 | ${sysconfdir}/nginx/koi-win \ | 
|  | 170 | ${sysconfdir}/nginx/mime.types \ | 
|  | 171 | ${sysconfdir}/nginx/scgi_params \ | 
|  | 172 | ${sysconfdir}/nginx/uwsgi_params \ | 
|  | 173 | ${sysconfdir}/nginx/win-utf \ | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 174 | " | 
|  | 175 |  | 
|  | 176 | INITSCRIPT_NAME = "nginx" | 
|  | 177 | INITSCRIPT_PARAMS = "defaults 92 20" | 
|  | 178 |  | 
|  | 179 | USERADD_PACKAGES = "${PN}" | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 180 | USERADD_PARAM:${PN} = " \ | 
| Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame] | 181 | --system --no-create-home \ | 
|  | 182 | --home ${NGINX_WWWDIR} \ | 
|  | 183 | --groups www-data \ | 
|  | 184 | --user-group ${NGINX_USER}" |