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