nginx-ilves/PKGBUILD

206 lines
6.8 KiB
Bash

# $Id$
# Maintainer: Giancarlo Razzolini <grazzolini@archlinux.org>
# Contributor: Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Sébastien Luttringer
# Contributor: Drew DeVault
# Contributor: Arti Zirk <arti.zirk@gmail.com>
# Contributor: Mark Vainomaa <mikroskeem@mikroskeem.eu>
_davext_ver=3.0.0
_fancyindex_ver=0.4.3
_headers_more_ver=0.33
_nchan_ver=1.2.6
_brotli_commit=e505dce68acc190cc5a1e780a3b0275e39f160ca
_boringssl_commit=9638f8fba961a593c064e3036bb580bdace29e8f
_zlibng_commit=503bdef7a29a7078a50d8149e261c4299a82a9da
_pkgname=nginx
pkgname=nginx-ilves
pkgver=1.17.5
pkgrel=1
pkgdesc='Lightweight HTTP server and IMAP/POP3 proxy server, mainline release'
arch=('x86_64')
url='https://nginx.org'
license=('custom')
depends=('pcre' 'brotli' 'geoip' 'mailcap'
'libxml2') # Extra modules dependencies
makedepends=('cmake' 'go')
backup=('etc/nginx/fastcgi.conf'
'etc/nginx/fastcgi_params'
'etc/nginx/koi-win'
'etc/nginx/koi-utf'
'etc/nginx/nginx.conf'
'etc/nginx/scgi_params'
'etc/nginx/uwsgi_params'
'etc/nginx/win-utf'
'etc/logrotate.d/nginx')
install=nginx.install
provides=('nginx')
conflicts=('nginx' 'nginx-mainline')
validpgpkeys=('B0F4253373F8F6F510D42178520A9993A1C052F8') # Maxim Dounin <mdounin@mdounin.ru>
source=("${url}/download/${_pkgname}-${pkgver}.tar.gz"{,.asc}
"service"
"logrotate"
"ngx_davext-${_davext_ver}.tar.gz::https://github.com/arut/nginx-dav-ext-module/archive/v${_davext_ver}.tar.gz"
"ngx_fancyindex-${_fancyindex_ver}.tar.gz::https://github.com/aperezdc/ngx-fancyindex/archive/v${_fancyindex_ver}.tar.gz"
"ngx_headers_more-${_headers_more_ver}.tar.gz::https://github.com/openresty/headers-more-nginx-module/archive/v${_headers_more_ver}.tar.gz"
"ngx_nchan-${_nchan_ver}.tar.gz::https://github.com/slact/nchan/archive/v${_nchan_ver}.tar.gz"
"ngx_brotli::git+https://github.com/google/ngx_brotli#commit=${_brotli_commit}"
"boringssl::git+https://boringssl.googlesource.com/boringssl#commit=${_boringssl_commit}"
"zlib-ng::git+https://github.com/zlib-ng/zlib-ng#commit=${_zlibng_commit}")
sha256sums=('63ee35e15a75af028ffa1f995e2b9c120b59ef5f1b61a23b8a4c33c262fc10c3'
'SKIP'
'6985a7c271a64b9fce5fb24afc459399643a7abf5e7f1a1cc5043c4941443892'
'06ebe161af3e761f2e2e35a67c6c0af27bf61aea7cd4ba8b28372ced5e3b3175'
'd2499d94d82d4e4eac8425d799e52883131ae86a956524040ff2fd230ef9f859'
'81698fb0c1ec9f906ce308c055d5d248085caf390f4b92516c1ec93f87c886d4'
'a3dcbab117a9c103bc1ea5200fc00a7b7d2af97ff7fd525f16f8ac2632e30fbf'
'277f35e479f80f04f76b70549d0ec7abdf8f1658cf46538ea9b0adf3e8b1ad50'
'SKIP'
'SKIP'
'SKIP')
_common_flags=(
--with-compat
--with-file-aio
--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_degradation_module
--with-http_flv_module
--with-http_geoip_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-pcre-jit
--with-stream
--with-stream_geoip_module
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module
--with-threads
)
_mainline_flags=(
)
_module_flags=(
--add-module=../nginx-dav-ext-module-${_davext_ver}
--add-module=../ngx-fancyindex-${_fancyindex_ver}
--add-module=../headers-more-nginx-module-${_headers_more_ver}
--add-module=../nchan-${_nchan_ver}
--add-module=../ngx_brotli
)
prepare() {
# Safety first
for dir in "${_module_flags[@]}"; do
dir="${dir/--add-module\=..\/}"
test -d "${dir}" || {
echo ">>> Module directory '${dir}' does not exist!"
return 1
}
done
# Replace version string
sed -i '/^#define NGINX_VER/s|"nginx/"|"'${pkgname}'/"|' "${_pkgname}-${pkgver}/src/core/nginx.h"
}
build() {
msg2 "Building BoringSSL"
mkdir -p boringssl-build
pushd boringssl-build
cmake "${srcdir}/boringssl" -G "Unix Makefiles" -DBUILD_SHARED_LIBS=0
make
# Move BoringSSL files to proper place
mkdir -p .openssl/lib
cp crypto/libcrypto.a ssl/libssl.a .openssl/lib/
cp -r ../boringssl/include .openssl/
popd
msg2 "Building zlib-ng"
mkdir -p zlib-ng-build
pushd zlib-ng-build
cmake "${srcdir}/zlib-ng" -G "Unix Makefiles" -DZLIB_COMPAT=1
make
popd
msg2 "Building nginx"
cd "${_pkgname}-${pkgver}"
./configure \
--prefix=/etc/nginx \
--conf-path=/etc/nginx/nginx.conf \
--sbin-path=/usr/bin/nginx \
--pid-path=/run/nginx.pid \
--lock-path=/run/lock/nginx.lock \
--user=http \
--group=http \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=stderr \
--http-client-body-temp-path=/var/lib/nginx/client-body \
--http-proxy-temp-path=/var/lib/nginx/proxy \
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
--http-scgi-temp-path=/var/lib/nginx/scgi \
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
--with-cc-opt="${CFLAGS} ${CPPFLAGS}" \
--with-ld-opt="${LDFLAGS}" \
--with-openssl="$(realpath ../boringssl-build)" \
--with-zlib="$(realpath ../zlib-ng-build)" \
${_common_flags[@]} \
${_mainline_flags[@]} \
${_module_flags[@]}
# No idea why this is needed, but nginx build otherwise fails
touch ../boringssl-build/.openssl/include/openssl/ssl.h
touch ../zlib-ng-build/libz.a
make
}
package() {
cd "${_pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
sed -e 's|\<user\s\+\w\+;|user html;|g' \
-e '44s|html|/usr/share/nginx/html|' \
-e '54s|html|/usr/share/nginx/html|' \
-i "${pkgdir}"/etc/nginx/nginx.conf
rm "${pkgdir}"/etc/nginx/*.default
rm "${pkgdir}"/etc/nginx/mime.types # in mailcap
install -d "${pkgdir}"/var/lib/nginx
install -dm700 "${pkgdir}"/var/lib/nginx/proxy
chmod 755 "${pkgdir}"/var/log/nginx
chown root:root "${pkgdir}"/var/log/nginx
install -d "${pkgdir}"/usr/share/nginx
mv "${pkgdir}"/etc/nginx/html/ "${pkgdir}"/usr/share/nginx
install -Dm644 ../logrotate "${pkgdir}"/etc/logrotate.d/nginx
install -Dm644 ../service "${pkgdir}"/usr/lib/systemd/system/nginx.service
install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/${_pkgname}/LICENSE
rmdir "${pkgdir}"/run
install -d "${pkgdir}"/usr/share/man/man8/
gzip -9c man/nginx.8 > "${pkgdir}"/usr/share/man/man8/nginx.8.gz
for i in ftdetect indent syntax; do
install -Dm644 contrib/vim/$i/nginx.vim \
"${pkgdir}/usr/share/vim/vimfiles/$i/nginx.vim"
done
}