blob: 8890e0bea1aa2ad9ff804215636653573e2b0bfd [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 \
Andrew Geissler82c905d2020-04-13 13:39:40 -050024 file://nginx-fix-pidfile.patch \
Andrew Geissler20137392023-10-12 04:59:14 -060025 file://0001-configure-libxslt-conf.patch \
Patrick Williamsb48b7b42016-08-17 15:04:38 -050026"
27
Brad Bishop316dfdd2018-06-25 12:45:53 -040028inherit siteinfo update-rc.d useradd systemd
Brad Bishop6e60e8b2018-02-01 10:27:11 -050029
Patrick Williams213cb262021-08-07 19:21:33 -050030SYSTEMD_SERVICE:${PN} = "nginx.service"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050031
Patrick Williams213cb262021-08-07 19:21:33 -050032CFLAGS:append = " -fPIE -pie"
33CXXFLAGS:append = " -fPIE -pie"
Patrick Williamsb48b7b42016-08-17 15:04:38 -050034
35NGINX_WWWDIR ?= "${localstatedir}/www/localhost"
36NGINX_USER ?= "www"
37
38EXTRA_OECONF = ""
39DISABLE_STATIC = ""
40
Patrick Williams2390b1b2022-11-03 13:47:49 -050041PACKAGECONFIG ??= "ssl ${@bb.utils.filter('DISTRO_FEATURES', 'ipv6', d)}"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080042
Andrew Geissler9aee5002022-03-30 16:27:02 +000043PACKAGECONFIG[gunzip] = "--with-http_gunzip_module,,"
Patrick Williamsddad1a12017-02-23 20:36:32 -060044PACKAGECONFIG[http2] = "--with-http_v2_module,,"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080045PACKAGECONFIG[ssl] = "--with-http_ssl_module,,openssl"
Brad Bishop15ae2502019-06-18 21:44:24 -040046PACKAGECONFIG[http-auth-request] = "--with-http_auth_request_module,,"
Patrick Williams2390b1b2022-11-03 13:47:49 -050047PACKAGECONFIG[ipv6] = "--with-ipv6,,"
Patrick Williams8e7b46e2023-05-01 14:19:06 -050048PACKAGECONFIG[webdav] = "--with-http_dav_module,,"
Andrew Geissler8f840682023-07-21 09:09:43 -050049PACKAGECONFIG[stream] = "--with-stream,,"
Patrick Williamsddad1a12017-02-23 20:36:32 -060050
Andrew Geissler20137392023-10-12 04:59:14 -060051PACKAGECONFIG[xslt] = "--with-http_xslt_module,,libxslt"
52
Patrick Williamsb48b7b42016-08-17 15:04:38 -050053do_configure () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060054 if [ "${SITEINFO_BITS}" = "64" ]; then
55 PTRSIZE=8
56 else
57 PTRSIZE=4
58 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -050059
Patrick Williamsddad1a12017-02-23 20:36:32 -060060 echo $CFLAGS
61 echo $LDFLAGS
Patrick Williamsb48b7b42016-08-17 15:04:38 -050062
Patrick Williamsddad1a12017-02-23 20:36:32 -060063 # Add the LDFLAGS to the main nginx link to avoid issues with missing GNU_HASH
64 echo "MAIN_LINK=\"\${MAIN_LINK} ${LDFLAGS}\"" >> auto/cc/conf
65
66 ./configure \
67 --crossbuild=Linux:${TUNE_ARCH} \
Brad Bishop316dfdd2018-06-25 12:45:53 -040068 --with-endian=${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'le', 'little', 'big', d)} \
Patrick Williamsddad1a12017-02-23 20:36:32 -060069 --with-int=4 \
70 --with-long=${PTRSIZE} \
71 --with-long-long=8 \
72 --with-ptr-size=${PTRSIZE} \
73 --with-sig-atomic-t=${PTRSIZE} \
74 --with-size-t=${PTRSIZE} \
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050075 --with-off-t=8 \
Patrick Williamsddad1a12017-02-23 20:36:32 -060076 --with-time-t=${PTRSIZE} \
77 --with-sys-nerr=132 \
78 --conf-path=${sysconfdir}/nginx/nginx.conf \
79 --http-log-path=${localstatedir}/log/nginx/access.log \
80 --error-log-path=${localstatedir}/log/nginx/error.log \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081 --http-client-body-temp-path=/run/nginx/client_body_temp \
82 --http-proxy-temp-path=/run/nginx/proxy_temp \
83 --http-fastcgi-temp-path=/run/nginx/fastcgi_temp \
84 --http-uwsgi-temp-path=/run/nginx/uwsgi_temp \
85 --http-scgi-temp-path=/run/nginx/scgi_temp \
Patrick Williamsddad1a12017-02-23 20:36:32 -060086 --pid-path=/run/nginx/nginx.pid \
87 --prefix=${prefix} \
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080088 --with-threads \
Patrick Williamsddad1a12017-02-23 20:36:32 -060089 --with-http_gzip_static_module \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050090 ${EXTRA_OECONF} ${PACKAGECONFIG_CONFARGS}
Patrick Williamsb48b7b42016-08-17 15:04:38 -050091}
92
93do_install () {
Patrick Williamsddad1a12017-02-23 20:36:32 -060094 oe_runmake 'DESTDIR=${D}' install
95 rm -fr ${D}${localstatedir}/run ${D}/run
96 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
97 install -d ${D}${sysconfdir}/tmpfiles.d
98 echo "d /run/${BPN} - - - -" \
99 > ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
Andrew Geissler7f40b712020-05-15 14:09:53 -0500100 echo "d ${localstatedir}/log/${BPN} 0755 root root -" \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600101 >> ${D}${sysconfdir}/tmpfiles.d/${BPN}.conf
102 fi
103 install -d ${D}${sysconfdir}/${BPN}
Andrew Geissler595f6302022-01-24 19:11:47 +0000104 ln -rs ${D}${localstatedir}/run/${BPN} ${D}${sysconfdir}/${BPN}/run
Patrick Williamsddad1a12017-02-23 20:36:32 -0600105 install -d ${D}${NGINX_WWWDIR}
Brad Bishop23eaf032019-11-20 05:15:02 -0500106 mv ${D}${exec_prefix}/html ${D}${NGINX_WWWDIR}/
Patrick Williamsddad1a12017-02-23 20:36:32 -0600107 chown ${NGINX_USER}:www-data -R ${D}${NGINX_WWWDIR}
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500108
Patrick Williamsddad1a12017-02-23 20:36:32 -0600109 install -d ${D}${sysconfdir}/init.d
110 install -m 0755 ${WORKDIR}/nginx.init ${D}${sysconfdir}/init.d/nginx
111 sed -i 's,/usr/sbin/,${sbindir}/,g' ${D}${sysconfdir}/init.d/nginx
112 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/init.d/nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500113
Patrick Williamsddad1a12017-02-23 20:36:32 -0600114 install -d ${D}${sysconfdir}/nginx
115 install -m 0644 ${WORKDIR}/nginx.conf ${D}${sysconfdir}/nginx/nginx.conf
Brad Bishop19323692019-04-05 15:28:33 -0400116 sed -i 's,/etc/,${sysconfdir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
Patrick Williamsddad1a12017-02-23 20:36:32 -0600117 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/nginx.conf
118 sed -i 's/^user.*/user ${NGINX_USER};/g' ${D}${sysconfdir}/nginx/nginx.conf
Brad Bishop19323692019-04-05 15:28:33 -0400119 install -Dm 0644 ${WORKDIR}/default_server.site ${D}${sysconfdir}/nginx/sites-available/default_server
120 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/nginx/sites-available/default_server
Patrick Williamsddad1a12017-02-23 20:36:32 -0600121 install -d ${D}${sysconfdir}/nginx/sites-enabled
Brad Bishop19323692019-04-05 15:28:33 -0400122 ln -s ../sites-available/default_server ${D}${sysconfdir}/nginx/sites-enabled/
123
124 install -m 0644 ${WORKDIR}/proxy_params ${D}${sysconfdir}/nginx/proxy_params
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500125
Patrick Williamsddad1a12017-02-23 20:36:32 -0600126 install -d ${D}${sysconfdir}/default/volatiles
127 install -m 0644 ${WORKDIR}/nginx-volatile.conf ${D}${sysconfdir}/default/volatiles/99_nginx
128 sed -i 's,/var/,${localstatedir}/,g' ${D}${sysconfdir}/default/volatiles/99_nginx
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500129 sed -i 's,@NGINX_USER@,${NGINX_USER},g' ${D}${sysconfdir}/default/volatiles/99_nginx
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500130
Brad Bishop19323692019-04-05 15:28:33 -0400131 # cleanup configuration folder
132 rm ${D}${sysconfdir}/nginx/*.default
133
134 # add additional configuration folders
135 install -d ${D}${sysconfdir}/nginx/modules-available
136 install -d ${D}${sysconfdir}/nginx/modules-enabled
137 install -d ${D}${sysconfdir}/nginx/server-conf.d
138 install -d ${D}${sysconfdir}/nginx/conf.d
139
Patrick Williamsddad1a12017-02-23 20:36:32 -0600140 if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)};then
141 install -d ${D}${systemd_unitdir}/system
142 install -m 0644 ${WORKDIR}/nginx.service ${D}${systemd_unitdir}/system/
143 sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
144 -e 's,@LOCALSTATEDIR@,${localstatedir},g' \
145 -e 's,@SBINDIR@,${sbindir},g' \
Brad Bishop15ae2502019-06-18 21:44:24 -0400146 -e 's,@BASE_BINDIR@,${base_bindir},g' \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600147 ${D}${systemd_unitdir}/system/nginx.service
148 fi
Andrew Geissler7f40b712020-05-15 14:09:53 -0500149
150 rm -rf ${D}${localstatedir}/log/
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500151}
152
Patrick Williams213cb262021-08-07 19:21:33 -0500153pkg_postinst:${PN} () {
Patrick Williamsddad1a12017-02-23 20:36:32 -0600154 if [ -z "$D" ]; then
Patrick Williams8e7b46e2023-05-01 14:19:06 -0500155 if type systemd-tmpfiles >/dev/null 2>&1; then
Patrick Williamsddad1a12017-02-23 20:36:32 -0600156 systemd-tmpfiles --create
157 elif [ -e ${sysconfdir}/init.d/populate-volatile.sh ]; then
158 ${sysconfdir}/init.d/populate-volatile.sh update
159 fi
160 fi
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500161}
162
Patrick Williams213cb262021-08-07 19:21:33 -0500163FILES:${PN} += " \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600164 ${localstatedir}/ \
165 ${systemd_unitdir}/system/nginx.service \
166"
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500167
Patrick Williams213cb262021-08-07 19:21:33 -0500168CONFFILES:${PN} = " \
Patrick Williamsddad1a12017-02-23 20:36:32 -0600169 ${sysconfdir}/nginx/nginx.conf \
170 ${sysconfdir}/nginx/fastcgi.conf \
171 ${sysconfdir}/nginx/fastcgi_params \
172 ${sysconfdir}/nginx/koi-utf \
173 ${sysconfdir}/nginx/koi-win \
174 ${sysconfdir}/nginx/mime.types \
175 ${sysconfdir}/nginx/scgi_params \
176 ${sysconfdir}/nginx/uwsgi_params \
177 ${sysconfdir}/nginx/win-utf \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500178"
179
180INITSCRIPT_NAME = "nginx"
181INITSCRIPT_PARAMS = "defaults 92 20"
182
183USERADD_PACKAGES = "${PN}"
Patrick Williams213cb262021-08-07 19:21:33 -0500184USERADD_PARAM:${PN} = " \
Patrick Williamsb48b7b42016-08-17 15:04:38 -0500185 --system --no-create-home \
186 --home ${NGINX_WWWDIR} \
187 --groups www-data \
188 --user-group ${NGINX_USER}"