blob: 24c2cedf5fe83bbcb34de5968c4832c517906687 [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001SUMMARY = "HTTP and reverse proxy server"
2
3DESCRIPTION = "Nginx is a web server and a reverse proxy server for \
4HTTP, SMTP, POP3 and IMAP protocols, with a strong focus on high \
5concurrency, performance and low memory usage."
6
7HOMEPAGE = "http://nginx.org/"
8LICENSE = "BSD-2-Clause"
9
10SECTION = "net"
11
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012DEPENDS = "libpcre zlib"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050013
14SRC_URI = " \
Patrick Williamsddad1a12017-02-23 20:36:32 -060015 http://nginx.org/download/nginx-${PV}.tar.gz \
16 file://nginx-cross.patch \
Brad Bishop316dfdd2018-06-25 12:45:53 -040017 file://0001-Allow-the-overriding-of-the-endianness-via-the-confi.patch \
Patrick Williamsddad1a12017-02-23 20:36:32 -060018 file://nginx.conf \
19 file://nginx.init \
20 file://nginx-volatile.conf \
21 file://nginx.service \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050022"
23
Brad Bishop316dfdd2018-06-25 12:45:53 -040024inherit siteinfo update-rc.d useradd systemd
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025
26SYSTEMD_SERVICE_${PN} = "nginx.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050027
28CFLAGS_append = " -fPIE -pie"
29CXXFLAGS_append = " -fPIE -pie"
30
31NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
32NGINX_USER ?= "www"
33
34EXTRA_OECONF = ""
35DISABLE_STATIC = ""
36
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080037PACKAGECONFIG ??= "ssl"
38
Patrick Williamsddad1a12017-02-23 20:36:32 -060039PACKAGECONFIG[http2] = "--with-http_v2_module,,"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080040PACKAGECONFIG[ssl] = "--with-http_ssl_module,,openssl"
Patrick Williamsddad1a12017-02-23 20:36:32 -060041
Patrick Williamsb48b7b42016-08-17 15:04:38 -050042do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060043 if [ "${SITEINFO_BITS}" = "64" ]; then
44 PTRSIZE=8
45 else
46 PTRSIZE=4
47 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050048
Patrick Williamsddad1a12017-02-23 20:36:32 -060049 echo $CFLAGS
50 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050051
Patrick Williamsddad1a12017-02-23 20:36:32 -060052 # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
53 echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
54
55 ./configure \
56 --crossbuild=Linux:${TUNE_ARCH} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040057 --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
Patrick Williamsddad1a12017-02-23 20:36:32 -060058 --with-int=4 \
59 --with-long=${PTRSIZE} \
60 --with-long-long=8 \
61 --with-ptr-size=${PTRSIZE} \
62 --with-sig-atomic-t=${PTRSIZE} \
63 --with-size-t=${PTRSIZE} \
64 --with-off-t=${PTRSIZE} \
65 --with-time-t=${PTRSIZE} \
66 --with-sys-nerr=132 \
67 --conf-path=${sysconfdir}/nginx/nginx.conf \
68 --http-log-path=${localstatedir}/log/nginx/access.log \
69 --error-log-path=${localstatedir}/log/nginx/error.log \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050070 --http-client-body-temp-path=/run/nginx/client_body_temp \
71 --http-proxy-temp-path=/run/nginx/proxy_temp \
72 --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \
73 --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \
74 --http-scgi-temp-path=/run/nginx/scgi_temp \
Patrick Williamsddad1a12017-02-23 20:36:32 -060075 --pid-path=/run/nginx/nginx.pid \
76 --prefix=${prefix} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080077 --with-threads \
Patrick Williamsddad1a12017-02-23 20:36:32 -060078 --with-http_gzip_static_module \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050079 ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050080}
81
82do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060083 oe_runmake 'DESTDIR=${D}' install
84 rm -fr ${D}${localstatedir}/run ${D}/run
85 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
86 install -d ${D}${sysconfdir}/tmpfiles.d
87 echo "d /run/${BPN} - - - -" \
88 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
89 echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
90 >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
91 fi
92 install -d ${D}${sysconfdir}/${BPN}
93 ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
94 install -d ${D}${NGINX_WWWDIR}
95 mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
96 chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050097
Patrick Williamsddad1a12017-02-23 20:36:32 -060098 install -d ${D}${sysconfdir}/init.d
99 install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
100 sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
101 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500102
Patrick Williamsddad1a12017-02-23 20:36:32 -0600103 install -d ${D}${sysconfdir}/nginx
104 install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
105 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
106 sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
107 install -d ${D}${sysconfdir}/nginx/sites-enabled
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500108
Patrick Williamsddad1a12017-02-23 20:36:32 -0600109 install -d ${D}${sysconfdir}/default/volatiles
110 install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
111 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500112 sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500113
Patrick Williamsddad1a12017-02-23 20:36:32 -0600114 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
115 install -d ${D}${systemd_unitdir}/system
116 install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
117 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
118 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
119 -e 's,@SBINDIR@,${sbindir},g' \
120 ${D}${systemd_unitdir}/system/nginx.service
121 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500122}
123
124pkg_postinst_${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600125 if [ -z "$D" ]; then
126 if type systemd-tmpfiles >/dev/null; then
127 systemd-tmpfiles --create
128 elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
129 ${sysconfdir}/init.d/populate-volatile.sh update
130 fi
131 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500132}
133
Patrick Williamsddad1a12017-02-23 20:36:32 -0600134FILES_${PN} += " \
135 ${localstatedir}/ \
136 ${systemd_unitdir}/system/nginx.service \
137"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500138
Patrick Williamsddad1a12017-02-23 20:36:32 -0600139CONFFILES_${PN} = " \
140 ${sysconfdir}/nginx/nginx.conf \
141 ${sysconfdir}/nginx/fastcgi.conf \
142 ${sysconfdir}/nginx/fastcgi_params \
143 ${sysconfdir}/nginx/koi-utf \
144 ${sysconfdir}/nginx/koi-win \
145 ${sysconfdir}/nginx/mime.types \
146 ${sysconfdir}/nginx/scgi_params \
147 ${sysconfdir}/nginx/uwsgi_params \
148 ${sysconfdir}/nginx/win-utf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500149"
150
151INITSCRIPT_NAME = "nginx"
152INITSCRIPT_PARAMS = "defaults 92 20"
153
154USERADD_PACKAGES = "${PN}"
155USERADD_PARAM_${PN} = " \
156 --system --no-create-home \
157 --home ${NGINX_WWWDIR} \
158 --groups www-data \
159 --user-group ${NGINX_USER}"