blob: ebf926a2017fb7ea70bfb4fda11bfd247f48437b [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 = " \
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 \
21"
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
34do_configure () {
35 if [ "${SITEINFO_BITS}" = "64" ]; then
36 PTRSIZE=8
37 else
38 PTRSIZE=4
39 fi
40
41 echo $CFLAGS
42 echo $LDFLAGS
43
44 ./configure \
45 --crossbuild=Linux:${TUNE_ARCH} \
46 --with-endian=${@base_conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
47 --with-int=4 \
48 --with-long=${PTRSIZE} \
49 --with-long-long=8 \
50 --with-ptr-size=${PTRSIZE} \
51 --with-sig-atomic-t=${PTRSIZE} \
52 --with-size-t=${PTRSIZE} \
53 --with-off-t=${PTRSIZE} \
54 --with-time-t=${PTRSIZE} \
55 --with-sys-nerr=132 \
56 --conf-path=${sysconfdir}/nginx/nginx.conf \
57 --http-log-path=${localstatedir}/log/nginx/access.log \
58 --error-log-path=${localstatedir}/log/nginx/error.log \
59 --pid-path=/run/nginx/nginx.pid \
60 --prefix=${prefix} \
61 --with-http_ssl_module \
62 --with-http_gzip_static_module \
63 ${EXTRA_OECONF}
64}
65
66do_install () {
67 oe_runmake 'DESTDIR=${D}' install
68 rm -fr ${D}${localstatedir}/run ${D}/run
69 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
70 install -d ${D}${sysconfdir}/tmpfiles.d
71 echo "d /run/${BPN} - - - -" \
72 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
73 fi
74 install -d ${D}${sysconfdir}/${BPN}
75 ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
76 install -d ${D}${NGINX_WWWDIR}
77 mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
78 chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
79
80 install -d ${D}${sysconfdir}/init.d
81 install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
82 sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
83 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
84
85 install -d ${D}${sysconfdir}/nginx
86 install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
87 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
88 install -d ${D}${sysconfdir}/nginx/sites-enabled
89
90 install -d ${D}${sysconfdir}/default/volatiles
91 install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
92 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
93
94 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
95 install -d ${D}${systemd_unitdir}/system
96 install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
97 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
98 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
99 -e 's,@BASEBINDIR@,${base_bindir},g' \
100 ${D}${systemd_unitdir}/system/nginx.service
101 fi
102}
103
104pkg_postinst_${PN} () {
105 if [ -z "$D" ]; then
106 if type systemd-tmpfiles >/dev/null; then
107 systemd-tmpfiles --create
108 elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
109 ${sysconfdir}/init.d/populate-volatile.sh update
110 fi
111 fi
112}
113
114FILES_${PN} += "${localstatedir}/ \
115 ${systemd_unitdir}/system/nginx.service \
116 "
117
118CONFFILES_${PN} = "${sysconfdir}/nginx/nginx.conf \
119 ${sysconfdir}/nginx/fastcgi.conf\
120 ${sysconfdir}/nginx/fastcgi_params \
121 ${sysconfdir}/nginx/koi-utf \
122 ${sysconfdir}/nginx/koi-win \
123 ${sysconfdir}/nginx/mime.types \
124 ${sysconfdir}/nginx/scgi_params \
125 ${sysconfdir}/nginx/uwsgi_params \
126 ${sysconfdir}/nginx/win-utf \
127"
128
129INITSCRIPT_NAME = "nginx"
130INITSCRIPT_PARAMS = "defaults 92 20"
131
132USERADD_PACKAGES = "${PN}"
133USERADD_PARAM_${PN} = " \
134 --system --no-create-home \
135 --home ${NGINX_WWWDIR} \
136 --groups www-data \
137 --user-group ${NGINX_USER}"