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