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