blob: e6ae52a09ff0a0cee20f8e0c60dc6347fb3b4095 [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 Bishopd7bf8c12018-02-25 22:55:05 -050012DEPENDS = "libpcre zlib openssl"
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
Patrick Williamsddad1a12017-02-23 20:36:32 -060037PACKAGECONFIG[http2] = "--with-http_v2_module,,"
38
Patrick Williamsb48b7b42016-08-17 15:04:38 -050039do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060040 if [ "${SITEINFO_BITS}" = "64" ]; then
41 PTRSIZE=8
42 else
43 PTRSIZE=4
44 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050045
Patrick Williamsddad1a12017-02-23 20:36:32 -060046 echo $CFLAGS
47 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050048
Patrick Williamsddad1a12017-02-23 20:36:32 -060049 # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
50 echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
51
52 ./configure \
53 --crossbuild=Linux:${TUNE_ARCH} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040054 --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
Patrick Williamsddad1a12017-02-23 20:36:32 -060055 --with-int=4 \
56 --with-long=${PTRSIZE} \
57 --with-long-long=8 \
58 --with-ptr-size=${PTRSIZE} \
59 --with-sig-atomic-t=${PTRSIZE} \
60 --with-size-t=${PTRSIZE} \
61 --with-off-t=${PTRSIZE} \
62 --with-time-t=${PTRSIZE} \
63 --with-sys-nerr=132 \
64 --conf-path=${sysconfdir}/nginx/nginx.conf \
65 --http-log-path=${localstatedir}/log/nginx/access.log \
66 --error-log-path=${localstatedir}/log/nginx/error.log \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067 --http-client-body-temp-path=/run/nginx/client_body_temp \
68 --http-proxy-temp-path=/run/nginx/proxy_temp \
69 --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \
70 --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \
71 --http-scgi-temp-path=/run/nginx/scgi_temp \
Patrick Williamsddad1a12017-02-23 20:36:32 -060072 --pid-path=/run/nginx/nginx.pid \
73 --prefix=${prefix} \
74 --with-http_ssl_module \
75 --with-http_gzip_static_module \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050076 ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050077}
78
79do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060080 oe_runmake 'DESTDIR=${D}' install
81 rm -fr ${D}${localstatedir}/run ${D}/run
82 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
83 install -d ${D}${sysconfdir}/tmpfiles.d
84 echo "d /run/${BPN} - - - -" \
85 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
86 echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
87 >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
88 fi
89 install -d ${D}${sysconfdir}/${BPN}
90 ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
91 install -d ${D}${NGINX_WWWDIR}
92 mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
93 chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050094
Patrick Williamsddad1a12017-02-23 20:36:32 -060095 install -d ${D}${sysconfdir}/init.d
96 install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
97 sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
98 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -050099
Patrick Williamsddad1a12017-02-23 20:36:32 -0600100 install -d ${D}${sysconfdir}/nginx
101 install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
102 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
103 sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
104 install -d ${D}${sysconfdir}/nginx/sites-enabled
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500105
Patrick Williamsddad1a12017-02-23 20:36:32 -0600106 install -d ${D}${sysconfdir}/default/volatiles
107 install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
108 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500109 sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500110
Patrick Williamsddad1a12017-02-23 20:36:32 -0600111 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
112 install -d ${D}${systemd_unitdir}/system
113 install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
114 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
115 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
116 -e 's,@SBINDIR@,${sbindir},g' \
117 ${D}${systemd_unitdir}/system/nginx.service
118 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500119}
120
121pkg_postinst_${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600122 if [ -z "$D" ]; then
123 if type systemd-tmpfiles >/dev/null; then
124 systemd-tmpfiles --create
125 elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
126 ${sysconfdir}/init.d/populate-volatile.sh update
127 fi
128 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500129}
130
Patrick Williamsddad1a12017-02-23 20:36:32 -0600131FILES_${PN} += " \
132 ${localstatedir}/ \
133 ${systemd_unitdir}/system/nginx.service \
134"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500135
Patrick Williamsddad1a12017-02-23 20:36:32 -0600136CONFFILES_${PN} = " \
137 ${sysconfdir}/nginx/nginx.conf \
138 ${sysconfdir}/nginx/fastcgi.conf \
139 ${sysconfdir}/nginx/fastcgi_params \
140 ${sysconfdir}/nginx/koi-utf \
141 ${sysconfdir}/nginx/koi-win \
142 ${sysconfdir}/nginx/mime.types \
143 ${sysconfdir}/nginx/scgi_params \
144 ${sysconfdir}/nginx/uwsgi_params \
145 ${sysconfdir}/nginx/win-utf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500146"
147
148INITSCRIPT_NAME = "nginx"
149INITSCRIPT_PARAMS = "defaults 92 20"
150
151USERADD_PACKAGES = "${PN}"
152USERADD_PARAM_${PN} = " \
153 --system --no-create-home \
154 --home ${NGINX_WWWDIR} \
155 --groups www-data \
156 --user-group ${NGINX_USER}"