blob: f98f2992620a32c63c3f04d710c2dd6ed8b73e4c [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
12DEPENDS = "libpcre gzip openssl"
13
14SRC_URI = " \
Patrick Williamsddad1a12017-02-23 20:36:32 -060015 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 Williamsb48b7b42016-08-17 15:04:38 -050021"
22
Brad Bishop6e60e8b2018-02-01 10:27:11 -050023inherit update-rc.d useradd systemd
24
25SYSTEMD_SERVICE_${PN} = "nginx.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050026
27CFLAGS_append = " -fPIE -pie"
28CXXFLAGS_append = " -fPIE -pie"
29
30NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
31NGINX_USER ?= "www"
32
33EXTRA_OECONF = ""
34DISABLE_STATIC = ""
35
Patrick Williamsddad1a12017-02-23 20:36:32 -060036PACKAGECONFIG[http2] = "--with-http_v2_module,,"
37
Patrick Williamsb48b7b42016-08-17 15:04:38 -050038do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060039 if [ "${SITEINFO_BITS}" = "64" ]; then
40 PTRSIZE=8
41 else
42 PTRSIZE=4
43 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050044
Patrick Williamsddad1a12017-02-23 20:36:32 -060045 echo $CFLAGS
46 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050047
Patrick Williamsddad1a12017-02-23 20:36:32 -060048 # 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 Bishop6e60e8b2018-02-01 10:27:11 -050066 --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 Williamsddad1a12017-02-23 20:36:32 -060071 --pid-path=/run/nginx/nginx.pid \
72 --prefix=${prefix} \
73 --with-http_ssl_module \
74 --with-http_gzip_static_module \
75 ${EXTRA_OECONF}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050076}
77
78do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060079 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 Williamsb48b7b42016-08-17 15:04:38 -050093
Patrick Williamsddad1a12017-02-23 20:36:32 -060094 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 Williamsb48b7b42016-08-17 15:04:38 -050098
Patrick Williamsddad1a12017-02-23 20:36:32 -060099 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 Williamsb48b7b42016-08-17 15:04:38 -0500104
Patrick Williamsddad1a12017-02-23 20:36:32 -0600105 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 Bishop6e60e8b2018-02-01 10:27:11 -0500108 sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500109
Patrick Williamsddad1a12017-02-23 20:36:32 -0600110 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 Williamsb48b7b42016-08-17 15:04:38 -0500118}
119
120pkg_postinst_${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600121 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 Williamsb48b7b42016-08-17 15:04:38 -0500128}
129
Patrick Williamsddad1a12017-02-23 20:36:32 -0600130FILES_${PN} += " \
131 ${localstatedir}/ \
132 ${systemd_unitdir}/system/nginx.service \
133"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500134
Patrick Williamsddad1a12017-02-23 20:36:32 -0600135CONFFILES_${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 Williamsb48b7b42016-08-17 15:04:38 -0500145"
146
147INITSCRIPT_NAME = "nginx"
148INITSCRIPT_PARAMS = "defaults 92 20"
149
150USERADD_PACKAGES = "${PN}"
151USERADD_PARAM_${PN} = " \
152 --system --no-create-home \
153 --home ${NGINX_WWWDIR} \
154 --groups www-data \
155 --user-group ${NGINX_USER}"