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