ahmubashshir / pkgbuilds

PKGBUILDs maintained by me
The Unlicense
3 stars 3 forks source link

nginx-mainline-mod-lua build failed caused by quote marks in `nginx -V` #8

Closed TerryGeng closed 1 year ago

TerryGeng commented 1 year ago

My nginx -V outputs

nginx version: nginx/1.25.0
built with OpenSSL 3.0.8 7 Feb 2023
TLS SNI support enabled
configure arguments: --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='-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -g -ffile-prefix-map=/build/nginx-mainline/src=/usr/src/debug/nginx-mainline -flto=auto' --with-ld-opt='-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto' --with-compat --with-debug --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-http_v3_module --with-mail --with-mail_ssl_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

Apparently, the quote marks in --with-cc-opt get stripped when going through the printf line in https://github.com/ahmubashshir/pkgbuilds/blob/7b6b4e024ca1a04825e5ce7e023d9a9ac4d23c0c/nginx-mainline-mod-lua/PKGBUILD#L37-L42 and confused nginx/configure.

A quick workaround is to change this block to

    nginx -V 2>&1 |
        grep -o -- '--prefix=.*$' |
        sed '/--with-ld-opt=/{s/-Wl,/\0-E,/;s/-Wl,/-lpcre \0/}' |
        xargs /usr/src/nginx/configure \
            --add-dynamic-module=../$_modname-nginx-module-$pkgver
ahmubashshir commented 1 year ago

Can you try this patch?

diff --git a/nginx-mainline-mod-lua/PKGBUILD b/nginx-mainline-mod-lua/PKGBUILD
index 9152885..0327488 100644
--- a/nginx-mainline-mod-lua/PKGBUILD
+++ b/nginx-mainline-mod-lua/PKGBUILD
@@ -36,9 +36,9 @@ build() {
    export LUAJIT_LIB=$(pkg-config luajit --variable=libdir)
    nginx -V 2>&1 |
        grep -o -- '--prefix=.*$' |
-       xargs printf '%s\n' |
-       sed '/^--with-ld-opt=/{s/-Wl,/\0-E,/;s/-Wl,/-lpcre \0/}' |
-       xargs /usr/src/nginx/configure \
+       xargs printf '%s\0' |
+       sed -z '/^--with-ld-opt=/{s/-Wl,/\0-E,/;s/-Wl,/-lpcre \0/}' |
+       xargs -0 /usr/src/nginx/configure \
            --add-dynamic-module=../$_modname-nginx-module-$pkgver
    make modules
 }
TerryGeng commented 1 year ago

Yes, it works!

TerryGeng commented 1 year ago

The regex in https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=nginx-mainline-mod-http-xslt-filter also works:

sed -nE 's/^configure arguments: ([^\n]*)$/\1/p' |
sed -nE 's/([^'"'"' \t\n]+('"'"'([^'"'"'\]|\\'"'"'?)*'"'"'|"([^"\\]|\\"?)*")?) ?/\1\n/gp')