blob: 36f2ac6d71e866d7a2b7709efbc199b817c3f024 [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
23inherit update-rc.d useradd
24
25CFLAGS_append = " -fPIE -pie"
26CXXFLAGS_append = " -fPIE -pie"
27
28NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
29NGINX_USER ?= "www"
30
31EXTRA_OECONF = ""
32DISABLE_STATIC = ""
33
Patrick Williamsddad1a12017-02-23 20:36:32 -060034PACKAGECONFIG[http2] = "--with-http_v2_module,,"
35
Patrick Williamsb48b7b42016-08-17 15:04:38 -050036do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060037 if [ "${SITEINFO_BITS}" = "64" ]; then
38 PTRSIZE=8
39 else
40 PTRSIZE=4
41 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050042
Patrick Williamsddad1a12017-02-23 20:36:32 -060043 echo $CFLAGS
44 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050045
Patrick Williamsddad1a12017-02-23 20:36:32 -060046 # 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 Williamsb48b7b42016-08-17 15:04:38 -050069}
70
71do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060072 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 Williamsb48b7b42016-08-17 15:04:38 -050086
Patrick Williamsddad1a12017-02-23 20:36:32 -060087 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 Williamsb48b7b42016-08-17 15:04:38 -050091
Patrick Williamsddad1a12017-02-23 20:36:32 -060092 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 Williamsb48b7b42016-08-17 15:04:38 -050097
Patrick Williamsddad1a12017-02-23 20:36:32 -060098 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 Williamsb48b7b42016-08-17 15:04:38 -0500101
Patrick Williamsddad1a12017-02-23 20:36:32 -0600102 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 Williamsb48b7b42016-08-17 15:04:38 -0500110}
111
112pkg_postinst_${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600113 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 Williamsb48b7b42016-08-17 15:04:38 -0500120}
121
Patrick Williamsddad1a12017-02-23 20:36:32 -0600122FILES_${PN} += " \
123 ${localstatedir}/ \
124 ${systemd_unitdir}/system/nginx.service \
125"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500126
Patrick Williamsddad1a12017-02-23 20:36:32 -0600127CONFFILES_${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 Williamsb48b7b42016-08-17 15:04:38 -0500137"
138
139INITSCRIPT_NAME = "nginx"
140INITSCRIPT_PARAMS = "defaults 92 20"
141
142USERADD_PACKAGES = "${PN}"
143USERADD_PARAM_${PN} = " \
144 --system --no-create-home \
145 --home ${NGINX_WWWDIR} \
146 --groups www-data \
147 --user-group ${NGINX_USER}"