# Maintainer: psykose pkgname=nginx-current pkgver=1.23.3 pkgrel=0 pkgdesc="HTTP and reverse proxy server (current version)" url="https://www.nginx.org/" arch="all" license="BSD-2-Clause" depends="!nginx" makedepends=" brotli-dev clang file-dev gd-dev libxml2-dev libxslt-dev lld linux-headers openssl-dev>3 pcre2-dev perl-dev zeromq-dev zlib-dev " pkgusers="nginx" _grp_ngx="nginx" _grp_www="www-data" pkggroups="$_grp_ngx $_grp_www" install="$pkgname.pre-install $pkgname.post-install $pkgname.pre-upgrade $pkgname.post-upgrade" subpackages="$pkgname-doc $pkgname-openrc $pkgname-vim::noarch" source="https://nginx.org/download/nginx-$pkgver.tar.gz nginx.conf default.conf stream.conf nginx.logrotate nginx.initd nginx.confd " builddir="$srcdir/nginx-$pkgver" options="!check" # no time! export CC=clang export CFLAGS="$CFLAGS -flto=thin" # passed below export LDFLAGS="$LDFLAGS -flto=thin -fuse-ld=lld -Wl,--icf=safe,--gc-sections" _modules_dir="usr/lib/nginx/modules" # Built-in dynamic modules for _mod in \ stream do subpackages="$subpackages $pkgname-mod-$_mod:_module" done # Third-party dynamic modules # For simplicity we assume that module is hosted on GitHub. _add_module() { local name="$1" ver="$2" url="$3" subdir="$4" enabled="${5:-true}" local dirname=${url##*/}-${ver#v} local varprefix="_${name//-/_}" eval "${varprefix}_ver='$ver'; ${varprefix}_url='$url'" # Don't add new flag and source if it's already there, i.e. two or more # modules share the same source (e.g. geoip2 that provides http-geoip2 # and stream-geoip2). if ! printf '%s\n' $_extra_flags | grep -qFw "$srcdir/$dirname"; then source="$source $dirname.tar.gz::$url/archive/$ver.tar.gz" # $source must be always in-sync with $sha512sums, so we have to # add there source of a module that is disabled on the current arch. [ "$enabled" = false ] && return _extra_flags="$_extra_flags --add-dynamic-module=$srcdir/$dirname/$subdir" fi subpackages="$subpackages $pkgname-mod-$name:_module" } _add_module "http-mime-magic" "v0.1.0" "https://github.com/Yureien/nginx-mime-magic-module" _add_module "http-fancyindex" "v0.5.2" "https://github.com/aperezdc/ngx-fancyindex" build() { ./configure \ --prefix=/var/lib/nginx \ --sbin-path=/usr/sbin/nginx \ --modules-path=/$_modules_dir \ --conf-path=/etc/nginx/nginx.conf \ --pid-path=/run/nginx/nginx.pid \ --lock-path=/run/nginx/nginx.lock \ --http-client-body-temp-path=/var/lib/nginx/tmp/client_body \ --http-proxy-temp-path=/var/lib/nginx/tmp/proxy \ --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi \ --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi \ --http-scgi-temp-path=/var/lib/nginx/tmp/scgi \ --with-perl_modules_path=/usr/lib/perl5/vendor_perl \ \ --user=$pkgusers \ --group=$_grp_ngx \ --with-threads \ --with-file-aio \ --with-ld-opt="-lmagic $LDFLAGS" \ \ --with-http_ssl_module \ --with-http_v2_module \ --with-http_realip_module \ --with-http_addition_module \ --with-http_sub_module \ --with-http_flv_module \ --with-http_mp4_module \ --with-http_gunzip_module \ --with-http_gzip_static_module \ --with-http_auth_request_module \ --with-http_random_index_module \ --with-http_secure_link_module \ --with-http_degradation_module \ --with-http_slice_module \ --with-http_stub_status_module \ --with-mail_ssl_module \ --with-openssl-opt=enable-ktls \ --with-stream=dynamic \ --with-stream_ssl_module \ --with-stream_realip_module \ --with-stream_ssl_preread_module \ \ $_extra_flags make } package() { make DESTDIR="$pkgdir" install chown root:root "$pkgdir"/usr/sbin/nginx install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE install -Dm644 README "$pkgdir"/usr/share/doc/$pkgname/README install -Dm644 objs/nginx.8 "$pkgdir"/usr/share/man/man8/nginx.8 # local name; for name in ngx_devel_kit nginx-rtmp-module; do # cp -r "$srcdir"/$name-*/doc* "$pkgdir"/usr/share/doc/$pkgname/$name # done cd "$pkgdir" install -Dm644 "$srcdir"/nginx.conf ./etc/nginx/nginx.conf install -dm755 ./etc/nginx/http.d ./etc/nginx/modules install -Dm755 "$srcdir"/nginx.initd ./etc/init.d/nginx install -Dm644 "$srcdir"/nginx.confd ./etc/conf.d/nginx install -Dm644 "$srcdir"/nginx.logrotate ./etc/logrotate.d/nginx install -dm750 -o $pkgusers -g $_grp_ngx ./var/lib/nginx install -dm700 -o $pkgusers -g $_grp_ngx ./var/lib/nginx/tmp install -dm755 -g $_grp_www ./var/www/localhost/htdocs install -Dm644 "$srcdir"/default.conf ./usr/share/nginx/http-default_server.conf install -dm755 ./var/log mv ./var/lib/nginx/logs ./var/log/nginx chown $pkgusers:$_grp_ngx var/log/nginx ln -sf /$_modules_dir ./var/lib/nginx/modules ln -sf /var/log/nginx ./var/lib/nginx/logs ln -sf /run/nginx ./var/lib/nginx/run # Remove archaic charset maps. rm ./etc/nginx/koi-* ./etc/nginx/win-utf rm -rf ./run ./etc/nginx/*.default } vim() { pkgdesc="$pkgdesc (vim syntax)" install_if="vim $pkgname=$pkgver-r$pkgrel" depends= mkdir -p "$subpkgdir"/usr/share/vim cp -r "$builddir"/contrib/vim "$subpkgdir"/usr/share/vim/vimfiles } _module() { local name="${subpkgname#$pkgname-mod-}"; name="${name//-/_}" local ver=$(getvar _${name}_ver) pkgdesc="Nginx module ${name//_/-}" [ "$ver" ] && pkgdesc="Nginx third-party module ${name//_/-} (version $ver)" url=$(getvar "_${name}_url" "$url") sonames=$(getvar "_${name}_so" "ngx_${name}_module.so") depends="$pkgname $(getvar "_${name}_depends")" provides=$(getvar "_${name}_provides") # Numeric prefix for the module config to ensure that modules with # dependencies on other modules will be loaded after their dependencies. # For simplicity, we don't actually resolve dependency tree. Instead, # we just prefix the module name with a number that reflects number of # the module's dependencies times ten (e.g. 10, 20, 30, ...). local conf_prefix="$(echo "$depends" | wc -w)0_" mkdir -p "$subpkgdir"/$_modules_dir mkdir -p "$subpkgdir"/etc/nginx/modules cd "$subpkgdir" local soname; for soname in $sonames; do mv "$pkgdir"/$_modules_dir/$soname ./$_modules_dir/$soname echo "load_module \"modules/$soname\";" >> ./etc/nginx/modules/${conf_prefix}$name.conf done case "$name" in http_perl) mv "$pkgdir"/usr/lib/perl5 "$subpkgdir"/usr/lib/ ;; http_naxsi) install -m644 -D "$srcdir"/naxsi-*/naxsi_config/naxsi_core.rules \ ./etc/nginx/naxsi_core.rules ;; stream) mkdir -p ./etc/nginx/stream.d install -m644 "$srcdir"/stream.conf ./etc/nginx/stream.conf ;; esac } # Print value of the specified variable, or the default if empty or not defined. getvar() { eval "printf '%s\n' \"\${$1:-$2}\"" } sha512sums=" da5f473ac213f8947f40f0a69820bf981157432fe9d29cf71fe30225dadd05f5814309034f0411ea15fb70bece8ceefc0cb0b2588096c1a9496c2a36fa425d9f nginx-1.23.3.tar.gz 9c5ee975dffa15b76688ef798371635f38f1e6773b143c738add26297878dddfc20ebf276e3871a60f28b197e8a70496ca17d4816c2136171978c157bb8e591f nginx.conf 0907f69dc2d3dc1bad3a04fb6673f741f1a8be964e22b306ef9ae2f8e736e1f5733a8884bfe54f3553fff5132a0e5336716250f54272c3fec2177d6ba16986f3 default.conf f3321a45736697009817db335ad36d3f1d05f60d98ac90a943220cdd4c00c52632f018db6a6076d5431a483525aacc5725b87b765b590e2f63b3ef98c5b16bd8 stream.conf 09b110693e3f4377349ccea3c43cb8199c8579ee351eae34283299be99fdf764b0c1bddd552e13e4d671b194501618b29c822e1ad53b34101a73a63954363dbb nginx.logrotate ee10a5687740dde0c3d18d8b3555f49fcdc6abfc0a3bc2de1de3be0e99951a346fe8027d916aab73071ecd4e2c50871e7c867aca3a7a0fd16e3374c5caed1c57 nginx.initd 0b9b9ed01ac077e334c034faa2679f6e26740fb3362eebf8cef82d22b2af2a3faaa53bae3c9e14af51cbf64720a7c66431905ca5cc43f978366456cc4e3b7f4a nginx.confd 68e5507c65abff2a199929db0a45a46a736bd903adebb411bcf32ec22c83cfd24ccd047635e1901ff50abdd1de22a7a1d0bb4f4f4205c6a710e238e8ef3199ee nginx-mime-magic-module-0.1.0.tar.gz c208cdf3e245527d7b313f9ef1f5d36ca26e3bdafe67df56492a13b7726587538665e5d9fd50f295fc933f218dc33394f2fe442713d15631701dbfc4a156799b ngx-fancyindex-0.5.2.tar.gz "