blob: e202e8563704c37ee5ab2e7870fa95f287d66544 [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 \
Brad Bishop19323692019-04-05 15:28:33 -040019 file://default_server.site \
20 file://proxy_params \
Patrick Williamsddad1a12017-02-23 20:36:32 -060021 file://nginx.init \
22 file://nginx-volatile.conf \
23 file://nginx.service \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050024"
25
Brad Bishop316dfdd2018-06-25 12:45:53 -040026inherit siteinfo update-rc.d useradd systemd
Brad Bishop6e60e8b2018-02-01 10:27:11 -050027
28SYSTEMD_SERVICE_${PN} = "nginx.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050029
30CFLAGS_append = " -fPIE -pie"
31CXXFLAGS_append = " -fPIE -pie"
32
33NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
34NGINX_USER ?= "www"
35
36EXTRA_OECONF = ""
37DISABLE_STATIC = ""
38
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080039PACKAGECONFIG ??= "ssl"
40
Patrick Williamsddad1a12017-02-23 20:36:32 -060041PACKAGECONFIG[http2] = "--with-http_v2_module,,"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042PACKAGECONFIG[ssl] = "--with-http_ssl_module,,openssl"
Brad Bishop15ae2502019-06-18 21:44:24 -040043PACKAGECONFIG[http-auth-request] = "--with-http_auth_request_module,,"
Patrick Williamsddad1a12017-02-23 20:36:32 -060044
Patrick Williamsb48b7b42016-08-17 15:04:38 -050045do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060046 if [ "${SITEINFO_BITS}" = "64" ]; then
47 PTRSIZE=8
48 else
49 PTRSIZE=4
50 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050051
Patrick Williamsddad1a12017-02-23 20:36:32 -060052 echo $CFLAGS
53 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050054
Patrick Williamsddad1a12017-02-23 20:36:32 -060055 # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
56 echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
57
58 ./configure \
59 --crossbuild=Linux:${TUNE_ARCH} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040060 --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
Patrick Williamsddad1a12017-02-23 20:36:32 -060061 --with-int=4 \
62 --with-long=${PTRSIZE} \
63 --with-long-long=8 \
64 --with-ptr-size=${PTRSIZE} \
65 --with-sig-atomic-t=${PTRSIZE} \
66 --with-size-t=${PTRSIZE} \
67 --with-off-t=${PTRSIZE} \
68 --with-time-t=${PTRSIZE} \
69 --with-sys-nerr=132 \
70 --conf-path=${sysconfdir}/nginx/nginx.conf \
71 --http-log-path=${localstatedir}/log/nginx/access.log \
72 --error-log-path=${localstatedir}/log/nginx/error.log \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073 --http-client-body-temp-path=/run/nginx/client_body_temp \
74 --http-proxy-temp-path=/run/nginx/proxy_temp \
75 --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \
76 --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \
77 --http-scgi-temp-path=/run/nginx/scgi_temp \
Patrick Williamsddad1a12017-02-23 20:36:32 -060078 --pid-path=/run/nginx/nginx.pid \
79 --prefix=${prefix} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080080 --with-threads \
Patrick Williamsddad1a12017-02-23 20:36:32 -060081 --with-http_gzip_static_module \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050082 ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050083}
84
85do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060086 oe_runmake 'DESTDIR=${D}' install
87 rm -fr ${D}${localstatedir}/run ${D}/run
88 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
89 install -d ${D}${sysconfdir}/tmpfiles.d
90 echo "d /run/${BPN} - - - -" \
91 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
92 echo "d /${localstatedir}/log/${BPN} 0755 root root -" \
93 >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
94 fi
95 install -d ${D}${sysconfdir}/${BPN}
96 ln -snf ${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
97 install -d ${D}${NGINX_WWWDIR}
98 mv ${D}/usr/html ${D}${NGINX_WWWDIR}/
99 chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500100
Patrick Williamsddad1a12017-02-23 20:36:32 -0600101 install -d ${D}${sysconfdir}/init.d
102 install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
103 sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
104 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500105
Patrick Williamsddad1a12017-02-23 20:36:32 -0600106 install -d ${D}${sysconfdir}/nginx
107 install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
Brad Bishop19323692019-04-05 15:28:33 -0400108 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
Patrick Williamsddad1a12017-02-23 20:36:32 -0600109 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
110 sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
Brad Bishop19323692019-04-05 15:28:33 -0400111 install -Dm 0644 ${WORKDIR}/default_server.site ${D}${sysconfdir}/nginx/sites-available/default_server
112 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/sites-available/default_server
Patrick Williamsddad1a12017-02-23 20:36:32 -0600113 install -d ${D}${sysconfdir}/nginx/sites-enabled
Brad Bishop19323692019-04-05 15:28:33 -0400114 ln -s ../sites-available/default_server ${D}${sysconfdir}/nginx/sites-enabled/
115
116 install -m 0644 ${WORKDIR}/proxy_params ${D}${sysconfdir}/nginx/proxy_params
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500117
Patrick Williamsddad1a12017-02-23 20:36:32 -0600118 install -d ${D}${sysconfdir}/default/volatiles
119 install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
120 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500121 sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500122
Brad Bishop19323692019-04-05 15:28:33 -0400123 # cleanup configuration folder
124 rm ${D}${sysconfdir}/nginx/*.default
125
126 # add additional configuration folders
127 install -d ${D}${sysconfdir}/nginx/modules-available
128 install -d ${D}${sysconfdir}/nginx/modules-enabled
129 install -d ${D}${sysconfdir}/nginx/server-conf.d
130 install -d ${D}${sysconfdir}/nginx/conf.d
131
Patrick Williamsddad1a12017-02-23 20:36:32 -0600132 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
133 install -d ${D}${systemd_unitdir}/system
134 install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
135 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
136 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
137 -e 's,@SBINDIR@,${sbindir},g' \
Brad Bishop15ae2502019-06-18 21:44:24 -0400138 -e 's,@BASE_BINDIR@,${base_bindir},g' \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600139 ${D}${systemd_unitdir}/system/nginx.service
140 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500141}
142
143pkg_postinst_${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600144 if [ -z "$D" ]; then
145 if type systemd-tmpfiles >/dev/null; then
146 systemd-tmpfiles --create
147 elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
148 ${sysconfdir}/init.d/populate-volatile.sh update
149 fi
150 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500151}
152
Patrick Williamsddad1a12017-02-23 20:36:32 -0600153FILES_${PN} += " \
154 ${localstatedir}/ \
155 ${systemd_unitdir}/system/nginx.service \
156"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500157
Patrick Williamsddad1a12017-02-23 20:36:32 -0600158CONFFILES_${PN} = " \
159 ${sysconfdir}/nginx/nginx.conf \
160 ${sysconfdir}/nginx/fastcgi.conf \
161 ${sysconfdir}/nginx/fastcgi_params \
162 ${sysconfdir}/nginx/koi-utf \
163 ${sysconfdir}/nginx/koi-win \
164 ${sysconfdir}/nginx/mime.types \
165 ${sysconfdir}/nginx/scgi_params \
166 ${sysconfdir}/nginx/uwsgi_params \
167 ${sysconfdir}/nginx/win-utf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500168"
169
170INITSCRIPT_NAME = "nginx"
171INITSCRIPT_PARAMS = "defaults 92 20"
172
173USERADD_PACKAGES = "${PN}"
174USERADD_PARAM_${PN} = " \
175 --system --no-create-home \
176 --home ${NGINX_WWWDIR} \
177 --groups www-data \
178 --user-group ${NGINX_USER}"