Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] [RFC] [WIP] use bash arrays for some template fields
@ 2023-03-08  9:48 classabbyamp
  2023-03-08 10:00 ` tranzystorek-io
                   ` (33 more replies)
  0 siblings, 34 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-08  9:48 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]

There is a new pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking.

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 25274 bytes --]

From 6913c072e5720835878acb3d8d30969f5c8e0d41 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:26:21 -0500
Subject: [PATCH 1/5] common/xbps-src/shutils/common.sh: add function for
 str->array

this will allow select variables to be defined as arrays or strings. if
a string is specified, it will be converted to an array for internal
usage. if it is an array, it passes through untouched. this should
allow for a smooth transition to using more arrays inside xbps-src,
and should solve issues with shell quoting in things like configure_args,
make_check_args, etc.
---
 common/xbps-src/shutils/common.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index fdc0c5eedd92..b311214e036a 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -250,6 +250,19 @@ source_file() {
     fi
 }
 
+into_array() {
+    for array_name; do
+        local declaration="$(declare -p "$array_name" 2> /dev/null)"
+        if [ -z "$declaration" ]; then
+            eval "$array_name=()"
+        elif ! $(echo $declaration | grep -q '^declare -a'); then
+            local existing_val="$(eval echo "\${$array_name}" | sed -e 's,^[[:space:]]*,,' -e 's,[[:space:]]*$,,')"
+            unset "${array_name?}"
+            IFS=" " read -r -a "${array_name?}" <<< "${existing_val}"
+        fi
+    done
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 
@@ -530,6 +543,8 @@ setup_pkg() {
 
     set_build_options
 
+    into_array configure_args
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"

From 4645a07acdb3e5d4e51e2728dd4fb5310a7dfc2c Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:03 -0500
Subject: [PATCH 2/5] common/xbps-src/shutils/show.sh: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 87 ++++++++++++++++++++++-----------
 1 file changed, 59 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df..0238a5534f13 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var 0 "pkgname" "$pkgname"
+    show_pkg_var 0 "version" "$version"
+    show_pkg_var 0 "revision" "$revision"
+    show_pkg_var 1 "distfiles" "$distfiles"
+    show_pkg_var 1 "checksum" "$checksum"
+    show_pkg_var 1 "archs" "$archs"
+    show_pkg_var 0 "maintainer" "${maintainer}"
+    show_pkg_var 0 "Upstream URL" "$homepage"
+    show_pkg_var 1 "License(s)" "${license//,/ }"
+    show_pkg_var 0 "Changelog" "$changelog"
+    show_pkg_var 0 "build_style" "$build_style"
+    show_pkg_var 1 "build_helper" "$build_helper"
+    show_pkg_var 2 "configure_args" "${configure_args[@]}"
+    show_pkg_var 0 "short_desc" "$short_desc"
+    show_pkg_var 1 "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var 1 "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var 1 "replaces" "$replaces"
+    show_pkg_var 1 "provides" "$provides"
+    show_pkg_var 1 "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var 0 "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var 1 "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,57 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1" # 0 = no, 1 = always, 2 = array
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        if [ "$_split" -eq 2 ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        elif [ "$_split" -eq 1 ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From 4030691f615f21930c65b5e35ac95773d32d0361 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:56 -0500
Subject: [PATCH 3/5] common/build-style/: convert configure-args to array

---
 common/build-style/cargo.sh            | 6 +++---
 common/build-style/cmake.sh            | 4 ++--
 common/build-style/configure.sh        | 2 +-
 common/build-style/gemspec.sh          | 2 +-
 common/build-style/gnu-configure.sh    | 2 +-
 common/build-style/meson.sh            | 4 ++--
 common/build-style/perl-ModuleBuild.sh | 2 +-
 common/build-style/perl-module.sh      | 2 +-
 common/build-style/qmake.sh            | 4 ++--
 common/build-style/sip-build.sh        | 2 +-
 common/build-style/void-cross.sh       | 4 ++--
 common/build-style/waf.sh              | 2 +-
 common/build-style/waf3.sh             | 2 +-
 common/build-style/zig-build.sh        | 2 +-
 14 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 387e711060bc..8c21f9c20445 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,13 +5,13 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} ${configure_args} \
+	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} "${configure_args[@]}" \
 		${make_check_args}
 }
 
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 43750ad20dcd..92032b7a8b09 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -74,7 +74,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e..9b472ca28ccc 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45..0ed948dbff0e 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f7..b89008875a89 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index e983c5f42c2f..2f97671388ff 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -91,7 +91,7 @@ do_configure() {
 	: ${meson_crossfile:=xbps_meson.cross}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -122,7 +122,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4c..5efa8484068e 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe1..2bcfda743083 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606e..1f79fd42d55c 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf..42b5b2bff191 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index 02bd1f555741..aae5db2b7355 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -438,7 +438,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b17..2b3b6eb03c9d 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7..455b043ebfa3 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f..e2d02fb11b7f 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {

From 62462b53d16dc286c949936bc246d2987f45e75d Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:33:30 -0500
Subject: [PATCH 4/5] common/environment/configure/gnu-configure-args.sh:
 configure_args->array

---
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index dafbf5dc110c..60946b0439b3 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).

From b98845350065c42910e07c9022fc9ff77565e136 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:45:40 -0500
Subject: [PATCH 5/5] srcpkgs/: fix configure_args

---
 srcpkgs/backintime/template          |  4 ++--
 srcpkgs/coreutils/template           |  8 ++++----
 srcpkgs/emacs/template               |  6 +++---
 srcpkgs/ndpi/template                |  2 +-
 srcpkgs/net-snmp/template            | 12 ++++++------
 srcpkgs/nx-libs/template             |  4 ++--
 srcpkgs/openjdk15-bootstrap/template | 11 +++++------
 srcpkgs/xen/template                 |  2 +-
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/backintime/template b/srcpkgs/backintime/template
index 2d8c9328216f..b0110046f42c 100644
--- a/srcpkgs/backintime/template
+++ b/srcpkgs/backintime/template
@@ -16,9 +16,9 @@ python_version=3
 
 do_configure() {
 	cd $wrksrc/common
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 	cd $wrksrc/qt
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/coreutils/template b/srcpkgs/coreutils/template
index b9148c854960..6964a3b748a1 100644
--- a/srcpkgs/coreutils/template
+++ b/srcpkgs/coreutils/template
@@ -49,19 +49,19 @@ pre_configure() {
 
 do_configure() {
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" fu_cv_sys_stat_statfs2_bsize=no
+		configure_args+=(fu_cv_sys_stat_statfs2_bsize=no
 			gl_cv_func_working_mkstemp=yes
-			gl_cv_func_working_acl_get_file=yes "
+			gl_cv_func_working_acl_get_file=yes)
 	fi
 	case "$XBPS_TARGET_MACHINE" in
 		# XXX syncfs() in src/sync.c expects a return value.
-		*-musl) configure_args+=" ac_cv_func_syncfs=no";;
+		*-musl) configure_args+=(ac_cv_func_syncfs=no);;
 	esac
 	#
 	# Do not install kill: provided by util-linux.
 	# Do not install uptime: provided by procps-ng.
 	#
-	env $_force_unsafe_configure ./configure ${configure_args} \
+	env $_force_unsafe_configure ./configure "${configure_args[@]}" \
 		--enable-install-program=arch,hostname \
 		--enable-no-install-program=kill,uptime \
 		--disable-rpath
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 1e74ec047dac..796d787225a6 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -59,16 +59,16 @@ post_extract() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args} \
+	./configure --without-x $(vopt_with dbus) "${configure_args[@]}" \
 		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
 		$(vopt_with dbus) --without-gconf --without-gsettings \
-		${configure_args}
+		"${configure_args[@]}"
 
 	cd $wrksrc/gtk3
-	./configure --with-x-toolkit=gtk3 --with-xwidgets ${configure_args}
+	./configure --with-x-toolkit=gtk3 --with-xwidgets "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/ndpi/template b/srcpkgs/ndpi/template
index 4fdef1b182e9..bcd50cc81954 100644
--- a/srcpkgs/ndpi/template
+++ b/srcpkgs/ndpi/template
@@ -13,7 +13,7 @@ distfiles="https://github.com/ntop/nDPI/archive/${version}.tar.gz"
 checksum=dc9b291c7fde94edb45fb0f222e0d93c93f8d6d37f4efba20ebd9c655bfcedf9
 
 do_configure() {
-	./autogen.sh ${configure_args}
+	./autogen.sh ${configure_args[@]}
 }
 
 do_check() {
diff --git a/srcpkgs/net-snmp/template b/srcpkgs/net-snmp/template
index af0d79685f15..6eed952b84d0 100644
--- a/srcpkgs/net-snmp/template
+++ b/srcpkgs/net-snmp/template
@@ -2,6 +2,11 @@
 pkgname=net-snmp
 version=5.9.1
 revision=3
+configure_args=(--enable-ucd-snmp-compatibility --enable-ipv6
+ --with-default-snmp-version="3" --with-sys-contact="root@localhost"
+ --with-sys-location="Unknown" --with-logfile=/var/log/snmpd.log
+ --sbindir=/usr/bin --with-persistent-directory=/var/net-snmp --disable-static
+ --with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib")
 hostmakedepends="pkg-config unzip"
 makedepends="bzip2-devel openssl-devel libnl-devel pciutils-devel
  libsensors-devel pcre-devel"
@@ -20,12 +25,7 @@ do_configure() {
 	# lack magic words.
 	export GREP='grep -a'
 
-	./configure ${configure_args} --enable-ucd-snmp-compatibility \
-		--enable-ipv6 --with-default-snmp-version="3" \
-		--with-sys-contact="root@localhost" --with-sys-location="Unknown" \
-		--with-logfile=/var/log/snmpd.log --sbindir=/usr/bin \
-		--with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib" \
-		--with-persistent-directory=/var/net-snmp --disable-static
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/nx-libs/template b/srcpkgs/nx-libs/template
index f604983c82c9..18c83aed0016 100644
--- a/srcpkgs/nx-libs/template
+++ b/srcpkgs/nx-libs/template
@@ -42,11 +42,11 @@ do_configure() {
 	# Configure all subprojects in advance of build
 	local _subdir
 	for _subdir in nxcomp nxcompshad nxproxy nxdialog; do
-		( cd ${_subdir} && ./configure ${configure_args} )
+		( cd ${_subdir} && ./configure "${configure_args[@]}" )
 	done
 
 	# nx-X11 configure has an extra argument
-	( cd nx-X11/lib && ./configure ${configure_args} --disable-poll )
+	( cd nx-X11/lib && ./configure "${configure_args[@]}" --disable-poll )
 }
 
 post_install() {
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index a3b515b98a96..430cf43eb215 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -61,14 +61,14 @@ esac
 
 if [ -n "$_use_zero" ]; then
 	makedepends+=" libffi-devel"
-	configure_args+=" --with-jvm-variants=zero"
+	configure_args+=("--with-jvm-variants=zero")
 	case "$XBPS_TARGET_MACHINE" in
-		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+		ppc*) configure_args+=("--with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560");;
 	esac
 fi
 
 if [ -n "$XBPS_DEBUG_PKGS" ]; then
-	configure_args+=" --with-native-debug-symbols=internal"
+	configure_args+=("--with-native-debug-symbols=internal")
 fi
 
 post_extract() {
@@ -100,13 +100,12 @@ do_configure() {
 			;;
 	esac
 
-	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
 	if [ "$XBPS_CCACHE" ]; then
-		configure_args+=" --enable-ccache"
+		configure_args+=(--enable-ccache)
 	fi
 	CC="/usr/bin/cc"
 	CXX="/usr/bin/c++"
-	./configure ${configure_args} \
+	./configure "${configure_args[@]/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}" \
 		--with-extra-cflags="$CFLAGS" \
 		--with-extra-cxxflags="$CXXFLAGS" \
 		--with-extra-ldflags="$LDFLAGS" \
diff --git a/srcpkgs/xen/template b/srcpkgs/xen/template
index 160db8e65929..dde7b0aa5df3 100644
--- a/srcpkgs/xen/template
+++ b/srcpkgs/xen/template
@@ -146,7 +146,7 @@ do_configure() {
 	cp -a ${FILESDIR}/stdint_local.h ${wrksrc}/tools/libxl/
 	rm -f ${XBPS_WRAPPERDIR}/strip
 	./autogen.sh
-	./configure ${configure_args}
+	./configure ${configure_args[@]}
 }
 
 do_build() {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
@ 2023-03-08 10:00 ` tranzystorek-io
  2023-03-08 10:03 ` tranzystorek-io
                   ` (32 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tranzystorek-io @ 2023-03-08 10:00 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 391 bytes --]

New comment by tranzystorek-io on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459916702

Comment:
`*depends` variables also seem like a good pick for this.

If possible, it would be nice if we could make this optional, i.e. still parse variables the old way, but if we detect an array, we skip the conversion step and just take it as-is.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
  2023-03-08 10:00 ` tranzystorek-io
@ 2023-03-08 10:03 ` tranzystorek-io
  2023-03-08 10:09 ` tranzystorek-io
                   ` (31 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tranzystorek-io @ 2023-03-08 10:03 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 484 bytes --]

New comment by tranzystorek-io on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459916702

Comment:
`*depends` variables also seem like a good pick for this.

~~If possible, it would be nice if we could make this optional, i.e. still parse variables the old way, but if we detect an array, we skip the conversion step and just take it as-is.~~

EDIT: sorry I skimmed through the part where you already say it's optional by design.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
  2023-03-08 10:00 ` tranzystorek-io
  2023-03-08 10:03 ` tranzystorek-io
@ 2023-03-08 10:09 ` tranzystorek-io
  2023-03-08 10:11 ` classabbyamp
                   ` (30 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tranzystorek-io @ 2023-03-08 10:09 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 660 bytes --]

New comment by tranzystorek-io on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459916702

Comment:
`*depends` variables also seem like a good pick for this.

I haven't checked if there's any convenient mechanism for concatenating arrays, which would be nice in python packages as an alternative to `checkdepends="${depends} ..."`.

~~If possible, it would be nice if we could make this optional, i.e. still parse variables the old way, but if we detect an array, we skip the conversion step and just take it as-is.~~

EDIT: sorry I skimmed through the part where you already say it's optional by design.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (2 preceding siblings ...)
  2023-03-08 10:09 ` tranzystorek-io
@ 2023-03-08 10:11 ` classabbyamp
  2023-03-08 10:12 ` classabbyamp
                   ` (29 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-08 10:11 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459930695

Comment:
> I haven't checked if there's any convenient mechanism for concatenating arrays

```bash
$ foo=(foo bar baz)
$ bar=("${foo[@]}" idk)
$ declare -p foo
declare -a foo=([0]="foo" [1]="bar" [2]="baz")
$ declare -p bar
declare -a bar=([0]="foo" [1]="bar" [2]="baz" [3]="idk")
```

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (3 preceding siblings ...)
  2023-03-08 10:11 ` classabbyamp
@ 2023-03-08 10:12 ` classabbyamp
  2023-03-08 10:17 ` tranzystorek-io
                   ` (28 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-08 10:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459930695

Comment:
> I haven't checked if there's any convenient mechanism for concatenating arrays

for the same array, just `foo+=(new_element)`, for different:
```bash
$ foo=(foo bar baz)
$ bar=("${foo[@]}" idk)
$ declare -p foo
declare -a foo=([0]="foo" [1]="bar" [2]="baz")
$ declare -p bar
declare -a bar=([0]="foo" [1]="bar" [2]="baz" [3]="idk")
```

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (4 preceding siblings ...)
  2023-03-08 10:12 ` classabbyamp
@ 2023-03-08 10:17 ` tranzystorek-io
  2023-03-08 11:41 ` [PR REVIEW] " ahesford
                   ` (27 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: tranzystorek-io @ 2023-03-08 10:17 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 628 bytes --]

New comment by tranzystorek-io on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1459937395

Comment:
> > I haven't checked if there's any convenient mechanism for concatenating arrays
> 
> for the same array, just `foo+=(new_element)`, for different:
> 
> ```shell
> $ foo=(foo bar baz)
> $ bar=("${foo[@]}" idk)
> $ declare -p foo
> declare -a foo=([0]="foo" [1]="bar" [2]="baz")
> $ declare -p bar
> declare -a bar=([0]="foo" [1]="bar" [2]="baz" [3]="idk")
> ```

Hm, for me the added explicitness of `"${foo[@]}"` is a plus, but probably not everyone would agree.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR REVIEW] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (5 preceding siblings ...)
  2023-03-08 10:17 ` tranzystorek-io
@ 2023-03-08 11:41 ` ahesford
  2023-03-08 12:26 ` leahneukirchen
                   ` (26 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: ahesford @ 2023-03-08 11:41 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

New review comment by ahesford on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#discussion_r1129279782

Comment:
Compare this with the much simpler implementation at https://github.com/archlinux/mkinitcpio/blob/master/functions#L299

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR REVIEW] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (6 preceding siblings ...)
  2023-03-08 11:41 ` [PR REVIEW] " ahesford
@ 2023-03-08 12:26 ` leahneukirchen
  2023-03-08 18:02 ` paper42
                   ` (25 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: leahneukirchen @ 2023-03-08 12:26 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 226 bytes --]

New review comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#discussion_r1129350772

Comment:
That `@a` trick is good, else one also could use `case` with a pattern.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (7 preceding siblings ...)
  2023-03-08 12:26 ` leahneukirchen
@ 2023-03-08 18:02 ` paper42
  2023-03-08 18:12 ` classabbyamp
                   ` (24 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: paper42 @ 2023-03-08 18:02 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 755 bytes --]

New comment by paper42 on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1460610011

Comment:
this might be for another issue/PR, but we might also want to consider using associative arrays for build_options like this:
```
declare -A buildopts=([docs]=0 [wayland]=1 [xorg]=1)
```
if this was declared before buildopts are used (= usually before configure_args), we could parse the template only once instead of twice if we also used functions for accessing build options instead of variables like currently (because buildopts has to be combined with options from cli args and the config). The only disadvantage I can think of is that it would be ugly to have declare -A right at the top of the template.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (8 preceding siblings ...)
  2023-03-08 18:02 ` paper42
@ 2023-03-08 18:12 ` classabbyamp
  2023-03-09  5:43 ` [PR REVIEW] " classabbyamp
                   ` (23 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-08 18:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1460626912

Comment:
I think that should be out of scope for this PR, but it may be useful to do

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR REVIEW] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (9 preceding siblings ...)
  2023-03-08 18:12 ` classabbyamp
@ 2023-03-09  5:43 ` classabbyamp
  2023-03-09  5:44 ` [PR PATCH] [Updated] " classabbyamp
                   ` (22 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09  5:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 261 bytes --]

New review comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#discussion_r1130503857

Comment:
bash never fails to surprise me with weird features like this. I've simplified my implementation to use this

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (10 preceding siblings ...)
  2023-03-09  5:43 ` [PR REVIEW] " classabbyamp
@ 2023-03-09  5:44 ` classabbyamp
  2023-03-09  5:45 ` classabbyamp
                   ` (21 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09  5:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 25122 bytes --]

From 15df45a1a8bbf47b7e37ff2706f4ff1aae1b0748 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:26:21 -0500
Subject: [PATCH 1/5] common/xbps-src/shutils/common.sh: add function for
 str->array

this will allow select variables to be defined as arrays or strings. if
a string is specified, it will be converted to an array for internal
usage. if it is an array, it passes through untouched. this should
allow for a smooth transition to using more arrays inside xbps-src,
and should solve issues with shell quoting in things like configure_args,
make_check_args, etc.
---
 common/xbps-src/shutils/common.sh | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index fdc0c5eedd92..b83669db2dd7 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -250,6 +250,17 @@ source_file() {
     fi
 }
 
+arrayise() {
+    for name; do
+        if [[ -n "$name" && "$(eval echo \${$name@a})" != *a* ]]; then
+            IFS=" " read -r -a "${name}" <<< "$(eval echo "\${$name}")"
+            if [ "$(eval echo \${#$name})" -gt 1 ]; then
+                msg_error "template variable '$name' should be an array!\n"
+            fi
+        fi
+    done
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 
@@ -530,6 +541,8 @@ setup_pkg() {
 
     set_build_options
 
+    arrayise configure_args
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"

From 4b0f80ba56a14a1cfa858e18fa22e186773cdc2d Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:03 -0500
Subject: [PATCH 2/5] common/xbps-src/shutils/show.sh: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 87 ++++++++++++++++++++++-----------
 1 file changed, 59 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df..0238a5534f13 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var 0 "pkgname" "$pkgname"
+    show_pkg_var 0 "version" "$version"
+    show_pkg_var 0 "revision" "$revision"
+    show_pkg_var 1 "distfiles" "$distfiles"
+    show_pkg_var 1 "checksum" "$checksum"
+    show_pkg_var 1 "archs" "$archs"
+    show_pkg_var 0 "maintainer" "${maintainer}"
+    show_pkg_var 0 "Upstream URL" "$homepage"
+    show_pkg_var 1 "License(s)" "${license//,/ }"
+    show_pkg_var 0 "Changelog" "$changelog"
+    show_pkg_var 0 "build_style" "$build_style"
+    show_pkg_var 1 "build_helper" "$build_helper"
+    show_pkg_var 2 "configure_args" "${configure_args[@]}"
+    show_pkg_var 0 "short_desc" "$short_desc"
+    show_pkg_var 1 "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var 1 "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var 1 "replaces" "$replaces"
+    show_pkg_var 1 "provides" "$provides"
+    show_pkg_var 1 "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var 0 "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var 1 "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,57 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1" # 0 = no, 1 = always, 2 = array
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        if [ "$_split" -eq 2 ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        elif [ "$_split" -eq 1 ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From e1c75c4fc74866c09f3f933741f65a8820e50e1e Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:56 -0500
Subject: [PATCH 3/5] common/build-style/: convert configure-args to array

---
 common/build-style/cargo.sh            | 6 +++---
 common/build-style/cmake.sh            | 4 ++--
 common/build-style/configure.sh        | 2 +-
 common/build-style/gemspec.sh          | 2 +-
 common/build-style/gnu-configure.sh    | 2 +-
 common/build-style/meson.sh            | 4 ++--
 common/build-style/perl-ModuleBuild.sh | 2 +-
 common/build-style/perl-module.sh      | 2 +-
 common/build-style/qmake.sh            | 4 ++--
 common/build-style/sip-build.sh        | 2 +-
 common/build-style/void-cross.sh       | 4 ++--
 common/build-style/waf.sh              | 2 +-
 common/build-style/waf3.sh             | 2 +-
 common/build-style/zig-build.sh        | 2 +-
 14 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 387e711060bc..8c21f9c20445 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,13 +5,13 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} ${configure_args} \
+	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} "${configure_args[@]}" \
 		${make_check_args}
 }
 
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 43750ad20dcd..92032b7a8b09 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -74,7 +74,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e..9b472ca28ccc 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45..0ed948dbff0e 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f7..b89008875a89 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index e983c5f42c2f..2f97671388ff 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -91,7 +91,7 @@ do_configure() {
 	: ${meson_crossfile:=xbps_meson.cross}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -122,7 +122,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4c..5efa8484068e 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe1..2bcfda743083 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606e..1f79fd42d55c 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf..42b5b2bff191 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index 02bd1f555741..aae5db2b7355 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -438,7 +438,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b17..2b3b6eb03c9d 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7..455b043ebfa3 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f..e2d02fb11b7f 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {

From 3c13a87388052f3db4e6c89222db2c080263f866 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:33:30 -0500
Subject: [PATCH 4/5] common/environment/configure/gnu-configure-args.sh:
 configure_args->array

---
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index dafbf5dc110c..60946b0439b3 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).

From 9f10439c48f84647c6be0e0add262fbbade751a1 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:45:40 -0500
Subject: [PATCH 5/5] srcpkgs/: fix configure_args

---
 srcpkgs/backintime/template          |  4 ++--
 srcpkgs/coreutils/template           |  8 ++++----
 srcpkgs/emacs/template               |  6 +++---
 srcpkgs/ndpi/template                |  2 +-
 srcpkgs/net-snmp/template            | 12 ++++++------
 srcpkgs/nx-libs/template             |  4 ++--
 srcpkgs/openjdk15-bootstrap/template | 11 +++++------
 srcpkgs/xen/template                 |  2 +-
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/backintime/template b/srcpkgs/backintime/template
index 2d8c9328216f..b0110046f42c 100644
--- a/srcpkgs/backintime/template
+++ b/srcpkgs/backintime/template
@@ -16,9 +16,9 @@ python_version=3
 
 do_configure() {
 	cd $wrksrc/common
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 	cd $wrksrc/qt
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/coreutils/template b/srcpkgs/coreutils/template
index b9148c854960..6964a3b748a1 100644
--- a/srcpkgs/coreutils/template
+++ b/srcpkgs/coreutils/template
@@ -49,19 +49,19 @@ pre_configure() {
 
 do_configure() {
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" fu_cv_sys_stat_statfs2_bsize=no
+		configure_args+=(fu_cv_sys_stat_statfs2_bsize=no
 			gl_cv_func_working_mkstemp=yes
-			gl_cv_func_working_acl_get_file=yes "
+			gl_cv_func_working_acl_get_file=yes)
 	fi
 	case "$XBPS_TARGET_MACHINE" in
 		# XXX syncfs() in src/sync.c expects a return value.
-		*-musl) configure_args+=" ac_cv_func_syncfs=no";;
+		*-musl) configure_args+=(ac_cv_func_syncfs=no);;
 	esac
 	#
 	# Do not install kill: provided by util-linux.
 	# Do not install uptime: provided by procps-ng.
 	#
-	env $_force_unsafe_configure ./configure ${configure_args} \
+	env $_force_unsafe_configure ./configure "${configure_args[@]}" \
 		--enable-install-program=arch,hostname \
 		--enable-no-install-program=kill,uptime \
 		--disable-rpath
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 1e74ec047dac..796d787225a6 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -59,16 +59,16 @@ post_extract() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args} \
+	./configure --without-x $(vopt_with dbus) "${configure_args[@]}" \
 		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
 		$(vopt_with dbus) --without-gconf --without-gsettings \
-		${configure_args}
+		"${configure_args[@]}"
 
 	cd $wrksrc/gtk3
-	./configure --with-x-toolkit=gtk3 --with-xwidgets ${configure_args}
+	./configure --with-x-toolkit=gtk3 --with-xwidgets "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/ndpi/template b/srcpkgs/ndpi/template
index 4fdef1b182e9..bcd50cc81954 100644
--- a/srcpkgs/ndpi/template
+++ b/srcpkgs/ndpi/template
@@ -13,7 +13,7 @@ distfiles="https://github.com/ntop/nDPI/archive/${version}.tar.gz"
 checksum=dc9b291c7fde94edb45fb0f222e0d93c93f8d6d37f4efba20ebd9c655bfcedf9
 
 do_configure() {
-	./autogen.sh ${configure_args}
+	./autogen.sh ${configure_args[@]}
 }
 
 do_check() {
diff --git a/srcpkgs/net-snmp/template b/srcpkgs/net-snmp/template
index af0d79685f15..6eed952b84d0 100644
--- a/srcpkgs/net-snmp/template
+++ b/srcpkgs/net-snmp/template
@@ -2,6 +2,11 @@
 pkgname=net-snmp
 version=5.9.1
 revision=3
+configure_args=(--enable-ucd-snmp-compatibility --enable-ipv6
+ --with-default-snmp-version="3" --with-sys-contact="root@localhost"
+ --with-sys-location="Unknown" --with-logfile=/var/log/snmpd.log
+ --sbindir=/usr/bin --with-persistent-directory=/var/net-snmp --disable-static
+ --with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib")
 hostmakedepends="pkg-config unzip"
 makedepends="bzip2-devel openssl-devel libnl-devel pciutils-devel
  libsensors-devel pcre-devel"
@@ -20,12 +25,7 @@ do_configure() {
 	# lack magic words.
 	export GREP='grep -a'
 
-	./configure ${configure_args} --enable-ucd-snmp-compatibility \
-		--enable-ipv6 --with-default-snmp-version="3" \
-		--with-sys-contact="root@localhost" --with-sys-location="Unknown" \
-		--with-logfile=/var/log/snmpd.log --sbindir=/usr/bin \
-		--with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib" \
-		--with-persistent-directory=/var/net-snmp --disable-static
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/nx-libs/template b/srcpkgs/nx-libs/template
index f604983c82c9..18c83aed0016 100644
--- a/srcpkgs/nx-libs/template
+++ b/srcpkgs/nx-libs/template
@@ -42,11 +42,11 @@ do_configure() {
 	# Configure all subprojects in advance of build
 	local _subdir
 	for _subdir in nxcomp nxcompshad nxproxy nxdialog; do
-		( cd ${_subdir} && ./configure ${configure_args} )
+		( cd ${_subdir} && ./configure "${configure_args[@]}" )
 	done
 
 	# nx-X11 configure has an extra argument
-	( cd nx-X11/lib && ./configure ${configure_args} --disable-poll )
+	( cd nx-X11/lib && ./configure "${configure_args[@]}" --disable-poll )
 }
 
 post_install() {
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index a3b515b98a96..430cf43eb215 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -61,14 +61,14 @@ esac
 
 if [ -n "$_use_zero" ]; then
 	makedepends+=" libffi-devel"
-	configure_args+=" --with-jvm-variants=zero"
+	configure_args+=("--with-jvm-variants=zero")
 	case "$XBPS_TARGET_MACHINE" in
-		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+		ppc*) configure_args+=("--with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560");;
 	esac
 fi
 
 if [ -n "$XBPS_DEBUG_PKGS" ]; then
-	configure_args+=" --with-native-debug-symbols=internal"
+	configure_args+=("--with-native-debug-symbols=internal")
 fi
 
 post_extract() {
@@ -100,13 +100,12 @@ do_configure() {
 			;;
 	esac
 
-	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
 	if [ "$XBPS_CCACHE" ]; then
-		configure_args+=" --enable-ccache"
+		configure_args+=(--enable-ccache)
 	fi
 	CC="/usr/bin/cc"
 	CXX="/usr/bin/c++"
-	./configure ${configure_args} \
+	./configure "${configure_args[@]/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}" \
 		--with-extra-cflags="$CFLAGS" \
 		--with-extra-cxxflags="$CXXFLAGS" \
 		--with-extra-ldflags="$LDFLAGS" \
diff --git a/srcpkgs/xen/template b/srcpkgs/xen/template
index 160db8e65929..dde7b0aa5df3 100644
--- a/srcpkgs/xen/template
+++ b/srcpkgs/xen/template
@@ -146,7 +146,7 @@ do_configure() {
 	cp -a ${FILESDIR}/stdint_local.h ${wrksrc}/tools/libxl/
 	rm -f ${XBPS_WRAPPERDIR}/strip
 	./autogen.sh
-	./configure ${configure_args}
+	./configure ${configure_args[@]}
 }
 
 do_build() {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (11 preceding siblings ...)
  2023-03-09  5:44 ` [PR PATCH] [Updated] " classabbyamp
@ 2023-03-09  5:45 ` classabbyamp
  2023-03-09 12:40 ` [PR REVIEW] " leahneukirchen
                   ` (20 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09  5:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 491 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1461323647

Comment:
> We can do this by attrition, but relatively quickly, with a linter that fails if any of the should-be-arrays is a string that will split into an array with more than one element.

I like this, and I've done this in the array conversion function directly, instead of e.g. changing xlint. I feel that using xlint for that would just be a mess

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR REVIEW] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (12 preceding siblings ...)
  2023-03-09  5:45 ` classabbyamp
@ 2023-03-09 12:40 ` leahneukirchen
  2023-03-09 12:42 ` leahneukirchen
                   ` (19 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: leahneukirchen @ 2023-03-09 12:40 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 193 bytes --]

New review comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#discussion_r1130971310

Comment:
Use `${!name@a}`, no eval echo needed.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR REVIEW] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (13 preceding siblings ...)
  2023-03-09 12:40 ` [PR REVIEW] " leahneukirchen
@ 2023-03-09 12:42 ` leahneukirchen
  2023-03-09 12:42 ` leahneukirchen
                   ` (18 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: leahneukirchen @ 2023-03-09 12:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 265 bytes --]

New review comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#discussion_r1130973206

Comment:
Here you need https://unix.stackexchange.com/questions/281390/how-to-get-the-size-of-an-indirect-array-in-bash

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (14 preceding siblings ...)
  2023-03-09 12:42 ` leahneukirchen
@ 2023-03-09 12:42 ` leahneukirchen
  2023-03-09 12:43 ` leahneukirchen
                   ` (17 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: leahneukirchen @ 2023-03-09 12:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 233 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1461990625

Comment:
I'm not a big fan of these 0,1,2 parameter... could we use `str` `ary` or something?

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (15 preceding siblings ...)
  2023-03-09 12:42 ` leahneukirchen
@ 2023-03-09 12:43 ` leahneukirchen
  2023-03-09 16:14 ` classabbyamp
                   ` (16 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: leahneukirchen @ 2023-03-09 12:43 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 162 bytes --]

New comment by leahneukirchen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1461991373

Comment:
or 1 and n ;)

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (16 preceding siblings ...)
  2023-03-09 12:43 ` leahneukirchen
@ 2023-03-09 16:14 ` classabbyamp
  2023-03-09 16:22 ` Duncaen
                   ` (15 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09 16:14 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1462341796

Comment:
i think `licenses` could be an array too, but we'd need to keep spdx expressions together for sanity, like `licenses=(LGPL-2.1-or-later "BSD-3-Clause WITH BullshitException")`

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (17 preceding siblings ...)
  2023-03-09 16:14 ` classabbyamp
@ 2023-03-09 16:22 ` Duncaen
  2023-03-09 16:37 ` [PR PATCH] [Updated] " classabbyamp
                   ` (14 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: Duncaen @ 2023-03-09 16:22 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 536 bytes --]

New comment by Duncaen on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1462355605

Comment:
We have nothing really to gain from making licenses an array, at the moment its free text that is not interpreted by anything, making it a shell array now might cause conflicts if we would want to actually use SPDX expressions where you can have nesting and AND/OR operators (`MIT AND (LGPL-2.1-or-later OR BSD-3-Clause)`).

https://spdx.github.io/spdx-spec/v2-draft/SPDX-license-expressions/

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (18 preceding siblings ...)
  2023-03-09 16:22 ` Duncaen
@ 2023-03-09 16:37 ` classabbyamp
  2023-03-09 16:38 ` classabbyamp
                   ` (13 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09 16:37 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 25201 bytes --]

From 8c8dfc1dfd0397b2d8ae4e0f9f694f8a0d01dd36 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:26:21 -0500
Subject: [PATCH 1/5] common/xbps-src/shutils/common.sh: add function for
 str->array

this will allow select variables to be defined as arrays or strings. if
a string is specified, it will be converted to an array for internal
usage. if it is an array, it passes through untouched. this should
allow for a smooth transition to using more arrays inside xbps-src,
and should solve issues with shell quoting in things like configure_args,
make_check_args, etc.
---
 common/xbps-src/shutils/common.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index fdc0c5eedd92..3f95c2029cbb 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -250,6 +250,18 @@ source_file() {
     fi
 }
 
+arrayise() {
+    for name; do
+        if [[ -n "$name" && "${!name@a}" != *a* ]]; then
+            IFS=" " read -r -a "${name}" <<< "${!name}"
+            declare -n nameref="$name"
+            if [ "${#nameref[@]}" -gt 1 ]; then
+                msg_error "template variable '$name' should be an array!\n"
+            fi
+        fi
+    done
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 
@@ -530,6 +542,8 @@ setup_pkg() {
 
     set_build_options
 
+    arrayise configure_args
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"

From e3c5f35a9cdeab63c3c21c5976fee5f8212668a9 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:03 -0500
Subject: [PATCH 2/5] common/xbps-src/shutils/show.sh: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df..464ac04f6261 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var ar "configure_args" "${configure_args[@]}"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From 5db6add46de1a7f3006d9a80dc2c09c66263cda2 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:56 -0500
Subject: [PATCH 3/5] common/build-style/: convert configure-args to array

---
 common/build-style/cargo.sh            | 6 +++---
 common/build-style/cmake.sh            | 4 ++--
 common/build-style/configure.sh        | 2 +-
 common/build-style/gemspec.sh          | 2 +-
 common/build-style/gnu-configure.sh    | 2 +-
 common/build-style/meson.sh            | 4 ++--
 common/build-style/perl-ModuleBuild.sh | 2 +-
 common/build-style/perl-module.sh      | 2 +-
 common/build-style/qmake.sh            | 4 ++--
 common/build-style/sip-build.sh        | 2 +-
 common/build-style/void-cross.sh       | 4 ++--
 common/build-style/waf.sh              | 2 +-
 common/build-style/waf3.sh             | 2 +-
 common/build-style/zig-build.sh        | 2 +-
 14 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 387e711060bc..8c21f9c20445 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,13 +5,13 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} ${configure_args} \
+	${make_check_pre} ${make_cmd} test --release --target ${RUST_TARGET} "${configure_args[@]}" \
 		${make_check_args}
 }
 
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 43750ad20dcd..92032b7a8b09 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -74,7 +74,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e..9b472ca28ccc 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45..0ed948dbff0e 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f7..b89008875a89 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index e983c5f42c2f..2f97671388ff 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -91,7 +91,7 @@ do_configure() {
 	: ${meson_crossfile:=xbps_meson.cross}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -122,7 +122,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4c..5efa8484068e 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe1..2bcfda743083 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606e..1f79fd42d55c 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf..42b5b2bff191 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index 02bd1f555741..aae5db2b7355 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -438,7 +438,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b17..2b3b6eb03c9d 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7..455b043ebfa3 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f..e2d02fb11b7f 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {

From fdf0f650476dfe198f0f439e8103a9df8ac28536 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:33:30 -0500
Subject: [PATCH 4/5] common/environment/configure/gnu-configure-args.sh:
 configure_args->array

---
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index dafbf5dc110c..60946b0439b3 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).

From 3d51873206332364938a8ac3de1ec95070d491f5 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:45:40 -0500
Subject: [PATCH 5/5] srcpkgs/: fix configure_args

---
 srcpkgs/backintime/template          |  4 ++--
 srcpkgs/coreutils/template           |  8 ++++----
 srcpkgs/emacs/template               |  6 +++---
 srcpkgs/ndpi/template                |  2 +-
 srcpkgs/net-snmp/template            | 12 ++++++------
 srcpkgs/nx-libs/template             |  4 ++--
 srcpkgs/openjdk15-bootstrap/template | 11 +++++------
 srcpkgs/xen/template                 |  2 +-
 8 files changed, 24 insertions(+), 25 deletions(-)

diff --git a/srcpkgs/backintime/template b/srcpkgs/backintime/template
index 2d8c9328216f..b0110046f42c 100644
--- a/srcpkgs/backintime/template
+++ b/srcpkgs/backintime/template
@@ -16,9 +16,9 @@ python_version=3
 
 do_configure() {
 	cd $wrksrc/common
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 	cd $wrksrc/qt
-	./configure $configure_args
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/coreutils/template b/srcpkgs/coreutils/template
index b9148c854960..6964a3b748a1 100644
--- a/srcpkgs/coreutils/template
+++ b/srcpkgs/coreutils/template
@@ -49,19 +49,19 @@ pre_configure() {
 
 do_configure() {
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" fu_cv_sys_stat_statfs2_bsize=no
+		configure_args+=(fu_cv_sys_stat_statfs2_bsize=no
 			gl_cv_func_working_mkstemp=yes
-			gl_cv_func_working_acl_get_file=yes "
+			gl_cv_func_working_acl_get_file=yes)
 	fi
 	case "$XBPS_TARGET_MACHINE" in
 		# XXX syncfs() in src/sync.c expects a return value.
-		*-musl) configure_args+=" ac_cv_func_syncfs=no";;
+		*-musl) configure_args+=(ac_cv_func_syncfs=no);;
 	esac
 	#
 	# Do not install kill: provided by util-linux.
 	# Do not install uptime: provided by procps-ng.
 	#
-	env $_force_unsafe_configure ./configure ${configure_args} \
+	env $_force_unsafe_configure ./configure "${configure_args[@]}" \
 		--enable-install-program=arch,hostname \
 		--enable-no-install-program=kill,uptime \
 		--disable-rpath
diff --git a/srcpkgs/emacs/template b/srcpkgs/emacs/template
index 1e74ec047dac..796d787225a6 100644
--- a/srcpkgs/emacs/template
+++ b/srcpkgs/emacs/template
@@ -59,16 +59,16 @@ post_extract() {
 
 do_configure() {
 	cd $wrksrc/nox
-	./configure --without-x $(vopt_with dbus) ${configure_args} \
+	./configure --without-x $(vopt_with dbus) "${configure_args[@]}" \
 		--without-native-compilation
 
 	cd $wrksrc/x11
 	./configure --with-x-toolkit=athena --without-toolkit-scroll-bars \
 		$(vopt_with dbus) --without-gconf --without-gsettings \
-		${configure_args}
+		"${configure_args[@]}"
 
 	cd $wrksrc/gtk3
-	./configure --with-x-toolkit=gtk3 --with-xwidgets ${configure_args}
+	./configure --with-x-toolkit=gtk3 --with-xwidgets "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/ndpi/template b/srcpkgs/ndpi/template
index 4fdef1b182e9..bcd50cc81954 100644
--- a/srcpkgs/ndpi/template
+++ b/srcpkgs/ndpi/template
@@ -13,7 +13,7 @@ distfiles="https://github.com/ntop/nDPI/archive/${version}.tar.gz"
 checksum=dc9b291c7fde94edb45fb0f222e0d93c93f8d6d37f4efba20ebd9c655bfcedf9
 
 do_configure() {
-	./autogen.sh ${configure_args}
+	./autogen.sh ${configure_args[@]}
 }
 
 do_check() {
diff --git a/srcpkgs/net-snmp/template b/srcpkgs/net-snmp/template
index af0d79685f15..6eed952b84d0 100644
--- a/srcpkgs/net-snmp/template
+++ b/srcpkgs/net-snmp/template
@@ -2,6 +2,11 @@
 pkgname=net-snmp
 version=5.9.1
 revision=3
+configure_args=(--enable-ucd-snmp-compatibility --enable-ipv6
+ --with-default-snmp-version="3" --with-sys-contact="root@localhost"
+ --with-sys-location="Unknown" --with-logfile=/var/log/snmpd.log
+ --sbindir=/usr/bin --with-persistent-directory=/var/net-snmp --disable-static
+ --with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib")
 hostmakedepends="pkg-config unzip"
 makedepends="bzip2-devel openssl-devel libnl-devel pciutils-devel
  libsensors-devel pcre-devel"
@@ -20,12 +25,7 @@ do_configure() {
 	# lack magic words.
 	export GREP='grep -a'
 
-	./configure ${configure_args} --enable-ucd-snmp-compatibility \
-		--enable-ipv6 --with-default-snmp-version="3" \
-		--with-sys-contact="root@localhost" --with-sys-location="Unknown" \
-		--with-logfile=/var/log/snmpd.log --sbindir=/usr/bin \
-		--with-mib-modules="host misc/ipfwacc ucd-snmp/diskio tunnel ucd-snmp/dlmod ucd-snmp/lmsensorsMib" \
-		--with-persistent-directory=/var/net-snmp --disable-static
+	./configure "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/srcpkgs/nx-libs/template b/srcpkgs/nx-libs/template
index f604983c82c9..18c83aed0016 100644
--- a/srcpkgs/nx-libs/template
+++ b/srcpkgs/nx-libs/template
@@ -42,11 +42,11 @@ do_configure() {
 	# Configure all subprojects in advance of build
 	local _subdir
 	for _subdir in nxcomp nxcompshad nxproxy nxdialog; do
-		( cd ${_subdir} && ./configure ${configure_args} )
+		( cd ${_subdir} && ./configure "${configure_args[@]}" )
 	done
 
 	# nx-X11 configure has an extra argument
-	( cd nx-X11/lib && ./configure ${configure_args} --disable-poll )
+	( cd nx-X11/lib && ./configure "${configure_args[@]}" --disable-poll )
 }
 
 post_install() {
diff --git a/srcpkgs/openjdk15-bootstrap/template b/srcpkgs/openjdk15-bootstrap/template
index a3b515b98a96..430cf43eb215 100644
--- a/srcpkgs/openjdk15-bootstrap/template
+++ b/srcpkgs/openjdk15-bootstrap/template
@@ -61,14 +61,14 @@ esac
 
 if [ -n "$_use_zero" ]; then
 	makedepends+=" libffi-devel"
-	configure_args+=" --with-jvm-variants=zero"
+	configure_args+=("--with-jvm-variants=zero")
 	case "$XBPS_TARGET_MACHINE" in
-		ppc*) configure_args+=" --with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560";;
+		ppc*) configure_args+=("--with-boot-jdk-jvmargs=-XX:ThreadStackSize=2560");;
 	esac
 fi
 
 if [ -n "$XBPS_DEBUG_PKGS" ]; then
-	configure_args+=" --with-native-debug-symbols=internal"
+	configure_args+=("--with-native-debug-symbols=internal")
 fi
 
 post_extract() {
@@ -100,13 +100,12 @@ do_configure() {
 			;;
 	esac
 
-	configure_args=${configure_args/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}
 	if [ "$XBPS_CCACHE" ]; then
-		configure_args+=" --enable-ccache"
+		configure_args+=(--enable-ccache)
 	fi
 	CC="/usr/bin/cc"
 	CXX="/usr/bin/c++"
-	./configure ${configure_args} \
+	./configure "${configure_args[@]/--with-libtool-sysroot=\/usr\/[a-z0-9]*-linux-[a-z]*/}" \
 		--with-extra-cflags="$CFLAGS" \
 		--with-extra-cxxflags="$CXXFLAGS" \
 		--with-extra-ldflags="$LDFLAGS" \
diff --git a/srcpkgs/xen/template b/srcpkgs/xen/template
index 160db8e65929..dde7b0aa5df3 100644
--- a/srcpkgs/xen/template
+++ b/srcpkgs/xen/template
@@ -146,7 +146,7 @@ do_configure() {
 	cp -a ${FILESDIR}/stdint_local.h ${wrksrc}/tools/libxl/
 	rm -f ${XBPS_WRAPPERDIR}/strip
 	./autogen.sh
-	./configure ${configure_args}
+	./configure ${configure_args[@]}
 }
 
 do_build() {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (19 preceding siblings ...)
  2023-03-09 16:37 ` [PR PATCH] [Updated] " classabbyamp
@ 2023-03-09 16:38 ` classabbyamp
  2023-03-09 16:38 ` classabbyamp
                   ` (12 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09 16:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1462381469

Comment:
> I'm not a big fan of these 0,1,2 parameter... could we use str ary or something?

i've made it a bit more readable, but I suspect the code will change a little once more things are arrays

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (20 preceding siblings ...)
  2023-03-09 16:38 ` classabbyamp
@ 2023-03-09 16:38 ` classabbyamp
  2023-06-08  2:05 ` github-actions
                   ` (11 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-03-09 16:38 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 334 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1462381469

Comment:
> I'm not a big fan of these 0,1,2 parameter... could we use str ary or something?

i've made it a bit more readable, but I suspect the code will change more once more things are arrays

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (21 preceding siblings ...)
  2023-03-09 16:38 ` classabbyamp
@ 2023-06-08  2:05 ` github-actions
  2023-06-08  2:35 ` classabbyamp
                   ` (10 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: github-actions @ 2023-06-08  2:05 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1581780020

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (22 preceding siblings ...)
  2023-06-08  2:05 ` github-actions
@ 2023-06-08  2:35 ` classabbyamp
  2023-09-07  1:44 ` github-actions
                   ` (9 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-06-08  2:35 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1581780020

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (23 preceding siblings ...)
  2023-06-08  2:35 ` classabbyamp
@ 2023-09-07  1:44 ` github-actions
  2023-09-07  1:55 ` classabbyamp
                   ` (8 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: github-actions @ 2023-09-07  1:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1709342173

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (24 preceding siblings ...)
  2023-09-07  1:44 ` github-actions
@ 2023-09-07  1:55 ` classabbyamp
  2023-11-02 13:42 ` [PR PATCH] [Updated] " classabbyamp
                   ` (7 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-09-07  1:55 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1709342173

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (25 preceding siblings ...)
  2023-09-07  1:55 ` classabbyamp
@ 2023-11-02 13:42 ` classabbyamp
  2023-11-02 15:54 ` classabbyamp
                   ` (6 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-11-02 13:42 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 18316 bytes --]

From cfeb2e1f7c0df9a2322581de3f957fb7a14a1a72 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:26:21 -0500
Subject: [PATCH 1/4] common/xbps-src/shutils/common.sh: add function for
 str->array

this will allow select variables to be defined as arrays or strings. if
a string is specified, it will be converted to an array for internal
usage. if it is an array, it passes through untouched. this should
allow for a smooth transition to using more arrays inside xbps-src,
and should solve issues with shell quoting in things like configure_args,
make_check_args, etc.
---
 common/xbps-src/shutils/common.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 04247942decf25..88ee6b4fb6ec1a 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -286,6 +286,18 @@ source_file() {
     fi
 }
 
+arrayise() {
+    for name; do
+        if [[ -n "$name" && "${!name@a}" != *a* ]]; then
+            IFS=" " read -r -a "${name}" <<< "${!name}"
+            declare -n nameref="$name"
+            if [ "${#nameref[@]}" -gt 1 ]; then
+                msg_error "template variable '$name' should be an array!\n"
+            fi
+        fi
+    done
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 
@@ -568,6 +580,8 @@ setup_pkg() {
 
     set_build_options
 
+    arrayise configure_args
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"

From a7c20ad2f26a5806fce95dc50e56ffa8c1dd6e7a Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:03 -0500
Subject: [PATCH 2/4] common/xbps-src/shutils/show.sh: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df28..464ac04f6261e3 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var ar "configure_args" "${configure_args[@]}"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From adddd05ebe6055df0c6ab01022090f400faf6c6b Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:32:56 -0500
Subject: [PATCH 3/4] common/build-style/: convert configure-args to array

---
 common/build-style/cargo.sh            | 6 +++---
 common/build-style/cmake.sh            | 4 ++--
 common/build-style/configure.sh        | 2 +-
 common/build-style/gemspec.sh          | 2 +-
 common/build-style/gnu-configure.sh    | 2 +-
 common/build-style/meson.sh            | 4 ++--
 common/build-style/perl-ModuleBuild.sh | 2 +-
 common/build-style/perl-module.sh      | 2 +-
 common/build-style/qmake.sh            | 4 ++--
 common/build-style/sip-build.sh        | 2 +-
 common/build-style/void-cross.sh       | 4 ++--
 common/build-style/waf.sh              | 2 +-
 common/build-style/waf3.sh             | 2 +-
 common/build-style/zig-build.sh        | 2 +-
 14 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 751911d8dbee8d..c080a65ad71ca6 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,14 +5,14 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --locked --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --locked --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
 	${make_check_pre} ${make_cmd} test --release --locked --target ${RUST_TARGET} \
-		${configure_args} ${make_check_args}
+		"${configure_args[@]}" ${make_check_args}
 }
 
 do_install() {
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 124ed354eff674..3adbba4db263b2 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -75,7 +75,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e8f..9b472ca28ccc20 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45a3..0ed948dbff0e57 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f79c..b89008875a894a 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index 5ea2eeda40097d..9f1abed904a797 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -8,7 +8,7 @@ do_configure() {
 	: ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -39,7 +39,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4cf0..5efa8484068e48 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe11e..2bcfda7430833f 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606eff..1f79fd42d55ced 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf09..42b5b2bff19122 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index 2e8ebb52ceaf90..bcd6cece5eadf2 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -442,7 +442,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b1797..2b3b6eb03c9df9 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7f3..455b043ebfa398 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f8c..e2d02fb11b7f27 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {

From 7e0ab2bbe997bf9e40997ed11822393cbb4fa4bd Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Wed, 8 Mar 2023 04:33:30 -0500
Subject: [PATCH 4/4] common/environment/configure/gnu-configure-args.sh:
 configure_args->array

---
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index 1a552b5074a076..06974323cf94fd 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (26 preceding siblings ...)
  2023-11-02 13:42 ` [PR PATCH] [Updated] " classabbyamp
@ 2023-11-02 15:54 ` classabbyamp
  2023-11-02 15:56 ` classabbyamp
                   ` (5 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-11-02 15:54 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 23853 bytes --]

From 9c263e0d3a4dce5b7ae34a39f09064a25430f127 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:31:56 -0400
Subject: [PATCH 1/3] common/xbps-src/shutils/common: add functions for arrays
 in templates

`ensure_array` will ensure the named variables are arrays if defined.
This allows us to not need to convert all packages to arrays
immediately, as they can be migrated the next time someone builds them.

`array_contains` is a helper function to make checking if an array
contains a value easier.
---
 common/xbps-src/shutils/common.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 04247942decf2..7c540084e40fe 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -286,6 +286,20 @@ source_file() {
     fi
 }
 
+ensure_array() {
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' should be an array!\n"
+        fi
+    done
+}
+
+array_contains() {
+    local arr="$1" val="$2"
+    printf '%s\0' "${!arr[@]}" | grep -Fxqz "$val"
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 

From 642d7a5b69d6ca92c20dbba4a227ac353da3b007 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:37:35 -0400
Subject: [PATCH 2/3] common/xbps-src/shutils/show: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df2..0cab761f1215c 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From b5a2bff2398b4f2ddb6ae88a7c53c2744837c10b Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:52:47 -0400
Subject: [PATCH 3/3] common: {hostmake,make,check,}depends to array

---
 common/build-helper/gir.sh                    | 16 +++++++--------
 common/build-helper/numpy.sh                  |  8 ++++----
 common/build-helper/qemu.sh                   |  4 ++--
 common/environment/build-style/R-cran.sh      |  4 ++--
 common/environment/build-style/cargo.sh       |  6 +++---
 common/environment/build-style/cmake.sh       |  4 ++--
 common/environment/build-style/gem.sh         |  4 ++--
 common/environment/build-style/gemspec.sh     |  4 ++--
 common/environment/build-style/go.sh          |  4 ++--
 .../environment/build-style/haskell-stack.sh  |  2 +-
 common/environment/build-style/meson.sh       |  2 +-
 .../build-style/perl-ModuleBuild.sh           |  4 ++--
 common/environment/build-style/perl-module.sh |  6 +++---
 .../environment/build-style/python2-module.sh |  2 +-
 .../environment/build-style/python3-module.sh |  2 +-
 .../environment/build-style/python3-pep517.sh |  2 +-
 common/environment/build-style/raku-dist.sh   |  6 +++---
 common/environment/build-style/scons.sh       |  2 +-
 common/environment/build-style/texmf.sh       |  2 +-
 common/environment/build-style/waf.sh         |  2 +-
 common/environment/build-style/waf3.sh        |  2 +-
 common/environment/build-style/zig-build.sh   |  2 +-
 common/xbps-src/shutils/build_dependencies.sh | 20 +++++++++----------
 common/xbps-src/shutils/common.sh             |  4 +++-
 common/xbps-src/shutils/consistency_check.sh  |  8 ++++----
 common/xbps-src/shutils/show.sh               |  6 +++---
 26 files changed, 65 insertions(+), 63 deletions(-)

diff --git a/common/build-helper/gir.sh b/common/build-helper/gir.sh
index 70699adb17973..93ae649572ee9 100644
--- a/common/build-helper/gir.sh
+++ b/common/build-helper/gir.sh
@@ -8,24 +8,24 @@
 # Check if the 'gir' build_option is set or if there is no
 # 'gir' build_option.
 if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
-	if [[ $hostmakedepends != *"gobject-introspection"* ]]; then
+	if ! array_contains hostmakedepends "gobject-introspection"; then
 		# Provide the host tooling, g-ir-scanner, g-ir-compiler
 		# and its wrappers.
-		hostmakedepends+=" gobject-introspection"
+		hostmakedepends+=(gobject-introspection)
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
 		# Required for running binaries produced from g-ir-compiler
 		# via g-ir-scanner-qemuwrapper
-		hostmakedepends+=" qemu-user-static"
+		hostmakedepends+=(qemu-user-static)
 
 		# Required for running the g-ir-scanner-lddwrapper
-		hostmakedepends+=" prelink-cross"
+		hostmakedepends+=(prelink-cross)
 
-		if [[ $makedepends != *"gobject-introspection"* ]]; then
+		if ! array_contains makedepends "gobject-introspection"; then
 			# Provide basic .gir types like GLib, GObject, DBus, Gio, cairo
 			# and tooling like g-ir-compiler
-			makedepends+=" gobject-introspection"
+			makedepends+=(gobject-introspection)
 		fi
 
 		export VAPIGEN_VAPIDIRS=${XBPS_CROSS_BASE}/usr/share/vala/vapi
@@ -33,8 +33,8 @@ if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
 
 		# Provide some packages in hostmakedepends if they are in makedepends
 		for f in gtk+3-devel python3-gobject-devel; do
-			if [[ $makedepends == *"${f}"* ]]; then
-				hostmakedepends+=" ${f}"
+			if array_contains makedepends "${f}"; then
+				hostmakedepends+=("${f}")
 			fi
 		done
 		unset f
diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh
index e0856dbca7cf3..801a7dcc41f4f 100644
--- a/common/build-helper/numpy.sh
+++ b/common/build-helper/numpy.sh
@@ -7,14 +7,14 @@
 
 # Even for cross compilation, numpy should be available on the host to ensure
 # that the host interpreter doesn't complain about missing deps
-if [[ $hostmakedepends != *"python3-numpy"* ]]; then
-	hostmakedepends+=" python3-numpy"
+if ! array_contains hostmakedepends "python3-numpy"; then
+	hostmakedepends+=(python3-numpy)
 fi
 
 [ -z "$CROSS_BUILD" ] && return 0
 
-if [[ $makedepends != *"python3-numpy"* ]]; then
-	makedepends+=" python3-numpy"
+if ! array_contains makedepends "python3-numpy"; then
+	makedepends+=(python3-numpy)
 fi
 
 # python3-setuptools finds numpy libs and headers on the host first;
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index d6a4342f5e8ee..5cbb3a6c8e654 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -1,7 +1,7 @@
 if [ "$CROSS_BUILD" ]; then
 	export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-	if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
-		hostmakedepends+=" qemu-user-static"
+	if ! array_contains hostmakedepends "qemu-user-static"; then
+		hostmakedepends+=(qemu-user-static)
 	fi
 fi
 
diff --git a/common/environment/build-style/R-cran.sh b/common/environment/build-style/R-cran.sh
index 0cb7c906f952a..6f1ab94ed59f3 100644
--- a/common/environment/build-style/R-cran.sh
+++ b/common/environment/build-style/R-cran.sh
@@ -1,5 +1,5 @@
-makedepends+=" R"
-depends+=" R"
+makedepends+=(R)
+depends+=(R)
 create_wrksrc=required
 build_wrksrc="${pkgname#R-cran-}"
 
diff --git a/common/environment/build-style/cargo.sh b/common/environment/build-style/cargo.sh
index 473750c7a359e..e96171cd5b067 100644
--- a/common/environment/build-style/cargo.sh
+++ b/common/environment/build-style/cargo.sh
@@ -1,11 +1,11 @@
-hostmakedepends+=" cargo"
+hostmakedepends+=(cargo)
 
 if ! [[ "$pkgname" =~ ^cargo-auditable(-bootstrap)?$ ]]; then
-	hostmakedepends+=" cargo-auditable"
+	hostmakedepends+=(cargo-auditable)
 fi
 
 if [ "$CROSS_BUILD" ]; then
-	makedepends+=" rust-std"
+	makedepends+=(rust-std)
 fi
 
 build_helper+=" rust"
diff --git a/common/environment/build-style/cmake.sh b/common/environment/build-style/cmake.sh
index 1c5386e1c46c1..992721ba9f814 100644
--- a/common/environment/build-style/cmake.sh
+++ b/common/environment/build-style/cmake.sh
@@ -1,9 +1,9 @@
 if [ "$CHROOT_READY" ]; then
 	if [ "$pkgname" != cmake-bootstrap ]; then
-		hostmakedepends+=" cmake-bootstrap"
+		hostmakedepends+=(cmake-bootstrap)
 	fi
 	if [ "${make_cmd:-ninja}" = ninja ]; then
-		hostmakedepends+=" ninja"
+		hostmakedepends+=(ninja)
 	fi
 fi
 
diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh
index 73a97bda7d8b2..8ef38cc779162 100644
--- a/common/environment/build-style/gem.sh
+++ b/common/environment/build-style/gem.sh
@@ -1,6 +1,6 @@
 lib32disabled=yes
-hostmakedepends+=" ruby"
-depends+=" ruby"
+hostmakedepends+=(ruby)
+depends+=(ruby)
 
 # default to rubygems
 if [ -z "$distfiles" ]; then
diff --git a/common/environment/build-style/gemspec.sh b/common/environment/build-style/gemspec.sh
index b3025a9ec47e9..2536da11cd46f 100644
--- a/common/environment/build-style/gemspec.sh
+++ b/common/environment/build-style/gemspec.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-hostmakedepends+=" ruby-devel"
-makedepends+=" ruby-devel"
+hostmakedepends+=(ruby-devel)
+makedepends+=(ruby-devel)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b..c58b297891cf6 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,9 @@
-if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
+if [ "${#hostmakedepends[@]}" -eq 0 ] || ! array_contains hostmakedepends "gcc-go-tools"; then
 	# gc compiler
 	if [ -z "$archs" ]; then
 		archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
 	fi
-	hostmakedepends+=" go"
+	hostmakedepends+=(go)
 	nopie=yes
 else
 	# gccgo compiler
diff --git a/common/environment/build-style/haskell-stack.sh b/common/environment/build-style/haskell-stack.sh
index 6b47c12151237..02d5dc63002fd 100644
--- a/common/environment/build-style/haskell-stack.sh
+++ b/common/environment/build-style/haskell-stack.sh
@@ -1 +1 @@
-hostmakedepends+=" ghc stack"
+hostmakedepends+=(ghc stack)
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index dbfe93700f691..2b5726f3dc057 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1,2 +1,2 @@
-hostmakedepends+=" meson"
+hostmakedepends+=(meson)
 build_helper+=" meson"
diff --git a/common/environment/build-style/perl-ModuleBuild.sh b/common/environment/build-style/perl-ModuleBuild.sh
index 60d677131479a..59ba553b1d4b8 100644
--- a/common/environment/build-style/perl-ModuleBuild.sh
+++ b/common/environment/build-style/perl-ModuleBuild.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/perl-module.sh b/common/environment/build-style/perl-module.sh
index 300ed9b5db616..cb56eb3ab0cad 100644
--- a/common/environment/build-style/perl-module.sh
+++ b/common/environment/build-style/perl-module.sh
@@ -1,4 +1,4 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
-depends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
+depends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/python2-module.sh b/common/environment/build-style/python2-module.sh
index 3a3699bfac0e1..ae51021e4988a 100644
--- a/common/environment/build-style/python2-module.sh
+++ b/common/environment/build-style/python2-module.sh
@@ -1,2 +1,2 @@
 lib32disabled=yes
-makedepends+=" python"
+makedepends+=(python)
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 638f6be9373a4..ce0d9bbeb10e5 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-makedepends+=" python3"
+makedepends+=(python3)
 build_helper+=" python3"
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
index f4faf980f5080..8e22b31966336 100644
--- a/common/environment/build-style/python3-pep517.sh
+++ b/common/environment/build-style/python3-pep517.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" python3-build python3-installer"
+hostmakedepends+=(python3-build python3-installer)
 lib32disabled=yes
 build_helper+=" python3"
diff --git a/common/environment/build-style/raku-dist.sh b/common/environment/build-style/raku-dist.sh
index 01dc08fcf6666..c72ff70958056 100644
--- a/common/environment/build-style/raku-dist.sh
+++ b/common/environment/build-style/raku-dist.sh
@@ -1,3 +1,3 @@
-depends+=" rakudo"
-checkdepends+=" perl"
-hostmakedepends+=" rakudo"
+depends+=(rakudo)
+checkdepends+=(perl)
+hostmakedepends+=(rakudo)
diff --git a/common/environment/build-style/scons.sh b/common/environment/build-style/scons.sh
index 614fb2c04bee6..bf5c972a4e260 100644
--- a/common/environment/build-style/scons.sh
+++ b/common/environment/build-style/scons.sh
@@ -1 +1 @@
-hostmakedepends+=" scons"
+hostmakedepends+=(scons)
diff --git a/common/environment/build-style/texmf.sh b/common/environment/build-style/texmf.sh
index b0ecf4702fe78..b883273531c2f 100644
--- a/common/environment/build-style/texmf.sh
+++ b/common/environment/build-style/texmf.sh
@@ -1,4 +1,4 @@
 # rsync isn't needed for everything but it's far easier to just put it here
-hostmakedepends+=" rsync"
+hostmakedepends+=(rsync)
 # python_version isn't needed for everything either
 python_version=3
diff --git a/common/environment/build-style/waf.sh b/common/environment/build-style/waf.sh
index f5deafbf00cab..2831340bf35a3 100644
--- a/common/environment/build-style/waf.sh
+++ b/common/environment/build-style/waf.sh
@@ -1 +1 @@
-hostmakedepends+=" python"
+hostmakedepends+=(python)
diff --git a/common/environment/build-style/waf3.sh b/common/environment/build-style/waf3.sh
index 471e0dae2d36a..8efbd8ae579c2 100644
--- a/common/environment/build-style/waf3.sh
+++ b/common/environment/build-style/waf3.sh
@@ -1 +1 @@
-hostmakedepends+=" python3"
+hostmakedepends+=(python3)
diff --git a/common/environment/build-style/zig-build.sh b/common/environment/build-style/zig-build.sh
index 049b7cd437d53..6af7f8335e629 100644
--- a/common/environment/build-style/zig-build.sh
+++ b/common/environment/build-style/zig-build.sh
@@ -1 +1 @@
-hostmakedepends+=" zig"
+hostmakedepends+=(zig)
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 20f61528d14c2..ad4fe406a3862 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -9,16 +9,16 @@ setup_pkg_depends() {
             ${pkg}_package
         fi
     elif [[ $with_subpkgs ]]; then
-        collected="${depends}"
+        collected=("${depends[@]}")
         for pkg in $subpackages; do
             [[ $pkg ]] || continue
             ${pkg}_package
-            collected+=" ${depends}"
+            collected+=("${depends[@]}")
         done
-        depends="${collected}"
+        depends=("${collected[@]}")
     fi
 
-    for j in ${depends}; do
+    for j in "${depends[@]}"; do
         _rpkgname="${j%\?*}"
         _depname="${j#*\?}"
         if [[ ${_rpkgname} == virtual ]]; then
@@ -158,10 +158,10 @@ install_pkg_deps() {
     #
     # Host build dependencies.
     #
-    if [[ ${hostmakedepends} ]]; then
+    if [ "${#hostmakedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${hostmakedepends}; do
+        for f in "${hostmakedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -208,10 +208,10 @@ install_pkg_deps() {
     #
     # Host check dependencies.
     #
-    if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
+    if [ ${#checkdepends[@]} -gt 0 ] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
         templates=""
         # check validity
-        for f in ${checkdepends}; do
+        for f in "${checkdepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -258,10 +258,10 @@ install_pkg_deps() {
     #
     # Target build dependencies.
     #
-    if [[ ${makedepends} ]]; then
+    if [ ${#makedepends[@]} -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${makedepends}; do
+        for f in "${makedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 7c540084e40fe..01bf8536959dd 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -529,7 +529,7 @@ setup_pkg() {
         fi
     fi
 
-    for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
+    for x in "${hostmakedepends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
         if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
             msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
         fi
@@ -582,6 +582,8 @@ setup_pkg() {
 
     set_build_options
 
+    ensure_array hostmakedepends makedepends checkdepends depends
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/consistency_check.sh b/common/xbps-src/shutils/consistency_check.sh
index 6a5b2ec199757..fe892839acad9 100644
--- a/common/xbps-src/shutils/consistency_check.sh
+++ b/common/xbps-src/shutils/consistency_check.sh
@@ -69,12 +69,12 @@ consistency_check() {
         XBPS_TARGET_PKG=${pkg##*/}
         (
             read_pkg
-            [ "$depends" ] && printf "%s $pkgname depends\n" $depends
+            [ "${#depends[@]}" -gt 0 ] && printf "%s $pkgname depends\n" "${depends[*]}"
             [ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
             [ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
-            [ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
-            [ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
-            [ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
+            [ "${#makedepends[@]}" -gt 0 ] && printf "%s $pkgname makedepends\n" "${makedepends[*]}"
+            [ "${#hostmakedepends[@]}" -gt 0 ] && printf "%s $pkgname hostmakedepends\n" "${hostmakedepends[*]}"
+            [ "${#checkdepends[@]}" -gt 0 ] && printf "%s $pkgname checkdepends\n" "${checkdepends[*]}"
         )
     done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
         consistency_convert_pkgname | consistency_check_smart
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 0cab761f1215c..d44c2c7c97a8e 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -150,15 +150,15 @@ show_pkg_build_depends() {
 }
 
 show_pkg_build_deps() {
-    show_pkg_build_depends "${makedepends} $(setup_pkg_depends '' 1 1)" "${hostmakedepends}"
+    show_pkg_build_depends "${makedepends[*]} $(setup_pkg_depends '' 1 1)" "${hostmakedepends[*]}"
 }
 
 show_pkg_hostmakedepends() {
-    show_pkg_build_depends "" "${hostmakedepends}"
+    show_pkg_build_depends "" "${hostmakedepends[*]}"
 }
 
 show_pkg_makedepends() {
-    show_pkg_build_depends "${makedepends}" ""
+    show_pkg_build_depends "${makedepends[*]}" ""
 }
 
 show_pkg_build_options() {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (27 preceding siblings ...)
  2023-11-02 15:54 ` classabbyamp
@ 2023-11-02 15:56 ` classabbyamp
  2023-11-02 16:31 ` [PR PATCH] [Updated] " classabbyamp
                   ` (4 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-11-02 15:56 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

New comment by classabbyamp on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1791009451

Comment:
I think the best way to go about this will be:
1. don't try to convert strings to arrrays
2. don't try to assume strings are single-element arrays
3. have some utility (maybe written in go with `shfmt`'s library) that can do a best-effort conversion of templates

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (28 preceding siblings ...)
  2023-11-02 15:56 ` classabbyamp
@ 2023-11-02 16:31 ` classabbyamp
  2023-11-02 16:44 ` classabbyamp
                   ` (3 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-11-02 16:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 24368 bytes --]

From 942c92c999af9bd6b31bfd3af22599c931f42ee4 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:31:56 -0400
Subject: [PATCH 1/3] common/xbps-src/shutils/common: add functions for arrays
 in templates

`ensure_array` will ensure the named variables are arrays if defined.
This allows us to not need to convert all packages to arrays
immediately, as they can be migrated the next time someone builds them.

`ensure_array_subpkg` does the same thing as `ensure_array`, but is also
passed the subpkg for better error message context.

`array_contains` is a helper function to make checking if an array
contains a value easier.
---
 common/xbps-src/shutils/common.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 04247942decf2..5c6a79fbda7eb 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -286,6 +286,31 @@ source_file() {
     fi
 }
 
+ensure_array() {
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' should be an array!\n"
+        fi
+    done
+}
+
+ensure_array_subpkg() {
+    local subpkg="$1"
+    shift 1
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' in subpkg '$subpkg' should be an array!\n"
+        fi
+    done
+}
+
+array_contains() {
+    local arr="$1" val="$2"
+    printf '%s\0' "${!arr[@]}" | grep -Fxqz "$val"
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 

From f3f3faeebe596df7aacc5a5357da07b8fe3b7945 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:37:35 -0400
Subject: [PATCH 2/3] common/xbps-src/shutils/show: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df2..0cab761f1215c 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From c9508ddcd7069669d2564a6db27197646a6eccdc Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:52:47 -0400
Subject: [PATCH 3/3] common: {hostmake,make,check,}depends to array

---
 common/build-helper/gir.sh                    | 16 +++++++-------
 common/build-helper/numpy.sh                  |  8 +++----
 common/build-helper/qemu.sh                   |  4 ++--
 common/environment/build-style/R-cran.sh      |  4 ++--
 common/environment/build-style/cargo.sh       |  6 +++---
 common/environment/build-style/cmake.sh       |  4 ++--
 common/environment/build-style/gem.sh         |  4 ++--
 common/environment/build-style/gemspec.sh     |  4 ++--
 common/environment/build-style/go.sh          |  4 ++--
 .../environment/build-style/haskell-stack.sh  |  2 +-
 common/environment/build-style/meson.sh       |  2 +-
 .../build-style/perl-ModuleBuild.sh           |  4 ++--
 common/environment/build-style/perl-module.sh |  6 +++---
 .../environment/build-style/python2-module.sh |  2 +-
 .../environment/build-style/python3-module.sh |  2 +-
 .../environment/build-style/python3-pep517.sh |  2 +-
 common/environment/build-style/raku-dist.sh   |  6 +++---
 common/environment/build-style/scons.sh       |  2 +-
 common/environment/build-style/texmf.sh       |  2 +-
 common/environment/build-style/waf.sh         |  2 +-
 common/environment/build-style/waf3.sh        |  2 +-
 common/environment/build-style/zig-build.sh   |  2 +-
 common/xbps-src/shutils/build_dependencies.sh | 21 ++++++++++---------
 common/xbps-src/shutils/common.sh             |  4 +++-
 common/xbps-src/shutils/consistency_check.sh  |  8 +++----
 common/xbps-src/shutils/show.sh               |  6 +++---
 26 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/common/build-helper/gir.sh b/common/build-helper/gir.sh
index 70699adb17973..93ae649572ee9 100644
--- a/common/build-helper/gir.sh
+++ b/common/build-helper/gir.sh
@@ -8,24 +8,24 @@
 # Check if the 'gir' build_option is set or if there is no
 # 'gir' build_option.
 if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
-	if [[ $hostmakedepends != *"gobject-introspection"* ]]; then
+	if ! array_contains hostmakedepends "gobject-introspection"; then
 		# Provide the host tooling, g-ir-scanner, g-ir-compiler
 		# and its wrappers.
-		hostmakedepends+=" gobject-introspection"
+		hostmakedepends+=(gobject-introspection)
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
 		# Required for running binaries produced from g-ir-compiler
 		# via g-ir-scanner-qemuwrapper
-		hostmakedepends+=" qemu-user-static"
+		hostmakedepends+=(qemu-user-static)
 
 		# Required for running the g-ir-scanner-lddwrapper
-		hostmakedepends+=" prelink-cross"
+		hostmakedepends+=(prelink-cross)
 
-		if [[ $makedepends != *"gobject-introspection"* ]]; then
+		if ! array_contains makedepends "gobject-introspection"; then
 			# Provide basic .gir types like GLib, GObject, DBus, Gio, cairo
 			# and tooling like g-ir-compiler
-			makedepends+=" gobject-introspection"
+			makedepends+=(gobject-introspection)
 		fi
 
 		export VAPIGEN_VAPIDIRS=${XBPS_CROSS_BASE}/usr/share/vala/vapi
@@ -33,8 +33,8 @@ if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
 
 		# Provide some packages in hostmakedepends if they are in makedepends
 		for f in gtk+3-devel python3-gobject-devel; do
-			if [[ $makedepends == *"${f}"* ]]; then
-				hostmakedepends+=" ${f}"
+			if array_contains makedepends "${f}"; then
+				hostmakedepends+=("${f}")
 			fi
 		done
 		unset f
diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh
index e0856dbca7cf3..801a7dcc41f4f 100644
--- a/common/build-helper/numpy.sh
+++ b/common/build-helper/numpy.sh
@@ -7,14 +7,14 @@
 
 # Even for cross compilation, numpy should be available on the host to ensure
 # that the host interpreter doesn't complain about missing deps
-if [[ $hostmakedepends != *"python3-numpy"* ]]; then
-	hostmakedepends+=" python3-numpy"
+if ! array_contains hostmakedepends "python3-numpy"; then
+	hostmakedepends+=(python3-numpy)
 fi
 
 [ -z "$CROSS_BUILD" ] && return 0
 
-if [[ $makedepends != *"python3-numpy"* ]]; then
-	makedepends+=" python3-numpy"
+if ! array_contains makedepends "python3-numpy"; then
+	makedepends+=(python3-numpy)
 fi
 
 # python3-setuptools finds numpy libs and headers on the host first;
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index d6a4342f5e8ee..5cbb3a6c8e654 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -1,7 +1,7 @@
 if [ "$CROSS_BUILD" ]; then
 	export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-	if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
-		hostmakedepends+=" qemu-user-static"
+	if ! array_contains hostmakedepends "qemu-user-static"; then
+		hostmakedepends+=(qemu-user-static)
 	fi
 fi
 
diff --git a/common/environment/build-style/R-cran.sh b/common/environment/build-style/R-cran.sh
index 0cb7c906f952a..6f1ab94ed59f3 100644
--- a/common/environment/build-style/R-cran.sh
+++ b/common/environment/build-style/R-cran.sh
@@ -1,5 +1,5 @@
-makedepends+=" R"
-depends+=" R"
+makedepends+=(R)
+depends+=(R)
 create_wrksrc=required
 build_wrksrc="${pkgname#R-cran-}"
 
diff --git a/common/environment/build-style/cargo.sh b/common/environment/build-style/cargo.sh
index 473750c7a359e..e96171cd5b067 100644
--- a/common/environment/build-style/cargo.sh
+++ b/common/environment/build-style/cargo.sh
@@ -1,11 +1,11 @@
-hostmakedepends+=" cargo"
+hostmakedepends+=(cargo)
 
 if ! [[ "$pkgname" =~ ^cargo-auditable(-bootstrap)?$ ]]; then
-	hostmakedepends+=" cargo-auditable"
+	hostmakedepends+=(cargo-auditable)
 fi
 
 if [ "$CROSS_BUILD" ]; then
-	makedepends+=" rust-std"
+	makedepends+=(rust-std)
 fi
 
 build_helper+=" rust"
diff --git a/common/environment/build-style/cmake.sh b/common/environment/build-style/cmake.sh
index 1c5386e1c46c1..992721ba9f814 100644
--- a/common/environment/build-style/cmake.sh
+++ b/common/environment/build-style/cmake.sh
@@ -1,9 +1,9 @@
 if [ "$CHROOT_READY" ]; then
 	if [ "$pkgname" != cmake-bootstrap ]; then
-		hostmakedepends+=" cmake-bootstrap"
+		hostmakedepends+=(cmake-bootstrap)
 	fi
 	if [ "${make_cmd:-ninja}" = ninja ]; then
-		hostmakedepends+=" ninja"
+		hostmakedepends+=(ninja)
 	fi
 fi
 
diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh
index 73a97bda7d8b2..8ef38cc779162 100644
--- a/common/environment/build-style/gem.sh
+++ b/common/environment/build-style/gem.sh
@@ -1,6 +1,6 @@
 lib32disabled=yes
-hostmakedepends+=" ruby"
-depends+=" ruby"
+hostmakedepends+=(ruby)
+depends+=(ruby)
 
 # default to rubygems
 if [ -z "$distfiles" ]; then
diff --git a/common/environment/build-style/gemspec.sh b/common/environment/build-style/gemspec.sh
index b3025a9ec47e9..2536da11cd46f 100644
--- a/common/environment/build-style/gemspec.sh
+++ b/common/environment/build-style/gemspec.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-hostmakedepends+=" ruby-devel"
-makedepends+=" ruby-devel"
+hostmakedepends+=(ruby-devel)
+makedepends+=(ruby-devel)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b..c58b297891cf6 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,9 @@
-if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
+if [ "${#hostmakedepends[@]}" -eq 0 ] || ! array_contains hostmakedepends "gcc-go-tools"; then
 	# gc compiler
 	if [ -z "$archs" ]; then
 		archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
 	fi
-	hostmakedepends+=" go"
+	hostmakedepends+=(go)
 	nopie=yes
 else
 	# gccgo compiler
diff --git a/common/environment/build-style/haskell-stack.sh b/common/environment/build-style/haskell-stack.sh
index 6b47c12151237..02d5dc63002fd 100644
--- a/common/environment/build-style/haskell-stack.sh
+++ b/common/environment/build-style/haskell-stack.sh
@@ -1 +1 @@
-hostmakedepends+=" ghc stack"
+hostmakedepends+=(ghc stack)
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index dbfe93700f691..2b5726f3dc057 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1,2 +1,2 @@
-hostmakedepends+=" meson"
+hostmakedepends+=(meson)
 build_helper+=" meson"
diff --git a/common/environment/build-style/perl-ModuleBuild.sh b/common/environment/build-style/perl-ModuleBuild.sh
index 60d677131479a..59ba553b1d4b8 100644
--- a/common/environment/build-style/perl-ModuleBuild.sh
+++ b/common/environment/build-style/perl-ModuleBuild.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/perl-module.sh b/common/environment/build-style/perl-module.sh
index 300ed9b5db616..cb56eb3ab0cad 100644
--- a/common/environment/build-style/perl-module.sh
+++ b/common/environment/build-style/perl-module.sh
@@ -1,4 +1,4 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
-depends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
+depends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/python2-module.sh b/common/environment/build-style/python2-module.sh
index 3a3699bfac0e1..ae51021e4988a 100644
--- a/common/environment/build-style/python2-module.sh
+++ b/common/environment/build-style/python2-module.sh
@@ -1,2 +1,2 @@
 lib32disabled=yes
-makedepends+=" python"
+makedepends+=(python)
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 638f6be9373a4..ce0d9bbeb10e5 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-makedepends+=" python3"
+makedepends+=(python3)
 build_helper+=" python3"
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
index f4faf980f5080..8e22b31966336 100644
--- a/common/environment/build-style/python3-pep517.sh
+++ b/common/environment/build-style/python3-pep517.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" python3-build python3-installer"
+hostmakedepends+=(python3-build python3-installer)
 lib32disabled=yes
 build_helper+=" python3"
diff --git a/common/environment/build-style/raku-dist.sh b/common/environment/build-style/raku-dist.sh
index 01dc08fcf6666..c72ff70958056 100644
--- a/common/environment/build-style/raku-dist.sh
+++ b/common/environment/build-style/raku-dist.sh
@@ -1,3 +1,3 @@
-depends+=" rakudo"
-checkdepends+=" perl"
-hostmakedepends+=" rakudo"
+depends+=(rakudo)
+checkdepends+=(perl)
+hostmakedepends+=(rakudo)
diff --git a/common/environment/build-style/scons.sh b/common/environment/build-style/scons.sh
index 614fb2c04bee6..bf5c972a4e260 100644
--- a/common/environment/build-style/scons.sh
+++ b/common/environment/build-style/scons.sh
@@ -1 +1 @@
-hostmakedepends+=" scons"
+hostmakedepends+=(scons)
diff --git a/common/environment/build-style/texmf.sh b/common/environment/build-style/texmf.sh
index b0ecf4702fe78..b883273531c2f 100644
--- a/common/environment/build-style/texmf.sh
+++ b/common/environment/build-style/texmf.sh
@@ -1,4 +1,4 @@
 # rsync isn't needed for everything but it's far easier to just put it here
-hostmakedepends+=" rsync"
+hostmakedepends+=(rsync)
 # python_version isn't needed for everything either
 python_version=3
diff --git a/common/environment/build-style/waf.sh b/common/environment/build-style/waf.sh
index f5deafbf00cab..2831340bf35a3 100644
--- a/common/environment/build-style/waf.sh
+++ b/common/environment/build-style/waf.sh
@@ -1 +1 @@
-hostmakedepends+=" python"
+hostmakedepends+=(python)
diff --git a/common/environment/build-style/waf3.sh b/common/environment/build-style/waf3.sh
index 471e0dae2d36a..8efbd8ae579c2 100644
--- a/common/environment/build-style/waf3.sh
+++ b/common/environment/build-style/waf3.sh
@@ -1 +1 @@
-hostmakedepends+=" python3"
+hostmakedepends+=(python3)
diff --git a/common/environment/build-style/zig-build.sh b/common/environment/build-style/zig-build.sh
index 049b7cd437d53..6af7f8335e629 100644
--- a/common/environment/build-style/zig-build.sh
+++ b/common/environment/build-style/zig-build.sh
@@ -1 +1 @@
-hostmakedepends+=" zig"
+hostmakedepends+=(zig)
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 20f61528d14c2..aa2ddd04d03a2 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -9,16 +9,17 @@ setup_pkg_depends() {
             ${pkg}_package
         fi
     elif [[ $with_subpkgs ]]; then
-        collected="${depends}"
+        collected=("${depends[@]}")
         for pkg in $subpackages; do
             [[ $pkg ]] || continue
             ${pkg}_package
-            collected+=" ${depends}"
+            ensure_array_subpkg "$pkg" depends
+            collected+=("${depends[@]}")
         done
-        depends="${collected}"
+        depends=("${collected[@]}")
     fi
 
-    for j in ${depends}; do
+    for j in "${depends[@]}"; do
         _rpkgname="${j%\?*}"
         _depname="${j#*\?}"
         if [[ ${_rpkgname} == virtual ]]; then
@@ -158,10 +159,10 @@ install_pkg_deps() {
     #
     # Host build dependencies.
     #
-    if [[ ${hostmakedepends} ]]; then
+    if [ "${#hostmakedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${hostmakedepends}; do
+        for f in "${hostmakedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -208,10 +209,10 @@ install_pkg_deps() {
     #
     # Host check dependencies.
     #
-    if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
+    if [ ${#checkdepends[@]} -gt 0 ] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
         templates=""
         # check validity
-        for f in ${checkdepends}; do
+        for f in "${checkdepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -258,10 +259,10 @@ install_pkg_deps() {
     #
     # Target build dependencies.
     #
-    if [[ ${makedepends} ]]; then
+    if [ ${#makedepends[@]} -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${makedepends}; do
+        for f in "${makedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 5c6a79fbda7eb..e3684ab924d85 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -540,7 +540,7 @@ setup_pkg() {
         fi
     fi
 
-    for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
+    for x in "${hostmakedepends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
         if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
             msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
         fi
@@ -593,6 +593,8 @@ setup_pkg() {
 
     set_build_options
 
+    ensure_array hostmakedepends makedepends checkdepends depends
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/consistency_check.sh b/common/xbps-src/shutils/consistency_check.sh
index 6a5b2ec199757..fe892839acad9 100644
--- a/common/xbps-src/shutils/consistency_check.sh
+++ b/common/xbps-src/shutils/consistency_check.sh
@@ -69,12 +69,12 @@ consistency_check() {
         XBPS_TARGET_PKG=${pkg##*/}
         (
             read_pkg
-            [ "$depends" ] && printf "%s $pkgname depends\n" $depends
+            [ "${#depends[@]}" -gt 0 ] && printf "%s $pkgname depends\n" "${depends[*]}"
             [ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
             [ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
-            [ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
-            [ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
-            [ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
+            [ "${#makedepends[@]}" -gt 0 ] && printf "%s $pkgname makedepends\n" "${makedepends[*]}"
+            [ "${#hostmakedepends[@]}" -gt 0 ] && printf "%s $pkgname hostmakedepends\n" "${hostmakedepends[*]}"
+            [ "${#checkdepends[@]}" -gt 0 ] && printf "%s $pkgname checkdepends\n" "${checkdepends[*]}"
         )
     done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
         consistency_convert_pkgname | consistency_check_smart
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 0cab761f1215c..d44c2c7c97a8e 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -150,15 +150,15 @@ show_pkg_build_depends() {
 }
 
 show_pkg_build_deps() {
-    show_pkg_build_depends "${makedepends} $(setup_pkg_depends '' 1 1)" "${hostmakedepends}"
+    show_pkg_build_depends "${makedepends[*]} $(setup_pkg_depends '' 1 1)" "${hostmakedepends[*]}"
 }
 
 show_pkg_hostmakedepends() {
-    show_pkg_build_depends "" "${hostmakedepends}"
+    show_pkg_build_depends "" "${hostmakedepends[*]}"
 }
 
 show_pkg_makedepends() {
-    show_pkg_build_depends "${makedepends}" ""
+    show_pkg_build_depends "${makedepends[*]}" ""
 }
 
 show_pkg_build_options() {

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (29 preceding siblings ...)
  2023-11-02 16:31 ` [PR PATCH] [Updated] " classabbyamp
@ 2023-11-02 16:44 ` classabbyamp
  2024-02-01  1:45 ` github-actions
                   ` (2 subsequent siblings)
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2023-11-02 16:44 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 37834 bytes --]

From 942c92c999af9bd6b31bfd3af22599c931f42ee4 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:31:56 -0400
Subject: [PATCH 1/4] common/xbps-src/shutils/common: add functions for arrays
 in templates

`ensure_array` will ensure the named variables are arrays if defined.
This allows us to not need to convert all packages to arrays
immediately, as they can be migrated the next time someone builds them.

`ensure_array_subpkg` does the same thing as `ensure_array`, but is also
passed the subpkg for better error message context.

`array_contains` is a helper function to make checking if an array
contains a value easier.
---
 common/xbps-src/shutils/common.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 04247942decf2..5c6a79fbda7eb 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -286,6 +286,31 @@ source_file() {
     fi
 }
 
+ensure_array() {
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' should be an array!\n"
+        fi
+    done
+}
+
+ensure_array_subpkg() {
+    local subpkg="$1"
+    shift 1
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' in subpkg '$subpkg' should be an array!\n"
+        fi
+    done
+}
+
+array_contains() {
+    local arr="$1" val="$2"
+    printf '%s\0' "${!arr[@]}" | grep -Fxqz "$val"
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 

From f3f3faeebe596df7aacc5a5357da07b8fe3b7945 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:37:35 -0400
Subject: [PATCH 2/4] common/xbps-src/shutils/show: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 6ae0f4e6d7df2..0cab761f1215c 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From c9508ddcd7069669d2564a6db27197646a6eccdc Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:52:47 -0400
Subject: [PATCH 3/4] common: {hostmake,make,check,}depends to array

---
 common/build-helper/gir.sh                    | 16 +++++++-------
 common/build-helper/numpy.sh                  |  8 +++----
 common/build-helper/qemu.sh                   |  4 ++--
 common/environment/build-style/R-cran.sh      |  4 ++--
 common/environment/build-style/cargo.sh       |  6 +++---
 common/environment/build-style/cmake.sh       |  4 ++--
 common/environment/build-style/gem.sh         |  4 ++--
 common/environment/build-style/gemspec.sh     |  4 ++--
 common/environment/build-style/go.sh          |  4 ++--
 .../environment/build-style/haskell-stack.sh  |  2 +-
 common/environment/build-style/meson.sh       |  2 +-
 .../build-style/perl-ModuleBuild.sh           |  4 ++--
 common/environment/build-style/perl-module.sh |  6 +++---
 .../environment/build-style/python2-module.sh |  2 +-
 .../environment/build-style/python3-module.sh |  2 +-
 .../environment/build-style/python3-pep517.sh |  2 +-
 common/environment/build-style/raku-dist.sh   |  6 +++---
 common/environment/build-style/scons.sh       |  2 +-
 common/environment/build-style/texmf.sh       |  2 +-
 common/environment/build-style/waf.sh         |  2 +-
 common/environment/build-style/waf3.sh        |  2 +-
 common/environment/build-style/zig-build.sh   |  2 +-
 common/xbps-src/shutils/build_dependencies.sh | 21 ++++++++++---------
 common/xbps-src/shutils/common.sh             |  4 +++-
 common/xbps-src/shutils/consistency_check.sh  |  8 +++----
 common/xbps-src/shutils/show.sh               |  6 +++---
 26 files changed, 66 insertions(+), 63 deletions(-)

diff --git a/common/build-helper/gir.sh b/common/build-helper/gir.sh
index 70699adb17973..93ae649572ee9 100644
--- a/common/build-helper/gir.sh
+++ b/common/build-helper/gir.sh
@@ -8,24 +8,24 @@
 # Check if the 'gir' build_option is set or if there is no
 # 'gir' build_option.
 if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
-	if [[ $hostmakedepends != *"gobject-introspection"* ]]; then
+	if ! array_contains hostmakedepends "gobject-introspection"; then
 		# Provide the host tooling, g-ir-scanner, g-ir-compiler
 		# and its wrappers.
-		hostmakedepends+=" gobject-introspection"
+		hostmakedepends+=(gobject-introspection)
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
 		# Required for running binaries produced from g-ir-compiler
 		# via g-ir-scanner-qemuwrapper
-		hostmakedepends+=" qemu-user-static"
+		hostmakedepends+=(qemu-user-static)
 
 		# Required for running the g-ir-scanner-lddwrapper
-		hostmakedepends+=" prelink-cross"
+		hostmakedepends+=(prelink-cross)
 
-		if [[ $makedepends != *"gobject-introspection"* ]]; then
+		if ! array_contains makedepends "gobject-introspection"; then
 			# Provide basic .gir types like GLib, GObject, DBus, Gio, cairo
 			# and tooling like g-ir-compiler
-			makedepends+=" gobject-introspection"
+			makedepends+=(gobject-introspection)
 		fi
 
 		export VAPIGEN_VAPIDIRS=${XBPS_CROSS_BASE}/usr/share/vala/vapi
@@ -33,8 +33,8 @@ if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
 
 		# Provide some packages in hostmakedepends if they are in makedepends
 		for f in gtk+3-devel python3-gobject-devel; do
-			if [[ $makedepends == *"${f}"* ]]; then
-				hostmakedepends+=" ${f}"
+			if array_contains makedepends "${f}"; then
+				hostmakedepends+=("${f}")
 			fi
 		done
 		unset f
diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh
index e0856dbca7cf3..801a7dcc41f4f 100644
--- a/common/build-helper/numpy.sh
+++ b/common/build-helper/numpy.sh
@@ -7,14 +7,14 @@
 
 # Even for cross compilation, numpy should be available on the host to ensure
 # that the host interpreter doesn't complain about missing deps
-if [[ $hostmakedepends != *"python3-numpy"* ]]; then
-	hostmakedepends+=" python3-numpy"
+if ! array_contains hostmakedepends "python3-numpy"; then
+	hostmakedepends+=(python3-numpy)
 fi
 
 [ -z "$CROSS_BUILD" ] && return 0
 
-if [[ $makedepends != *"python3-numpy"* ]]; then
-	makedepends+=" python3-numpy"
+if ! array_contains makedepends "python3-numpy"; then
+	makedepends+=(python3-numpy)
 fi
 
 # python3-setuptools finds numpy libs and headers on the host first;
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index d6a4342f5e8ee..5cbb3a6c8e654 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -1,7 +1,7 @@
 if [ "$CROSS_BUILD" ]; then
 	export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-	if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
-		hostmakedepends+=" qemu-user-static"
+	if ! array_contains hostmakedepends "qemu-user-static"; then
+		hostmakedepends+=(qemu-user-static)
 	fi
 fi
 
diff --git a/common/environment/build-style/R-cran.sh b/common/environment/build-style/R-cran.sh
index 0cb7c906f952a..6f1ab94ed59f3 100644
--- a/common/environment/build-style/R-cran.sh
+++ b/common/environment/build-style/R-cran.sh
@@ -1,5 +1,5 @@
-makedepends+=" R"
-depends+=" R"
+makedepends+=(R)
+depends+=(R)
 create_wrksrc=required
 build_wrksrc="${pkgname#R-cran-}"
 
diff --git a/common/environment/build-style/cargo.sh b/common/environment/build-style/cargo.sh
index 473750c7a359e..e96171cd5b067 100644
--- a/common/environment/build-style/cargo.sh
+++ b/common/environment/build-style/cargo.sh
@@ -1,11 +1,11 @@
-hostmakedepends+=" cargo"
+hostmakedepends+=(cargo)
 
 if ! [[ "$pkgname" =~ ^cargo-auditable(-bootstrap)?$ ]]; then
-	hostmakedepends+=" cargo-auditable"
+	hostmakedepends+=(cargo-auditable)
 fi
 
 if [ "$CROSS_BUILD" ]; then
-	makedepends+=" rust-std"
+	makedepends+=(rust-std)
 fi
 
 build_helper+=" rust"
diff --git a/common/environment/build-style/cmake.sh b/common/environment/build-style/cmake.sh
index 1c5386e1c46c1..992721ba9f814 100644
--- a/common/environment/build-style/cmake.sh
+++ b/common/environment/build-style/cmake.sh
@@ -1,9 +1,9 @@
 if [ "$CHROOT_READY" ]; then
 	if [ "$pkgname" != cmake-bootstrap ]; then
-		hostmakedepends+=" cmake-bootstrap"
+		hostmakedepends+=(cmake-bootstrap)
 	fi
 	if [ "${make_cmd:-ninja}" = ninja ]; then
-		hostmakedepends+=" ninja"
+		hostmakedepends+=(ninja)
 	fi
 fi
 
diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh
index 73a97bda7d8b2..8ef38cc779162 100644
--- a/common/environment/build-style/gem.sh
+++ b/common/environment/build-style/gem.sh
@@ -1,6 +1,6 @@
 lib32disabled=yes
-hostmakedepends+=" ruby"
-depends+=" ruby"
+hostmakedepends+=(ruby)
+depends+=(ruby)
 
 # default to rubygems
 if [ -z "$distfiles" ]; then
diff --git a/common/environment/build-style/gemspec.sh b/common/environment/build-style/gemspec.sh
index b3025a9ec47e9..2536da11cd46f 100644
--- a/common/environment/build-style/gemspec.sh
+++ b/common/environment/build-style/gemspec.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-hostmakedepends+=" ruby-devel"
-makedepends+=" ruby-devel"
+hostmakedepends+=(ruby-devel)
+makedepends+=(ruby-devel)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b..c58b297891cf6 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,9 @@
-if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
+if [ "${#hostmakedepends[@]}" -eq 0 ] || ! array_contains hostmakedepends "gcc-go-tools"; then
 	# gc compiler
 	if [ -z "$archs" ]; then
 		archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
 	fi
-	hostmakedepends+=" go"
+	hostmakedepends+=(go)
 	nopie=yes
 else
 	# gccgo compiler
diff --git a/common/environment/build-style/haskell-stack.sh b/common/environment/build-style/haskell-stack.sh
index 6b47c12151237..02d5dc63002fd 100644
--- a/common/environment/build-style/haskell-stack.sh
+++ b/common/environment/build-style/haskell-stack.sh
@@ -1 +1 @@
-hostmakedepends+=" ghc stack"
+hostmakedepends+=(ghc stack)
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index dbfe93700f691..2b5726f3dc057 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1,2 +1,2 @@
-hostmakedepends+=" meson"
+hostmakedepends+=(meson)
 build_helper+=" meson"
diff --git a/common/environment/build-style/perl-ModuleBuild.sh b/common/environment/build-style/perl-ModuleBuild.sh
index 60d677131479a..59ba553b1d4b8 100644
--- a/common/environment/build-style/perl-ModuleBuild.sh
+++ b/common/environment/build-style/perl-ModuleBuild.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/perl-module.sh b/common/environment/build-style/perl-module.sh
index 300ed9b5db616..cb56eb3ab0cad 100644
--- a/common/environment/build-style/perl-module.sh
+++ b/common/environment/build-style/perl-module.sh
@@ -1,4 +1,4 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
-depends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
+depends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/python2-module.sh b/common/environment/build-style/python2-module.sh
index 3a3699bfac0e1..ae51021e4988a 100644
--- a/common/environment/build-style/python2-module.sh
+++ b/common/environment/build-style/python2-module.sh
@@ -1,2 +1,2 @@
 lib32disabled=yes
-makedepends+=" python"
+makedepends+=(python)
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 638f6be9373a4..ce0d9bbeb10e5 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-makedepends+=" python3"
+makedepends+=(python3)
 build_helper+=" python3"
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
index f4faf980f5080..8e22b31966336 100644
--- a/common/environment/build-style/python3-pep517.sh
+++ b/common/environment/build-style/python3-pep517.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" python3-build python3-installer"
+hostmakedepends+=(python3-build python3-installer)
 lib32disabled=yes
 build_helper+=" python3"
diff --git a/common/environment/build-style/raku-dist.sh b/common/environment/build-style/raku-dist.sh
index 01dc08fcf6666..c72ff70958056 100644
--- a/common/environment/build-style/raku-dist.sh
+++ b/common/environment/build-style/raku-dist.sh
@@ -1,3 +1,3 @@
-depends+=" rakudo"
-checkdepends+=" perl"
-hostmakedepends+=" rakudo"
+depends+=(rakudo)
+checkdepends+=(perl)
+hostmakedepends+=(rakudo)
diff --git a/common/environment/build-style/scons.sh b/common/environment/build-style/scons.sh
index 614fb2c04bee6..bf5c972a4e260 100644
--- a/common/environment/build-style/scons.sh
+++ b/common/environment/build-style/scons.sh
@@ -1 +1 @@
-hostmakedepends+=" scons"
+hostmakedepends+=(scons)
diff --git a/common/environment/build-style/texmf.sh b/common/environment/build-style/texmf.sh
index b0ecf4702fe78..b883273531c2f 100644
--- a/common/environment/build-style/texmf.sh
+++ b/common/environment/build-style/texmf.sh
@@ -1,4 +1,4 @@
 # rsync isn't needed for everything but it's far easier to just put it here
-hostmakedepends+=" rsync"
+hostmakedepends+=(rsync)
 # python_version isn't needed for everything either
 python_version=3
diff --git a/common/environment/build-style/waf.sh b/common/environment/build-style/waf.sh
index f5deafbf00cab..2831340bf35a3 100644
--- a/common/environment/build-style/waf.sh
+++ b/common/environment/build-style/waf.sh
@@ -1 +1 @@
-hostmakedepends+=" python"
+hostmakedepends+=(python)
diff --git a/common/environment/build-style/waf3.sh b/common/environment/build-style/waf3.sh
index 471e0dae2d36a..8efbd8ae579c2 100644
--- a/common/environment/build-style/waf3.sh
+++ b/common/environment/build-style/waf3.sh
@@ -1 +1 @@
-hostmakedepends+=" python3"
+hostmakedepends+=(python3)
diff --git a/common/environment/build-style/zig-build.sh b/common/environment/build-style/zig-build.sh
index 049b7cd437d53..6af7f8335e629 100644
--- a/common/environment/build-style/zig-build.sh
+++ b/common/environment/build-style/zig-build.sh
@@ -1 +1 @@
-hostmakedepends+=" zig"
+hostmakedepends+=(zig)
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 20f61528d14c2..aa2ddd04d03a2 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -9,16 +9,17 @@ setup_pkg_depends() {
             ${pkg}_package
         fi
     elif [[ $with_subpkgs ]]; then
-        collected="${depends}"
+        collected=("${depends[@]}")
         for pkg in $subpackages; do
             [[ $pkg ]] || continue
             ${pkg}_package
-            collected+=" ${depends}"
+            ensure_array_subpkg "$pkg" depends
+            collected+=("${depends[@]}")
         done
-        depends="${collected}"
+        depends=("${collected[@]}")
     fi
 
-    for j in ${depends}; do
+    for j in "${depends[@]}"; do
         _rpkgname="${j%\?*}"
         _depname="${j#*\?}"
         if [[ ${_rpkgname} == virtual ]]; then
@@ -158,10 +159,10 @@ install_pkg_deps() {
     #
     # Host build dependencies.
     #
-    if [[ ${hostmakedepends} ]]; then
+    if [ "${#hostmakedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${hostmakedepends}; do
+        for f in "${hostmakedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -208,10 +209,10 @@ install_pkg_deps() {
     #
     # Host check dependencies.
     #
-    if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
+    if [ ${#checkdepends[@]} -gt 0 ] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
         templates=""
         # check validity
-        for f in ${checkdepends}; do
+        for f in "${checkdepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -258,10 +259,10 @@ install_pkg_deps() {
     #
     # Target build dependencies.
     #
-    if [[ ${makedepends} ]]; then
+    if [ ${#makedepends[@]} -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${makedepends}; do
+        for f in "${makedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 5c6a79fbda7eb..e3684ab924d85 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -540,7 +540,7 @@ setup_pkg() {
         fi
     fi
 
-    for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
+    for x in "${hostmakedepends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
         if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
             msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
         fi
@@ -593,6 +593,8 @@ setup_pkg() {
 
     set_build_options
 
+    ensure_array hostmakedepends makedepends checkdepends depends
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/consistency_check.sh b/common/xbps-src/shutils/consistency_check.sh
index 6a5b2ec199757..fe892839acad9 100644
--- a/common/xbps-src/shutils/consistency_check.sh
+++ b/common/xbps-src/shutils/consistency_check.sh
@@ -69,12 +69,12 @@ consistency_check() {
         XBPS_TARGET_PKG=${pkg##*/}
         (
             read_pkg
-            [ "$depends" ] && printf "%s $pkgname depends\n" $depends
+            [ "${#depends[@]}" -gt 0 ] && printf "%s $pkgname depends\n" "${depends[*]}"
             [ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
             [ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
-            [ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
-            [ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
-            [ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
+            [ "${#makedepends[@]}" -gt 0 ] && printf "%s $pkgname makedepends\n" "${makedepends[*]}"
+            [ "${#hostmakedepends[@]}" -gt 0 ] && printf "%s $pkgname hostmakedepends\n" "${hostmakedepends[*]}"
+            [ "${#checkdepends[@]}" -gt 0 ] && printf "%s $pkgname checkdepends\n" "${checkdepends[*]}"
         )
     done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
         consistency_convert_pkgname | consistency_check_smart
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 0cab761f1215c..d44c2c7c97a8e 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -150,15 +150,15 @@ show_pkg_build_depends() {
 }
 
 show_pkg_build_deps() {
-    show_pkg_build_depends "${makedepends} $(setup_pkg_depends '' 1 1)" "${hostmakedepends}"
+    show_pkg_build_depends "${makedepends[*]} $(setup_pkg_depends '' 1 1)" "${hostmakedepends[*]}"
 }
 
 show_pkg_hostmakedepends() {
-    show_pkg_build_depends "" "${hostmakedepends}"
+    show_pkg_build_depends "" "${hostmakedepends[*]}"
 }
 
 show_pkg_makedepends() {
-    show_pkg_build_depends "${makedepends}" ""
+    show_pkg_build_depends "${makedepends[*]}" ""
 }
 
 show_pkg_build_options() {

From 66d35a432e1d2c1beb44bd2550c227796cd0e52d Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 12:44:18 -0400
Subject: [PATCH 4/4] common: configure_args to array

---
 common/build-helper/cmake-wxWidgets-gtk3.sh      |  2 +-
 common/build-style/cargo.sh                      |  6 +++---
 common/build-style/cmake.sh                      |  4 ++--
 common/build-style/configure.sh                  |  2 +-
 common/build-style/gemspec.sh                    |  2 +-
 common/build-style/gnu-configure.sh              |  2 +-
 common/build-style/meson.sh                      |  4 ++--
 common/build-style/perl-ModuleBuild.sh           |  2 +-
 common/build-style/perl-module.sh                |  2 +-
 common/build-style/qmake.sh                      |  4 ++--
 common/build-style/sip-build.sh                  |  2 +-
 common/build-style/void-cross.sh                 |  4 ++--
 common/build-style/waf.sh                        |  2 +-
 common/build-style/waf3.sh                       |  2 +-
 common/build-style/zig-build.sh                  |  2 +-
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 common/xbps-src/shutils/common.sh                |  3 ++-
 common/xbps-src/shutils/show.sh                  |  2 +-
 18 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/common/build-helper/cmake-wxWidgets-gtk3.sh b/common/build-helper/cmake-wxWidgets-gtk3.sh
index 7d813dc5f9538..ffa4ebd90e71e 100644
--- a/common/build-helper/cmake-wxWidgets-gtk3.sh
+++ b/common/build-helper/cmake-wxWidgets-gtk3.sh
@@ -3,4 +3,4 @@ if [ "$CROSS_BUILD" ]; then
 else
 	export WX_CONFIG=/usr/bin/wx-config-gtk3
 fi
-configure_args+=" -DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG} "
+configure_args+=("-DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG}")
diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 751911d8dbee8..c080a65ad71ca 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,14 +5,14 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --locked --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --locked --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
 	${make_check_pre} ${make_cmd} test --release --locked --target ${RUST_TARGET} \
-		${configure_args} ${make_check_args}
+		"${configure_args[@]}" ${make_check_args}
 }
 
 do_install() {
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 124ed354eff67..3adbba4db263b 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -75,7 +75,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e8..9b472ca28ccc2 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45a..0ed948dbff0e5 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f79..b89008875a894 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index 5ea2eeda40097..9f1abed904a79 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -8,7 +8,7 @@ do_configure() {
 	: ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -39,7 +39,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4cf..5efa8484068e4 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe11..2bcfda7430833 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606ef..1f79fd42d55ce 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf0..42b5b2bff1912 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index 2e8ebb52ceaf9..bcd6cece5eadf 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -442,7 +442,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b179..2b3b6eb03c9df 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7f..455b043ebfa39 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f8..e2d02fb11b7f2 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {
diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index 1a552b5074a07..06974323cf94f 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index e3684ab924d85..cdfa462715f1d 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -593,7 +593,8 @@ setup_pkg() {
 
     set_build_options
 
-    ensure_array hostmakedepends makedepends checkdepends depends
+    ensure_array hostmakedepends makedepends checkdepends depends \
+        configure_args
 
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index d44c2c7c97a8e..8c880a08721c6 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -13,7 +13,7 @@ show_pkg() {
     show_pkg_var no "Changelog" "$changelog"
     show_pkg_var no "build_style" "$build_style"
     show_pkg_var st "build_helper" "$build_helper"
-    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var ar "configure_args" "${configure_args[@]}"
     show_pkg_var no "short_desc" "$short_desc"
     show_pkg_var st "subpackages" "$subpackages"
     set -f

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (30 preceding siblings ...)
  2023-11-02 16:44 ` classabbyamp
@ 2024-02-01  1:45 ` github-actions
  2024-03-17  2:13 ` [PR PATCH] [Updated] " classabbyamp
  2024-03-17  2:31 ` classabbyamp
  33 siblings, 0 replies; 35+ messages in thread
From: github-actions @ 2024-02-01  1:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 305 bytes --]

New comment by github-actions[bot] on void-packages repository

https://github.com/void-linux/void-packages/pull/42656#issuecomment-1920338462

Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that.  If this pull request is still relevant bump it or assign it.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (31 preceding siblings ...)
  2024-02-01  1:45 ` github-actions
@ 2024-03-17  2:13 ` classabbyamp
  2024-03-17  2:31 ` classabbyamp
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2024-03-17  2:13 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 37423 bytes --]

From 5f6304588e0be95684c0dab4e26e4735666a7a29 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:31:56 -0400
Subject: [PATCH 1/4] common/xbps-src/shutils/common: add functions for arrays
 in templates

`ensure_array` will ensure the named variables are arrays if defined.
This allows us to not need to convert all packages to arrays
immediately, as they can be migrated the next time someone builds them.

`ensure_array_subpkg` does the same thing as `ensure_array`, but is also
passed the subpkg for better error message context.

`array_contains` is a helper function to make checking if an array
contains a value easier.
---
 common/xbps-src/shutils/common.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 86d91fdf50796a..50c6ebf9aef8ad 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -302,6 +302,31 @@ source_file() {
     fi
 }
 
+ensure_array() {
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' should be an array!\n"
+        fi
+    done
+}
+
+ensure_array_subpkg() {
+    local subpkg="$1"
+    shift 1
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' in subpkg '$subpkg' should be an array!\n"
+        fi
+    done
+}
+
+array_contains() {
+    local arr="$1" val="$2"
+    printf '%s\0' "${!arr[@]}" | grep -Fxqz "$val"
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 

From ba19cd8c48bf8da51526d56a7c9c6c6aed30dc37 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:37:35 -0400
Subject: [PATCH 2/4] common/xbps-src/shutils/show: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 4671a1317449b1..b1f938a8f96a11 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From fd7cd1484852f4c96292c887185b7e60a53cb2f2 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:52:47 -0400
Subject: [PATCH 3/4] common: {hostmake,make,check,}depends to array

---
 common/build-helper/gir.sh                    | 16 +++++++-------
 common/build-helper/numpy.sh                  |  8 +++----
 common/build-helper/qemu.sh                   |  4 ++--
 common/environment/build-style/R-cran.sh      |  4 ++--
 common/environment/build-style/cargo.sh       |  6 +++---
 common/environment/build-style/cmake.sh       |  4 ++--
 common/environment/build-style/gem.sh         |  4 ++--
 common/environment/build-style/gemspec.sh     |  4 ++--
 common/environment/build-style/go.sh          |  4 ++--
 .../environment/build-style/haskell-stack.sh  |  2 +-
 common/environment/build-style/meson.sh       |  2 +-
 .../build-style/perl-ModuleBuild.sh           |  4 ++--
 common/environment/build-style/perl-module.sh |  6 +++---
 .../environment/build-style/python2-module.sh |  2 +-
 .../environment/build-style/python3-module.sh |  2 +-
 .../environment/build-style/python3-pep517.sh |  2 +-
 common/environment/build-style/raku-dist.sh   |  6 +++---
 common/environment/build-style/scons.sh       |  2 +-
 common/environment/build-style/waf.sh         |  2 +-
 common/environment/build-style/waf3.sh        |  2 +-
 common/environment/build-style/zig-build.sh   |  2 +-
 common/xbps-src/shutils/build_dependencies.sh | 21 ++++++++++---------
 common/xbps-src/shutils/common.sh             |  4 +++-
 common/xbps-src/shutils/consistency_check.sh  |  8 +++----
 common/xbps-src/shutils/show.sh               |  6 +++---
 25 files changed, 65 insertions(+), 62 deletions(-)

diff --git a/common/build-helper/gir.sh b/common/build-helper/gir.sh
index 70699adb179732..93ae649572ee97 100644
--- a/common/build-helper/gir.sh
+++ b/common/build-helper/gir.sh
@@ -8,24 +8,24 @@
 # Check if the 'gir' build_option is set or if there is no
 # 'gir' build_option.
 if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
-	if [[ $hostmakedepends != *"gobject-introspection"* ]]; then
+	if ! array_contains hostmakedepends "gobject-introspection"; then
 		# Provide the host tooling, g-ir-scanner, g-ir-compiler
 		# and its wrappers.
-		hostmakedepends+=" gobject-introspection"
+		hostmakedepends+=(gobject-introspection)
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
 		# Required for running binaries produced from g-ir-compiler
 		# via g-ir-scanner-qemuwrapper
-		hostmakedepends+=" qemu-user-static"
+		hostmakedepends+=(qemu-user-static)
 
 		# Required for running the g-ir-scanner-lddwrapper
-		hostmakedepends+=" prelink-cross"
+		hostmakedepends+=(prelink-cross)
 
-		if [[ $makedepends != *"gobject-introspection"* ]]; then
+		if ! array_contains makedepends "gobject-introspection"; then
 			# Provide basic .gir types like GLib, GObject, DBus, Gio, cairo
 			# and tooling like g-ir-compiler
-			makedepends+=" gobject-introspection"
+			makedepends+=(gobject-introspection)
 		fi
 
 		export VAPIGEN_VAPIDIRS=${XBPS_CROSS_BASE}/usr/share/vala/vapi
@@ -33,8 +33,8 @@ if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
 
 		# Provide some packages in hostmakedepends if they are in makedepends
 		for f in gtk+3-devel python3-gobject-devel; do
-			if [[ $makedepends == *"${f}"* ]]; then
-				hostmakedepends+=" ${f}"
+			if array_contains makedepends "${f}"; then
+				hostmakedepends+=("${f}")
 			fi
 		done
 		unset f
diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh
index e0856dbca7cf3c..801a7dcc41f4f7 100644
--- a/common/build-helper/numpy.sh
+++ b/common/build-helper/numpy.sh
@@ -7,14 +7,14 @@
 
 # Even for cross compilation, numpy should be available on the host to ensure
 # that the host interpreter doesn't complain about missing deps
-if [[ $hostmakedepends != *"python3-numpy"* ]]; then
-	hostmakedepends+=" python3-numpy"
+if ! array_contains hostmakedepends "python3-numpy"; then
+	hostmakedepends+=(python3-numpy)
 fi
 
 [ -z "$CROSS_BUILD" ] && return 0
 
-if [[ $makedepends != *"python3-numpy"* ]]; then
-	makedepends+=" python3-numpy"
+if ! array_contains makedepends "python3-numpy"; then
+	makedepends+=(python3-numpy)
 fi
 
 # python3-setuptools finds numpy libs and headers on the host first;
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index d6a4342f5e8ee3..5cbb3a6c8e6542 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -1,7 +1,7 @@
 if [ "$CROSS_BUILD" ]; then
 	export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-	if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
-		hostmakedepends+=" qemu-user-static"
+	if ! array_contains hostmakedepends "qemu-user-static"; then
+		hostmakedepends+=(qemu-user-static)
 	fi
 fi
 
diff --git a/common/environment/build-style/R-cran.sh b/common/environment/build-style/R-cran.sh
index 0cb7c906f952ac..6f1ab94ed59f3d 100644
--- a/common/environment/build-style/R-cran.sh
+++ b/common/environment/build-style/R-cran.sh
@@ -1,5 +1,5 @@
-makedepends+=" R"
-depends+=" R"
+makedepends+=(R)
+depends+=(R)
 create_wrksrc=required
 build_wrksrc="${pkgname#R-cran-}"
 
diff --git a/common/environment/build-style/cargo.sh b/common/environment/build-style/cargo.sh
index 473750c7a359ea..e96171cd5b0671 100644
--- a/common/environment/build-style/cargo.sh
+++ b/common/environment/build-style/cargo.sh
@@ -1,11 +1,11 @@
-hostmakedepends+=" cargo"
+hostmakedepends+=(cargo)
 
 if ! [[ "$pkgname" =~ ^cargo-auditable(-bootstrap)?$ ]]; then
-	hostmakedepends+=" cargo-auditable"
+	hostmakedepends+=(cargo-auditable)
 fi
 
 if [ "$CROSS_BUILD" ]; then
-	makedepends+=" rust-std"
+	makedepends+=(rust-std)
 fi
 
 build_helper+=" rust"
diff --git a/common/environment/build-style/cmake.sh b/common/environment/build-style/cmake.sh
index 1c5386e1c46c16..992721ba9f814d 100644
--- a/common/environment/build-style/cmake.sh
+++ b/common/environment/build-style/cmake.sh
@@ -1,9 +1,9 @@
 if [ "$CHROOT_READY" ]; then
 	if [ "$pkgname" != cmake-bootstrap ]; then
-		hostmakedepends+=" cmake-bootstrap"
+		hostmakedepends+=(cmake-bootstrap)
 	fi
 	if [ "${make_cmd:-ninja}" = ninja ]; then
-		hostmakedepends+=" ninja"
+		hostmakedepends+=(ninja)
 	fi
 fi
 
diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh
index 73a97bda7d8b28..8ef38cc7791626 100644
--- a/common/environment/build-style/gem.sh
+++ b/common/environment/build-style/gem.sh
@@ -1,6 +1,6 @@
 lib32disabled=yes
-hostmakedepends+=" ruby"
-depends+=" ruby"
+hostmakedepends+=(ruby)
+depends+=(ruby)
 
 # default to rubygems
 if [ -z "$distfiles" ]; then
diff --git a/common/environment/build-style/gemspec.sh b/common/environment/build-style/gemspec.sh
index b3025a9ec47e9d..2536da11cd46f4 100644
--- a/common/environment/build-style/gemspec.sh
+++ b/common/environment/build-style/gemspec.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-hostmakedepends+=" ruby-devel"
-makedepends+=" ruby-devel"
+hostmakedepends+=(ruby-devel)
+makedepends+=(ruby-devel)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b4..c58b297891cf6a 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,9 @@
-if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
+if [ "${#hostmakedepends[@]}" -eq 0 ] || ! array_contains hostmakedepends "gcc-go-tools"; then
 	# gc compiler
 	if [ -z "$archs" ]; then
 		archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
 	fi
-	hostmakedepends+=" go"
+	hostmakedepends+=(go)
 	nopie=yes
 else
 	# gccgo compiler
diff --git a/common/environment/build-style/haskell-stack.sh b/common/environment/build-style/haskell-stack.sh
index 6b47c121512378..02d5dc63002fd9 100644
--- a/common/environment/build-style/haskell-stack.sh
+++ b/common/environment/build-style/haskell-stack.sh
@@ -1 +1 @@
-hostmakedepends+=" ghc stack"
+hostmakedepends+=(ghc stack)
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index dbfe93700f6919..2b5726f3dc0579 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1,2 +1,2 @@
-hostmakedepends+=" meson"
+hostmakedepends+=(meson)
 build_helper+=" meson"
diff --git a/common/environment/build-style/perl-ModuleBuild.sh b/common/environment/build-style/perl-ModuleBuild.sh
index 60d677131479a3..59ba553b1d4b82 100644
--- a/common/environment/build-style/perl-ModuleBuild.sh
+++ b/common/environment/build-style/perl-ModuleBuild.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/perl-module.sh b/common/environment/build-style/perl-module.sh
index 300ed9b5db6166..cb56eb3ab0cadb 100644
--- a/common/environment/build-style/perl-module.sh
+++ b/common/environment/build-style/perl-module.sh
@@ -1,4 +1,4 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
-depends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
+depends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/python2-module.sh b/common/environment/build-style/python2-module.sh
index 3a3699bfac0e17..ae51021e4988a9 100644
--- a/common/environment/build-style/python2-module.sh
+++ b/common/environment/build-style/python2-module.sh
@@ -1,2 +1,2 @@
 lib32disabled=yes
-makedepends+=" python"
+makedepends+=(python)
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 638f6be9373a47..ce0d9bbeb10e51 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-makedepends+=" python3"
+makedepends+=(python3)
 build_helper+=" python3"
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
index f4faf980f5080d..8e22b31966336e 100644
--- a/common/environment/build-style/python3-pep517.sh
+++ b/common/environment/build-style/python3-pep517.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" python3-build python3-installer"
+hostmakedepends+=(python3-build python3-installer)
 lib32disabled=yes
 build_helper+=" python3"
diff --git a/common/environment/build-style/raku-dist.sh b/common/environment/build-style/raku-dist.sh
index 01dc08fcf66660..c72ff709580566 100644
--- a/common/environment/build-style/raku-dist.sh
+++ b/common/environment/build-style/raku-dist.sh
@@ -1,3 +1,3 @@
-depends+=" rakudo"
-checkdepends+=" perl"
-hostmakedepends+=" rakudo"
+depends+=(rakudo)
+checkdepends+=(perl)
+hostmakedepends+=(rakudo)
diff --git a/common/environment/build-style/scons.sh b/common/environment/build-style/scons.sh
index 614fb2c04bee62..bf5c972a4e260f 100644
--- a/common/environment/build-style/scons.sh
+++ b/common/environment/build-style/scons.sh
@@ -1 +1 @@
-hostmakedepends+=" scons"
+hostmakedepends+=(scons)
diff --git a/common/environment/build-style/waf.sh b/common/environment/build-style/waf.sh
index f5deafbf00cabb..2831340bf35a3d 100644
--- a/common/environment/build-style/waf.sh
+++ b/common/environment/build-style/waf.sh
@@ -1 +1 @@
-hostmakedepends+=" python"
+hostmakedepends+=(python)
diff --git a/common/environment/build-style/waf3.sh b/common/environment/build-style/waf3.sh
index 471e0dae2d36a3..8efbd8ae579c26 100644
--- a/common/environment/build-style/waf3.sh
+++ b/common/environment/build-style/waf3.sh
@@ -1 +1 @@
-hostmakedepends+=" python3"
+hostmakedepends+=(python3)
diff --git a/common/environment/build-style/zig-build.sh b/common/environment/build-style/zig-build.sh
index 049b7cd437d538..6af7f8335e629a 100644
--- a/common/environment/build-style/zig-build.sh
+++ b/common/environment/build-style/zig-build.sh
@@ -1 +1 @@
-hostmakedepends+=" zig"
+hostmakedepends+=(zig)
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 57ef45a7d5dd42..dcb9d02673468b 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -9,16 +9,17 @@ setup_pkg_depends() {
             ${pkg}_package
         fi
     elif [[ $with_subpkgs ]]; then
-        collected="${depends}"
+        collected=("${depends[@]}")
         for pkg in $subpackages; do
             [[ $pkg ]] || continue
             ${pkg}_package
-            collected+=" ${depends}"
+            ensure_array_subpkg "$pkg" depends
+            collected+=("${depends[@]}")
         done
-        depends="${collected}"
+        depends=("${collected[@]}")
     fi
 
-    for j in ${depends}; do
+    for j in "${depends[@]}"; do
         _rpkgname="${j%\?*}"
         _depname="${j#*\?}"
         if [[ ${_rpkgname} == virtual ]]; then
@@ -158,10 +159,10 @@ install_pkg_deps() {
     #
     # Host build dependencies.
     #
-    if [[ ${hostmakedepends} ]]; then
+    if [ "${#hostmakedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${hostmakedepends}; do
+        for f in "${hostmakedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -208,10 +209,10 @@ install_pkg_deps() {
     #
     # Host check dependencies.
     #
-    if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
+    if [ ${#checkdepends[@]} -gt 0 ] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
         templates=""
         # check validity
-        for f in ${checkdepends}; do
+        for f in "${checkdepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -258,10 +259,10 @@ install_pkg_deps() {
     #
     # Target build dependencies.
     #
-    if [[ ${makedepends} ]]; then
+    if [ ${#makedepends[@]} -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${makedepends}; do
+        for f in "${makedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 50c6ebf9aef8ad..65b21f336483e2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -556,7 +556,7 @@ setup_pkg() {
         fi
     fi
 
-    for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
+    for x in "${hostmakedepends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
         if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
             msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
         fi
@@ -609,6 +609,8 @@ setup_pkg() {
 
     set_build_options
 
+    ensure_array hostmakedepends makedepends checkdepends depends
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/consistency_check.sh b/common/xbps-src/shutils/consistency_check.sh
index 6a5b2ec1997574..fe892839acad9c 100644
--- a/common/xbps-src/shutils/consistency_check.sh
+++ b/common/xbps-src/shutils/consistency_check.sh
@@ -69,12 +69,12 @@ consistency_check() {
         XBPS_TARGET_PKG=${pkg##*/}
         (
             read_pkg
-            [ "$depends" ] && printf "%s $pkgname depends\n" $depends
+            [ "${#depends[@]}" -gt 0 ] && printf "%s $pkgname depends\n" "${depends[*]}"
             [ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
             [ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
-            [ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
-            [ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
-            [ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
+            [ "${#makedepends[@]}" -gt 0 ] && printf "%s $pkgname makedepends\n" "${makedepends[*]}"
+            [ "${#hostmakedepends[@]}" -gt 0 ] && printf "%s $pkgname hostmakedepends\n" "${hostmakedepends[*]}"
+            [ "${#checkdepends[@]}" -gt 0 ] && printf "%s $pkgname checkdepends\n" "${checkdepends[*]}"
         )
     done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
         consistency_convert_pkgname | consistency_check_smart
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index b1f938a8f96a11..cb2e758643ba2a 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -149,15 +149,15 @@ show_pkg_build_depends() {
 }
 
 show_pkg_build_deps() {
-    show_pkg_build_depends "${makedepends} $(setup_pkg_depends '' 1 1)" "${hostmakedepends}"
+    show_pkg_build_depends "${makedepends[*]} $(setup_pkg_depends '' 1 1)" "${hostmakedepends[*]}"
 }
 
 show_pkg_hostmakedepends() {
-    show_pkg_build_depends "" "${hostmakedepends}"
+    show_pkg_build_depends "" "${hostmakedepends[*]}"
 }
 
 show_pkg_makedepends() {
-    show_pkg_build_depends "${makedepends}" ""
+    show_pkg_build_depends "${makedepends[*]}" ""
 }
 
 show_pkg_build_options() {

From f6398e407463deaf8850477a14bd4d582c721462 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 12:44:18 -0400
Subject: [PATCH 4/4] common: configure_args to array

---
 common/build-helper/cmake-wxWidgets-gtk3.sh      |  2 +-
 common/build-style/cargo.sh                      |  6 +++---
 common/build-style/cmake.sh                      |  4 ++--
 common/build-style/configure.sh                  |  2 +-
 common/build-style/gemspec.sh                    |  2 +-
 common/build-style/gnu-configure.sh              |  2 +-
 common/build-style/meson.sh                      |  4 ++--
 common/build-style/perl-ModuleBuild.sh           |  2 +-
 common/build-style/perl-module.sh                |  2 +-
 common/build-style/qmake.sh                      |  4 ++--
 common/build-style/sip-build.sh                  |  2 +-
 common/build-style/void-cross.sh                 |  4 ++--
 common/build-style/waf.sh                        |  2 +-
 common/build-style/waf3.sh                       |  2 +-
 common/build-style/zig-build.sh                  |  2 +-
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 common/xbps-src/shutils/common.sh                |  3 ++-
 common/xbps-src/shutils/show.sh                  |  2 +-
 18 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/common/build-helper/cmake-wxWidgets-gtk3.sh b/common/build-helper/cmake-wxWidgets-gtk3.sh
index 7d813dc5f9538c..ffa4ebd90e71e7 100644
--- a/common/build-helper/cmake-wxWidgets-gtk3.sh
+++ b/common/build-helper/cmake-wxWidgets-gtk3.sh
@@ -3,4 +3,4 @@ if [ "$CROSS_BUILD" ]; then
 else
 	export WX_CONFIG=/usr/bin/wx-config-gtk3
 fi
-configure_args+=" -DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG} "
+configure_args+=("-DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG}")
diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 751911d8dbee8d..c080a65ad71ca6 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,14 +5,14 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --locked --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --locked --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
 	${make_check_pre} ${make_cmd} test --release --locked --target ${RUST_TARGET} \
-		${configure_args} ${make_check_args}
+		"${configure_args[@]}" ${make_check_args}
 }
 
 do_install() {
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 124ed354eff674..3adbba4db263b2 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=("-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake")
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -75,7 +75,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e8f..9b472ca28ccc20 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45a3..0ed948dbff0e57 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f79c..b89008875a894a 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index 5ea2eeda40097d..9f1abed904a797 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -8,7 +8,7 @@ do_configure() {
 	: ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -39,7 +39,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4cf0..5efa8484068e48 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe11e..2bcfda7430833f 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606eff..1f79fd42d55ced 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf09..42b5b2bff19122 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index d94e90cbb133c4..7b792abb0d7bbb 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -438,7 +438,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b1797..2b3b6eb03c9df9 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7f3..455b043ebfa398 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f8c..e2d02fb11b7f27 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {
diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index 1a552b5074a076..06974323cf94fd 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 65b21f336483e2..9374feacb5cccd 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -609,7 +609,8 @@ setup_pkg() {
 
     set_build_options
 
-    ensure_array hostmakedepends makedepends checkdepends depends
+    ensure_array hostmakedepends makedepends checkdepends depends \
+        configure_args
 
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index cb2e758643ba2a..c700ae2a8e5b53 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -13,7 +13,7 @@ show_pkg() {
     show_pkg_var no "Changelog" "$changelog"
     show_pkg_var no "build_style" "$build_style"
     show_pkg_var st "build_helper" "$build_helper"
-    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var ar "configure_args" "${configure_args[@]}"
     show_pkg_var no "short_desc" "$short_desc"
     show_pkg_var st "subpackages" "$subpackages"
     set -f

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
  2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
                   ` (32 preceding siblings ...)
  2024-03-17  2:13 ` [PR PATCH] [Updated] " classabbyamp
@ 2024-03-17  2:31 ` classabbyamp
  33 siblings, 0 replies; 35+ messages in thread
From: classabbyamp @ 2024-03-17  2:31 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1181 bytes --]

There is an updated pull request by classabbyamp against master on the void-packages repository

https://github.com/classabbyamp/void-packages declare-a
https://github.com/void-linux/void-packages/pull/42656

[RFC] [WIP] use bash arrays for some template fields
this will allow select variables to be defined as arrays or strings. if a string is specified, it will be converted to an array for internal usage. if it is an array, it passes through untouched. this should allow for a smooth transition to using more arrays inside xbps-src, and should solve issues with shell quoting in things like configure_args, make_check_args, etc.

to start, I've only done this with configure_args, and fixed *some* templates

would like to get some feedback before continuing, as this will be a fairly massive undertaking. what fields would be valuable as arrays? (I'm thinking mostly the `*_args` variables) should the internal string -> array conversion happen or should we just go all-in?

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

[ci skip]


A patch file from https://github.com/void-linux/void-packages/pull/42656.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-declare-a-42656.patch --]
[-- Type: text/x-diff, Size: 37425 bytes --]

From 5f6304588e0be95684c0dab4e26e4735666a7a29 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:31:56 -0400
Subject: [PATCH 1/4] common/xbps-src/shutils/common: add functions for arrays
 in templates

`ensure_array` will ensure the named variables are arrays if defined.
This allows us to not need to convert all packages to arrays
immediately, as they can be migrated the next time someone builds them.

`ensure_array_subpkg` does the same thing as `ensure_array`, but is also
passed the subpkg for better error message context.

`array_contains` is a helper function to make checking if an array
contains a value easier.
---
 common/xbps-src/shutils/common.sh | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 86d91fdf50796a..50c6ebf9aef8ad 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -302,6 +302,31 @@ source_file() {
     fi
 }
 
+ensure_array() {
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' should be an array!\n"
+        fi
+    done
+}
+
+ensure_array_subpkg() {
+    local subpkg="$1"
+    shift 1
+    for name; do
+        # if the name is not "", is set, and is not an array
+        if [[ -n "$name" && -v "$name" && "${!name@a}" != *a* ]]; then
+            msg_error "template variable '$name' in subpkg '$subpkg' should be an array!\n"
+        fi
+    done
+}
+
+array_contains() {
+    local arr="$1" val="$2"
+    printf '%s\0' "${!arr[@]}" | grep -Fxqz "$val"
+}
+
 run_pkg_hooks() {
     local phase="$1" hookn f
 

From ba19cd8c48bf8da51526d56a7c9c6c6aed30dc37 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:37:35 -0400
Subject: [PATCH 2/4] common/xbps-src/shutils/show: refactor show_pkg_var to
 support arrays

---
 common/xbps-src/shutils/show.sh | 89 ++++++++++++++++++++++-----------
 1 file changed, 61 insertions(+), 28 deletions(-)

diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index 4671a1317449b1..b1f938a8f96a11 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -1,27 +1,27 @@
 # vim: set ts=4 sw=4 et:
 
 show_pkg() {
-    show_pkg_var "pkgname" "$pkgname"
-    show_pkg_var "version" "$version"
-    show_pkg_var "revision" "$revision"
-    show_pkg_var "distfiles" "$distfiles" 1
-    show_pkg_var "checksum" "$checksum" 1
-    show_pkg_var "archs" "$archs" 1
-    show_pkg_var "maintainer" "${maintainer}"
-    show_pkg_var "Upstream URL" "$homepage"
-    show_pkg_var "License(s)" "${license//,/ }" 1
-    show_pkg_var "Changelog" "$changelog"
-    show_pkg_var "build_style" "$build_style"
-    show_pkg_var "build_helper" "$build_helper" 1
-    show_pkg_var "configure_args" "$configure_args" 1
-    show_pkg_var "short_desc" "$short_desc"
-    show_pkg_var "subpackages" "$subpackages" 1
+    show_pkg_var no "pkgname" "$pkgname"
+    show_pkg_var no "version" "$version"
+    show_pkg_var no "revision" "$revision"
+    show_pkg_var st "distfiles" "$distfiles"
+    show_pkg_var st "checksum" "$checksum"
+    show_pkg_var st "archs" "$archs"
+    show_pkg_var no "maintainer" "${maintainer}"
+    show_pkg_var no "Upstream URL" "$homepage"
+    show_pkg_var st "License(s)" "${license//,/ }"
+    show_pkg_var no "Changelog" "$changelog"
+    show_pkg_var no "build_style" "$build_style"
+    show_pkg_var st "build_helper" "$build_helper"
+    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var no "short_desc" "$short_desc"
+    show_pkg_var st "subpackages" "$subpackages"
     set -f
-    show_pkg_var "conf_files" "$conf_files" 1
+    show_pkg_var st "conf_files" "$conf_files"
     set +f
-    show_pkg_var "replaces" "$replaces" 1
-    show_pkg_var "provides" "$provides" 1
-    show_pkg_var "conflicts" "$conflicts" 1
+    show_pkg_var st "replaces" "$replaces"
+    show_pkg_var st "provides" "$provides"
+    show_pkg_var st "conflicts" "$conflicts"
     local OIFS="$IFS"
     IFS=','
     for var in $1; do
@@ -29,9 +29,9 @@ show_pkg() {
         if [ ${var} != ${var/'*'} ]
         then
             var="${var/'*'}"
-            show_pkg_var "$var" "${!var//$'\n'/' '}"
+            show_pkg_var no "$var" "${!var//$'\n'/' '}"
         else
-            show_pkg_var "$var" "${!var}" 1
+            show_pkg_var st "$var" "${!var}"
         fi
     done
     IFS="$OIFS"
@@ -41,26 +41,59 @@ show_pkg() {
 
 show_pkg_var() {
     local _sep i=
-    local _label="$1"
-    local _value="$2"
-    local _always_split="$3"
-    if [ -n "$_value" ] && [ -n "$_label" ]; then
+    local _split="$1"
+    local _label="$2"
+    shift 2
+    if [ -n "$_label" ]; then
         # on short labels, use more padding so everything lines up
         if [ "${#_label}" -lt 7 ]; then
             _sep="		"
         else
             _sep="	"
         fi
-        if [ -n "$_always_split" ] || [[ "$_value" =~ $'\n' ]]; then
-            for i in ${_value}; do
+
+        # treat as an array
+        if [ "$_split" = "ar" ]; then
+            for _value; do
+                if [ -n "$_value" ]; then
+                    if [[ "$_value" =~ $'\n' ]]; then
+                        OIFS="$IFS"; IFS=$'\n'
+                        for i in $_value; do
+                            [ -n "$i" ] && echo "${_label}:${_sep}${i}"
+                        done
+                        IFS="$OIFS"
+                    else
+                        echo "${_label}:${_sep}${_value}"
+                    fi
+                fi
+            done
+        # treat as a string, always split at whitespace
+        elif [ "$_split" = "st" ] || [[ "$@" =~ $'\n' ]]; then
+            _value="$@"
+            for i in $_value; do
                 [ -n "$i" ] && echo "${_label}:${_sep}${i}"
             done
         else
-            echo "${_label}:${_sep}${_value}"
+            _value="$@"
+            [ -n "$_value" ] && echo "${_label}:${_sep}${_value}"
         fi
     fi
 }
 
+show_pkg_arr() {
+    local _sep i=
+    local _label="$1"
+    shift
+    for _value; do
+        # on short labels, use more padding so everything lines up
+        if [ "${#_label}" -lt 7 ]; then
+            _sep="		"
+        else
+            _sep="	"
+        fi
+    done
+}
+
 show_pkg_deps() {
     [ -f "${PKGDESTDIR}/rdeps" ] && cat ${PKGDESTDIR}/rdeps
 }

From a75d5bbb26508d3df6ebfa7e195ddc863ac5cb54 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 11:52:47 -0400
Subject: [PATCH 3/4] common: {hostmake,make,check,}depends to array

---
 common/build-helper/gir.sh                    | 16 +++++++-------
 common/build-helper/numpy.sh                  |  8 +++----
 common/build-helper/qemu.sh                   |  4 ++--
 common/environment/build-style/R-cran.sh      |  4 ++--
 common/environment/build-style/cargo.sh       |  6 +++---
 common/environment/build-style/cmake.sh       |  4 ++--
 common/environment/build-style/gem.sh         |  4 ++--
 common/environment/build-style/gemspec.sh     |  4 ++--
 common/environment/build-style/go.sh          |  4 ++--
 .../environment/build-style/haskell-stack.sh  |  2 +-
 common/environment/build-style/meson.sh       |  2 +-
 .../build-style/perl-ModuleBuild.sh           |  4 ++--
 common/environment/build-style/perl-module.sh |  6 +++---
 .../environment/build-style/python2-module.sh |  2 +-
 .../environment/build-style/python3-module.sh |  2 +-
 .../environment/build-style/python3-pep517.sh |  2 +-
 common/environment/build-style/raku-dist.sh   |  6 +++---
 common/environment/build-style/scons.sh       |  2 +-
 common/environment/build-style/waf.sh         |  2 +-
 common/environment/build-style/waf3.sh        |  2 +-
 common/environment/build-style/zig-build.sh   |  2 +-
 common/xbps-src/shutils/build_dependencies.sh | 21 ++++++++++---------
 common/xbps-src/shutils/common.sh             |  4 +++-
 common/xbps-src/shutils/consistency_check.sh  |  8 +++----
 common/xbps-src/shutils/show.sh               |  6 +++---
 25 files changed, 65 insertions(+), 62 deletions(-)

diff --git a/common/build-helper/gir.sh b/common/build-helper/gir.sh
index 70699adb179732..93ae649572ee97 100644
--- a/common/build-helper/gir.sh
+++ b/common/build-helper/gir.sh
@@ -8,24 +8,24 @@
 # Check if the 'gir' build_option is set or if there is no
 # 'gir' build_option.
 if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
-	if [[ $hostmakedepends != *"gobject-introspection"* ]]; then
+	if ! array_contains hostmakedepends "gobject-introspection"; then
 		# Provide the host tooling, g-ir-scanner, g-ir-compiler
 		# and its wrappers.
-		hostmakedepends+=" gobject-introspection"
+		hostmakedepends+=(gobject-introspection)
 	fi
 
 	if [ "$CROSS_BUILD" ]; then
 		# Required for running binaries produced from g-ir-compiler
 		# via g-ir-scanner-qemuwrapper
-		hostmakedepends+=" qemu-user-static"
+		hostmakedepends+=(qemu-user-static)
 
 		# Required for running the g-ir-scanner-lddwrapper
-		hostmakedepends+=" prelink-cross"
+		hostmakedepends+=(prelink-cross)
 
-		if [[ $makedepends != *"gobject-introspection"* ]]; then
+		if ! array_contains makedepends "gobject-introspection"; then
 			# Provide basic .gir types like GLib, GObject, DBus, Gio, cairo
 			# and tooling like g-ir-compiler
-			makedepends+=" gobject-introspection"
+			makedepends+=(gobject-introspection)
 		fi
 
 		export VAPIGEN_VAPIDIRS=${XBPS_CROSS_BASE}/usr/share/vala/vapi
@@ -33,8 +33,8 @@ if [ "$build_option_gir" ] || [[ $build_options != *"gir"* ]]; then
 
 		# Provide some packages in hostmakedepends if they are in makedepends
 		for f in gtk+3-devel python3-gobject-devel; do
-			if [[ $makedepends == *"${f}"* ]]; then
-				hostmakedepends+=" ${f}"
+			if array_contains makedepends "${f}"; then
+				hostmakedepends+=("${f}")
 			fi
 		done
 		unset f
diff --git a/common/build-helper/numpy.sh b/common/build-helper/numpy.sh
index e0856dbca7cf3c..801a7dcc41f4f7 100644
--- a/common/build-helper/numpy.sh
+++ b/common/build-helper/numpy.sh
@@ -7,14 +7,14 @@
 
 # Even for cross compilation, numpy should be available on the host to ensure
 # that the host interpreter doesn't complain about missing deps
-if [[ $hostmakedepends != *"python3-numpy"* ]]; then
-	hostmakedepends+=" python3-numpy"
+if ! array_contains hostmakedepends "python3-numpy"; then
+	hostmakedepends+=(python3-numpy)
 fi
 
 [ -z "$CROSS_BUILD" ] && return 0
 
-if [[ $makedepends != *"python3-numpy"* ]]; then
-	makedepends+=" python3-numpy"
+if ! array_contains makedepends "python3-numpy"; then
+	makedepends+=(python3-numpy)
 fi
 
 # python3-setuptools finds numpy libs and headers on the host first;
diff --git a/common/build-helper/qemu.sh b/common/build-helper/qemu.sh
index d6a4342f5e8ee3..5cbb3a6c8e6542 100644
--- a/common/build-helper/qemu.sh
+++ b/common/build-helper/qemu.sh
@@ -1,7 +1,7 @@
 if [ "$CROSS_BUILD" ]; then
 	export QEMU_LD_PREFIX=${XBPS_CROSS_BASE}
-	if [[ $hostmakedepends != *"qemu-user-static"* ]]; then
-		hostmakedepends+=" qemu-user-static"
+	if ! array_contains hostmakedepends "qemu-user-static"; then
+		hostmakedepends+=(qemu-user-static)
 	fi
 fi
 
diff --git a/common/environment/build-style/R-cran.sh b/common/environment/build-style/R-cran.sh
index 0cb7c906f952ac..6f1ab94ed59f3d 100644
--- a/common/environment/build-style/R-cran.sh
+++ b/common/environment/build-style/R-cran.sh
@@ -1,5 +1,5 @@
-makedepends+=" R"
-depends+=" R"
+makedepends+=(R)
+depends+=(R)
 create_wrksrc=required
 build_wrksrc="${pkgname#R-cran-}"
 
diff --git a/common/environment/build-style/cargo.sh b/common/environment/build-style/cargo.sh
index 473750c7a359ea..e96171cd5b0671 100644
--- a/common/environment/build-style/cargo.sh
+++ b/common/environment/build-style/cargo.sh
@@ -1,11 +1,11 @@
-hostmakedepends+=" cargo"
+hostmakedepends+=(cargo)
 
 if ! [[ "$pkgname" =~ ^cargo-auditable(-bootstrap)?$ ]]; then
-	hostmakedepends+=" cargo-auditable"
+	hostmakedepends+=(cargo-auditable)
 fi
 
 if [ "$CROSS_BUILD" ]; then
-	makedepends+=" rust-std"
+	makedepends+=(rust-std)
 fi
 
 build_helper+=" rust"
diff --git a/common/environment/build-style/cmake.sh b/common/environment/build-style/cmake.sh
index 1c5386e1c46c16..992721ba9f814d 100644
--- a/common/environment/build-style/cmake.sh
+++ b/common/environment/build-style/cmake.sh
@@ -1,9 +1,9 @@
 if [ "$CHROOT_READY" ]; then
 	if [ "$pkgname" != cmake-bootstrap ]; then
-		hostmakedepends+=" cmake-bootstrap"
+		hostmakedepends+=(cmake-bootstrap)
 	fi
 	if [ "${make_cmd:-ninja}" = ninja ]; then
-		hostmakedepends+=" ninja"
+		hostmakedepends+=(ninja)
 	fi
 fi
 
diff --git a/common/environment/build-style/gem.sh b/common/environment/build-style/gem.sh
index 73a97bda7d8b28..8ef38cc7791626 100644
--- a/common/environment/build-style/gem.sh
+++ b/common/environment/build-style/gem.sh
@@ -1,6 +1,6 @@
 lib32disabled=yes
-hostmakedepends+=" ruby"
-depends+=" ruby"
+hostmakedepends+=(ruby)
+depends+=(ruby)
 
 # default to rubygems
 if [ -z "$distfiles" ]; then
diff --git a/common/environment/build-style/gemspec.sh b/common/environment/build-style/gemspec.sh
index b3025a9ec47e9d..2536da11cd46f4 100644
--- a/common/environment/build-style/gemspec.sh
+++ b/common/environment/build-style/gemspec.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-hostmakedepends+=" ruby-devel"
-makedepends+=" ruby-devel"
+hostmakedepends+=(ruby-devel)
+makedepends+=(ruby-devel)
diff --git a/common/environment/build-style/go.sh b/common/environment/build-style/go.sh
index 223bba83ff11b4..c58b297891cf6a 100644
--- a/common/environment/build-style/go.sh
+++ b/common/environment/build-style/go.sh
@@ -1,9 +1,9 @@
-if [ -z "$hostmakedepends" -o "${hostmakedepends##*gcc-go-tools*}" ]; then
+if [ "${#hostmakedepends[@]}" -eq 0 ] || ! array_contains hostmakedepends "gcc-go-tools"; then
 	# gc compiler
 	if [ -z "$archs" ]; then
 		archs="aarch64* armv[567]* i686* x86_64* ppc64le* riscv64*"
 	fi
-	hostmakedepends+=" go"
+	hostmakedepends+=(go)
 	nopie=yes
 else
 	# gccgo compiler
diff --git a/common/environment/build-style/haskell-stack.sh b/common/environment/build-style/haskell-stack.sh
index 6b47c121512378..02d5dc63002fd9 100644
--- a/common/environment/build-style/haskell-stack.sh
+++ b/common/environment/build-style/haskell-stack.sh
@@ -1 +1 @@
-hostmakedepends+=" ghc stack"
+hostmakedepends+=(ghc stack)
diff --git a/common/environment/build-style/meson.sh b/common/environment/build-style/meson.sh
index dbfe93700f6919..2b5726f3dc0579 100644
--- a/common/environment/build-style/meson.sh
+++ b/common/environment/build-style/meson.sh
@@ -1,2 +1,2 @@
-hostmakedepends+=" meson"
+hostmakedepends+=(meson)
 build_helper+=" meson"
diff --git a/common/environment/build-style/perl-ModuleBuild.sh b/common/environment/build-style/perl-ModuleBuild.sh
index 60d677131479a3..59ba553b1d4b82 100644
--- a/common/environment/build-style/perl-ModuleBuild.sh
+++ b/common/environment/build-style/perl-ModuleBuild.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/perl-module.sh b/common/environment/build-style/perl-module.sh
index 300ed9b5db6166..cb56eb3ab0cadb 100644
--- a/common/environment/build-style/perl-module.sh
+++ b/common/environment/build-style/perl-module.sh
@@ -1,4 +1,4 @@
-hostmakedepends+=" perl"
-makedepends+=" perl"
-depends+=" perl"
+hostmakedepends+=(perl)
+makedepends+=(perl)
+depends+=(perl)
 lib32disabled=yes
diff --git a/common/environment/build-style/python2-module.sh b/common/environment/build-style/python2-module.sh
index 3a3699bfac0e17..ae51021e4988a9 100644
--- a/common/environment/build-style/python2-module.sh
+++ b/common/environment/build-style/python2-module.sh
@@ -1,2 +1,2 @@
 lib32disabled=yes
-makedepends+=" python"
+makedepends+=(python)
diff --git a/common/environment/build-style/python3-module.sh b/common/environment/build-style/python3-module.sh
index 638f6be9373a47..ce0d9bbeb10e51 100644
--- a/common/environment/build-style/python3-module.sh
+++ b/common/environment/build-style/python3-module.sh
@@ -1,3 +1,3 @@
 lib32disabled=yes
-makedepends+=" python3"
+makedepends+=(python3)
 build_helper+=" python3"
diff --git a/common/environment/build-style/python3-pep517.sh b/common/environment/build-style/python3-pep517.sh
index f4faf980f5080d..8e22b31966336e 100644
--- a/common/environment/build-style/python3-pep517.sh
+++ b/common/environment/build-style/python3-pep517.sh
@@ -1,3 +1,3 @@
-hostmakedepends+=" python3-build python3-installer"
+hostmakedepends+=(python3-build python3-installer)
 lib32disabled=yes
 build_helper+=" python3"
diff --git a/common/environment/build-style/raku-dist.sh b/common/environment/build-style/raku-dist.sh
index 01dc08fcf66660..c72ff709580566 100644
--- a/common/environment/build-style/raku-dist.sh
+++ b/common/environment/build-style/raku-dist.sh
@@ -1,3 +1,3 @@
-depends+=" rakudo"
-checkdepends+=" perl"
-hostmakedepends+=" rakudo"
+depends+=(rakudo)
+checkdepends+=(perl)
+hostmakedepends+=(rakudo)
diff --git a/common/environment/build-style/scons.sh b/common/environment/build-style/scons.sh
index 614fb2c04bee62..bf5c972a4e260f 100644
--- a/common/environment/build-style/scons.sh
+++ b/common/environment/build-style/scons.sh
@@ -1 +1 @@
-hostmakedepends+=" scons"
+hostmakedepends+=(scons)
diff --git a/common/environment/build-style/waf.sh b/common/environment/build-style/waf.sh
index f5deafbf00cabb..2831340bf35a3d 100644
--- a/common/environment/build-style/waf.sh
+++ b/common/environment/build-style/waf.sh
@@ -1 +1 @@
-hostmakedepends+=" python"
+hostmakedepends+=(python)
diff --git a/common/environment/build-style/waf3.sh b/common/environment/build-style/waf3.sh
index 471e0dae2d36a3..8efbd8ae579c26 100644
--- a/common/environment/build-style/waf3.sh
+++ b/common/environment/build-style/waf3.sh
@@ -1 +1 @@
-hostmakedepends+=" python3"
+hostmakedepends+=(python3)
diff --git a/common/environment/build-style/zig-build.sh b/common/environment/build-style/zig-build.sh
index 049b7cd437d538..6af7f8335e629a 100644
--- a/common/environment/build-style/zig-build.sh
+++ b/common/environment/build-style/zig-build.sh
@@ -1 +1 @@
-hostmakedepends+=" zig"
+hostmakedepends+=(zig)
diff --git a/common/xbps-src/shutils/build_dependencies.sh b/common/xbps-src/shutils/build_dependencies.sh
index 57ef45a7d5dd42..62cb698c217dfe 100644
--- a/common/xbps-src/shutils/build_dependencies.sh
+++ b/common/xbps-src/shutils/build_dependencies.sh
@@ -9,16 +9,17 @@ setup_pkg_depends() {
             ${pkg}_package
         fi
     elif [[ $with_subpkgs ]]; then
-        collected="${depends}"
+        collected=("${depends[@]}")
         for pkg in $subpackages; do
             [[ $pkg ]] || continue
             ${pkg}_package
-            collected+=" ${depends}"
+            ensure_array_subpkg "$pkg" depends
+            collected+=("${depends[@]}")
         done
-        depends="${collected}"
+        depends=("${collected[@]}")
     fi
 
-    for j in ${depends}; do
+    for j in "${depends[@]}"; do
         _rpkgname="${j%\?*}"
         _depname="${j#*\?}"
         if [[ ${_rpkgname} == virtual ]]; then
@@ -158,10 +159,10 @@ install_pkg_deps() {
     #
     # Host build dependencies.
     #
-    if [[ ${hostmakedepends} ]]; then
+    if [ "${#hostmakedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${hostmakedepends}; do
+        for f in "${hostmakedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -208,10 +209,10 @@ install_pkg_deps() {
     #
     # Host check dependencies.
     #
-    if [[ ${checkdepends} ]] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
+    if [ "${#checkdepends[@]}" -gt 0 ] && [[ $XBPS_CHECK_PKGS ]] && [ -z "$XBPS_CROSS_BUILD" ]; then
         templates=""
         # check validity
-        for f in ${checkdepends}; do
+        for f in "${checkdepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
@@ -258,10 +259,10 @@ install_pkg_deps() {
     #
     # Target build dependencies.
     #
-    if [[ ${makedepends} ]]; then
+    if [ "${#makedepends[@]}" -gt 0 ]; then
         templates=""
         # check validity
-        for f in ${makedepends}; do
+        for f in "${makedepends[@]}"; do
             if [ -f $XBPS_SRCPKGDIR/$f/template ]; then
                 templates+=" $f"
                 continue
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 50c6ebf9aef8ad..65b21f336483e2 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -556,7 +556,7 @@ setup_pkg() {
         fi
     fi
 
-    for x in ${hostmakedepends} ${makedepends} ${checkdepends}; do
+    for x in "${hostmakedepends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do
         if [[ $x = *[\<\>]* || $x =~ -[^-_]*[0-9][^-_]*_[0-9_]+$ ]]; then
             msg_error "$pkgver: specifying version in build dependency '$x' is invalid, template version is used always\n"
         fi
@@ -609,6 +609,8 @@ setup_pkg() {
 
     set_build_options
 
+    ensure_array hostmakedepends makedepends checkdepends depends
+
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
     export FFLAGS="$XBPS_FFLAGS $XBPS_CROSS_FFLAGS $FFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/consistency_check.sh b/common/xbps-src/shutils/consistency_check.sh
index 6a5b2ec1997574..fe892839acad9c 100644
--- a/common/xbps-src/shutils/consistency_check.sh
+++ b/common/xbps-src/shutils/consistency_check.sh
@@ -69,12 +69,12 @@ consistency_check() {
         XBPS_TARGET_PKG=${pkg##*/}
         (
             read_pkg
-            [ "$depends" ] && printf "%s $pkgname depends\n" $depends
+            [ "${#depends[@]}" -gt 0 ] && printf "%s $pkgname depends\n" "${depends[*]}"
             [ "$conflicts" ] && printf "%s $pkgname conflicts\n" $conflicts
             [ -L "$XBPS_SRCPKGDIR/$XBPS_TARGET_PKG" ] && return
-            [ "$makedepends" ] && printf "%s $pkgname makedepends\n" $makedepends
-            [ "$hostmakedepends" ] && printf "%s $pkgname hostmakedepends\n" $hostmakedepends
-            [ "$checkdepends" ] && printf "%s $pkgname checkdepends\n" $checkdepends
+            [ "${#makedepends[@]}" -gt 0 ] && printf "%s $pkgname makedepends\n" "${makedepends[*]}"
+            [ "${#hostmakedepends[@]}" -gt 0 ] && printf "%s $pkgname hostmakedepends\n" "${hostmakedepends[*]}"
+            [ "${#checkdepends[@]}" -gt 0 ] && printf "%s $pkgname checkdepends\n" "${checkdepends[*]}"
         )
     done | grep -v "^virtual?" | sed "s/^[^ ]*?//" | consistency_check_existing | \
         consistency_convert_pkgname | consistency_check_smart
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index b1f938a8f96a11..cb2e758643ba2a 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -149,15 +149,15 @@ show_pkg_build_depends() {
 }
 
 show_pkg_build_deps() {
-    show_pkg_build_depends "${makedepends} $(setup_pkg_depends '' 1 1)" "${hostmakedepends}"
+    show_pkg_build_depends "${makedepends[*]} $(setup_pkg_depends '' 1 1)" "${hostmakedepends[*]}"
 }
 
 show_pkg_hostmakedepends() {
-    show_pkg_build_depends "" "${hostmakedepends}"
+    show_pkg_build_depends "" "${hostmakedepends[*]}"
 }
 
 show_pkg_makedepends() {
-    show_pkg_build_depends "${makedepends}" ""
+    show_pkg_build_depends "${makedepends[*]}" ""
 }
 
 show_pkg_build_options() {

From b58f039de61e4e5c83203bb3011afca39d0f0596 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Thu, 2 Nov 2023 12:44:18 -0400
Subject: [PATCH 4/4] common: configure_args to array

---
 common/build-helper/cmake-wxWidgets-gtk3.sh      |  2 +-
 common/build-style/cargo.sh                      |  6 +++---
 common/build-style/cmake.sh                      |  4 ++--
 common/build-style/configure.sh                  |  2 +-
 common/build-style/gemspec.sh                    |  2 +-
 common/build-style/gnu-configure.sh              |  2 +-
 common/build-style/meson.sh                      |  4 ++--
 common/build-style/perl-ModuleBuild.sh           |  2 +-
 common/build-style/perl-module.sh                |  2 +-
 common/build-style/qmake.sh                      |  4 ++--
 common/build-style/sip-build.sh                  |  2 +-
 common/build-style/void-cross.sh                 |  4 ++--
 common/build-style/waf.sh                        |  2 +-
 common/build-style/waf3.sh                       |  2 +-
 common/build-style/zig-build.sh                  |  2 +-
 .../environment/configure/gnu-configure-args.sh  | 16 ++++++++--------
 common/xbps-src/shutils/common.sh                |  3 ++-
 common/xbps-src/shutils/show.sh                  |  2 +-
 18 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/common/build-helper/cmake-wxWidgets-gtk3.sh b/common/build-helper/cmake-wxWidgets-gtk3.sh
index 7d813dc5f9538c..ffa4ebd90e71e7 100644
--- a/common/build-helper/cmake-wxWidgets-gtk3.sh
+++ b/common/build-helper/cmake-wxWidgets-gtk3.sh
@@ -3,4 +3,4 @@ if [ "$CROSS_BUILD" ]; then
 else
 	export WX_CONFIG=/usr/bin/wx-config-gtk3
 fi
-configure_args+=" -DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG} "
+configure_args+=("-DwxWidgets_CONFIG_EXECUTABLE=${WX_CONFIG}")
diff --git a/common/build-style/cargo.sh b/common/build-style/cargo.sh
index 751911d8dbee8d..c080a65ad71ca6 100644
--- a/common/build-style/cargo.sh
+++ b/common/build-style/cargo.sh
@@ -5,14 +5,14 @@
 do_build() {
 	: ${make_cmd:=cargo auditable}
 
-	${make_cmd} build --release --locked --target ${RUST_TARGET} ${configure_args}
+	${make_cmd} build --release --locked --target ${RUST_TARGET} "${configure_args[@]}"
 }
 
 do_check() {
 	: ${make_cmd:=cargo auditable}
 
 	${make_check_pre} ${make_cmd} test --release --locked --target ${RUST_TARGET} \
-		${configure_args} ${make_check_args}
+		"${configure_args[@]}" ${make_check_args}
 }
 
 do_install() {
@@ -20,7 +20,7 @@ do_install() {
 	: ${make_install_args:=--path .}
 
 	${make_cmd} install --target ${RUST_TARGET} --root="${DESTDIR}/usr" \
-		--offline --locked ${configure_args} ${make_install_args}
+		--offline --locked "${configure_args[@]}" ${make_install_args}
 
 	rm -f "${DESTDIR}"/usr/.crates.toml
 	rm -f "${DESTDIR}"/usr/.crates2.json
diff --git a/common/build-style/cmake.sh b/common/build-style/cmake.sh
index 124ed354eff674..51836d2c264543 100644
--- a/common/build-style/cmake.sh
+++ b/common/build-style/cmake.sh
@@ -19,7 +19,7 @@ SET(CMAKE_FIND_ROOT_PATH  "${XBPS_MASTERDIR}/usr;${XBPS_MASTERDIR}")
 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 _EOF
-		configure_args+=" -DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake"
+		configure_args+=(-DCMAKE_TOOLCHAIN_FILE=bootstrap.cmake)
 	elif [ "$CROSS_BUILD" ]; then
 		case "$XBPS_TARGET_MACHINE" in
 			x86_64*) _CMAKE_SYSTEM_PROCESSOR=x86_64 ;;
@@ -75,7 +75,7 @@ _EOF
 	export CMAKE_GENERATOR="${CMAKE_GENERATOR:-Ninja}"
 	# Remove -pipe: https://gitlab.kitware.com/cmake/cmake/issues/19590
 	CFLAGS="-DNDEBUG ${CFLAGS/ -pipe / }" CXXFLAGS="-DNDEBUG ${CXXFLAGS/ -pipe / }" \
-		cmake ${cmake_args} ${configure_args} \
+		cmake ${cmake_args} "${configure_args[@]}" \
 		${LIBS:+-DCMAKE_C_STANDARD_LIBRARIES="$LIBS"} \
 		${LIBS:+-DCMAKE_CXX_STANDARD_LIBRARIES="$LIBS"} \
 		${wrksrc}/${build_wrksrc}
diff --git a/common/build-style/configure.sh b/common/build-style/configure.sh
index 8fe327507d9e8f..9b472ca28ccc20 100644
--- a/common/build-style/configure.sh
+++ b/common/build-style/configure.sh
@@ -5,7 +5,7 @@
 do_configure() {
 	: ${configure_script:=./configure}
 
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/gemspec.sh b/common/build-style/gemspec.sh
index 9568e819ed45a3..0ed948dbff0e57 100644
--- a/common/build-style/gemspec.sh
+++ b/common/build-style/gemspec.sh
@@ -120,7 +120,7 @@ do_install() {
 		--no-document \
 		--verbose \
 		"${pkgname#ruby-}-${version}.gem" \
-		-- $configure_args
+		-- "${configure_args[@]}"
 
 	# Remove cache
 	rm -rf ${DESTDIR}/${_GEMDIR}/cache
diff --git a/common/build-style/gnu-configure.sh b/common/build-style/gnu-configure.sh
index 82d36f6ee0f79c..b89008875a894a 100644
--- a/common/build-style/gnu-configure.sh
+++ b/common/build-style/gnu-configure.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=./configure}
 
 	export lt_cv_sys_lib_dlsearch_path_spec="/usr/lib64 /usr/lib32 /usr/lib /lib /usr/local/lib"
-	${configure_script} ${configure_args}
+	${configure_script} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/meson.sh b/common/build-style/meson.sh
index 5ea2eeda40097d..9f1abed904a797 100644
--- a/common/build-style/meson.sh
+++ b/common/build-style/meson.sh
@@ -8,7 +8,7 @@ do_configure() {
 	: ${meson_crossfile:="${XBPS_WRAPPERDIR}/meson/xbps_meson.cross"}
 
 	if [ "$CROSS_BUILD" ]; then
-		configure_args+=" --cross-file=${meson_crossfile}"
+		configure_args+=("--cross-file=${meson_crossfile}")
 	fi
 
 	# binutils ar needs a plugin when LTO is used on static libraries, so we
@@ -39,7 +39,7 @@ do_configure() {
 		--wrap-mode=nodownload \
 		-Db_lto=true -Db_ndebug=true \
 		-Db_staticpic=true \
-		${configure_args} . ${meson_builddir}
+		"${configure_args[@]}" . ${meson_builddir}
 }
 
 do_build() {
diff --git a/common/build-style/perl-ModuleBuild.sh b/common/build-style/perl-ModuleBuild.sh
index f21d2b0efb4cf0..5efa8484068e48 100644
--- a/common/build-style/perl-ModuleBuild.sh
+++ b/common/build-style/perl-ModuleBuild.sh
@@ -24,7 +24,7 @@ do_configure() {
 			perl Build.PL --config optimize="$_optimize" --config ccflags="$_ccflags" \
 			--config lddlflags="$_lddlflags" --config ldflags="$_ldflags" \
 			--config archlibexp="${XBPS_CROSS_BASE}${_archlibexp}" \
-			${configure_args} INSTALLDIRS=vendor
+			"${configure_args[@]}" INSTALLDIRS=vendor
 	else
 		msg_error "$pkgver: cannot find Build.PL for perl module!\n"
 	fi
diff --git a/common/build-style/perl-module.sh b/common/build-style/perl-module.sh
index 2945787ffbe11e..2bcfda7430833f 100644
--- a/common/build-style/perl-module.sh
+++ b/common/build-style/perl-module.sh
@@ -47,7 +47,7 @@ do_configure() {
 			CFLAGS="$CFLAGS -I${XBPS_CROSS_BASE}/usr/include" \
 			LDFLAGS="$LDFLAGS -L${XBPS_CROSS_BASE}/usr/lib -lperl" \
 			LDDLFLAGS="-shared $CFLAGS -L${XBPS_CROSS_BASE}/usr/lib" \
-			perl -I. Makefile.PL ${configure_args} INSTALLDIRS=vendor
+			perl -I. Makefile.PL "${configure_args[@]}" INSTALLDIRS=vendor
 	fi
 
 	for i in ${perl_configure_dirs}; do
diff --git a/common/build-style/qmake.sh b/common/build-style/qmake.sh
index 31745833606eff..1f79fd42d55ced 100644
--- a/common/build-style/qmake.sh
+++ b/common/build-style/qmake.sh
@@ -117,7 +117,7 @@ _EOF
 			QT_INSTALL_PREFIX=/usr \
 			LIB=/usr/lib \
 			QT_TARGET_ARCH=$_qt_arch \
-			${configure_args}
+			"${configure_args[@]}"
 	else
 		${qmake} ${qmake_args} \
 			PREFIX=/usr \
@@ -129,7 +129,7 @@ _EOF
 			QMAKE_CXXFLAGS="${CXXFLAGS}" \
 			QMAKE_LFLAGS="${LDFLAGS}" \
 			CONFIG+=no_qt_rpath \
-			${configure_args}
+			"${configure_args[@]}"
 	fi
 }
 
diff --git a/common/build-style/sip-build.sh b/common/build-style/sip-build.sh
index d8b3bcea98bf09..42b5b2bff19122 100644
--- a/common/build-style/sip-build.sh
+++ b/common/build-style/sip-build.sh
@@ -124,7 +124,7 @@ do_configure() {
 	sip-build --no-make \
 		${_qt:+--qmake "$XBPS_WRAPPERDIR/sip-qmake"} \
 		--api-dir /usr/share/$_qt/qsci/api/python \
-		$configure_args \
+		"${configure_args[@]}" \
 		--build-dir "$sip_builddir"
 
 	if [ "$CROSS_BUILD" ]; then
diff --git a/common/build-style/void-cross.sh b/common/build-style/void-cross.sh
index d94e90cbb133c4..7b792abb0d7bbb 100644
--- a/common/build-style/void-cross.sh
+++ b/common/build-style/void-cross.sh
@@ -142,7 +142,7 @@ _void_cross_build_bootstrap_gcc() {
 		--with-gnu-ld \
 		--with-gnu-as \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_bootstrap_configure_args}
 
 	make ${makejobs}
@@ -438,7 +438,7 @@ _void_cross_build_gcc() {
 		--with-gnu-as \
 		--with-linker-hash-style=gnu \
 		${extra_args} \
-		${configure_args} \
+		"${configure_args[@]}" \
 		${cross_gcc_configure_args}
 
 	make ${makejobs}
diff --git a/common/build-style/waf.sh b/common/build-style/waf.sh
index e943765f9b1797..2b3b6eb03c9df9 100644
--- a/common/build-style/waf.sh
+++ b/common/build-style/waf.sh
@@ -5,7 +5,7 @@ do_configure() {
 	: ${configure_script:=waf}
 
 	PYTHON=/usr/bin/python2 python2 ${configure_script} configure \
-		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} ${configure_args}
+		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} "${configure_args[@]}"
 }
 
 do_build() {
diff --git a/common/build-style/waf3.sh b/common/build-style/waf3.sh
index 54fd221172b7f3..455b043ebfa398 100644
--- a/common/build-style/waf3.sh
+++ b/common/build-style/waf3.sh
@@ -13,7 +13,7 @@ do_configure() {
 
 	PYTHON=/usr/bin/python3 python3 ${configure_script} configure \
 		--prefix=/usr --libdir=/usr/lib${XBPS_TARGET_WORDSIZE} \
-		${configure_args} ${cross_args}
+		"${configure_args[@]}" ${cross_args}
 }
 
 do_build() {
diff --git a/common/build-style/zig-build.sh b/common/build-style/zig-build.sh
index 205c4cadf53f8c..e2d02fb11b7f27 100644
--- a/common/build-style/zig-build.sh
+++ b/common/build-style/zig-build.sh
@@ -33,7 +33,7 @@ do_build() {
 		--libc xbps_zig_libc.txt \
 		-Dtarget="${zig_target}" -Dcpu="${zig_cpu}" \
 		-Drelease-safe --prefix /usr install \
-		${configure_args}
+		"${configure_args[@]}"
 }
 
 do_install() {
diff --git a/common/environment/configure/gnu-configure-args.sh b/common/environment/configure/gnu-configure-args.sh
index 1a552b5074a076..06974323cf94fd 100644
--- a/common/environment/configure/gnu-configure-args.sh
+++ b/common/environment/configure/gnu-configure-args.sh
@@ -6,18 +6,18 @@ fi
 
 # Store args from template so they can be included last and override
 # our defaults
-TEMPLATE_CONFIGURE_ARGS="${configure_args}"
+TEMPLATE_CONFIGURE_ARGS=("${configure_args[@]}")
 
-export configure_args="--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
- --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var"
+export configure_args=(--prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --bindir=/usr/bin
+ --mandir=/usr/share/man --infodir=/usr/share/info --localstatedir=/var)
 
 . ${XBPS_COMMONDIR}/build-profiles/${XBPS_MACHINE}.sh
-export configure_args+=" --host=$XBPS_TRIPLET --build=$XBPS_TRIPLET"
+export configure_args+=("--host=$XBPS_TRIPLET" "--build=$XBPS_TRIPLET")
 
 # Always use wordsize-specific libdir even though the real path is lib
 # This is to make sure 32-bit and 64-bit libs can coexist when looking
 # up things (the opposite-libdir is always symlinked as libNN)
-export configure_args+=" --libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}"
+export configure_args+=("--libdir=\${exec_prefix}/lib${XBPS_TARGET_WORDSIZE}")
 
 _AUTOCONFCACHEDIR=${XBPS_COMMONDIR}/environment/configure/autoconf_cache
 
@@ -33,16 +33,16 @@ esac
 
 # Cross compilation vars
 if [ -z "$CROSS_BUILD" ]; then
-	export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+	export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 	unset TEMPLATE_CONFIGURE_ARGS
 
 	set +a
 	return 0
 fi
 
-export configure_args+=" --host=$XBPS_CROSS_TRIPLET --with-sysroot=$XBPS_CROSS_BASE --with-libtool-sysroot=$XBPS_CROSS_BASE "
+export configure_args+=("--host=$XBPS_CROSS_TRIPLET" "--with-sysroot=$XBPS_CROSS_BASE" "--with-libtool-sysroot=$XBPS_CROSS_BASE")
 
-export configure_args+=" ${TEMPLATE_CONFIGURE_ARGS}"
+export configure_args+=("${TEMPLATE_CONFIGURE_ARGS[@]}")
 unset TEMPLATE_CONFIGURE_ARGS
 
 # Read autoconf cache variables for cross target (taken from OE).
diff --git a/common/xbps-src/shutils/common.sh b/common/xbps-src/shutils/common.sh
index 65b21f336483e2..9374feacb5cccd 100644
--- a/common/xbps-src/shutils/common.sh
+++ b/common/xbps-src/shutils/common.sh
@@ -609,7 +609,8 @@ setup_pkg() {
 
     set_build_options
 
-    ensure_array hostmakedepends makedepends checkdepends depends
+    ensure_array hostmakedepends makedepends checkdepends depends \
+        configure_args
 
     export CFLAGS="$XBPS_CFLAGS $XBPS_CROSS_CFLAGS $CFLAGS $dbgflags"
     export CXXFLAGS="$XBPS_CXXFLAGS $XBPS_CROSS_CXXFLAGS $CXXFLAGS $dbgflags"
diff --git a/common/xbps-src/shutils/show.sh b/common/xbps-src/shutils/show.sh
index cb2e758643ba2a..c700ae2a8e5b53 100644
--- a/common/xbps-src/shutils/show.sh
+++ b/common/xbps-src/shutils/show.sh
@@ -13,7 +13,7 @@ show_pkg() {
     show_pkg_var no "Changelog" "$changelog"
     show_pkg_var no "build_style" "$build_style"
     show_pkg_var st "build_helper" "$build_helper"
-    show_pkg_var st "configure_args" "$configure_args"
+    show_pkg_var ar "configure_args" "${configure_args[@]}"
     show_pkg_var no "short_desc" "$short_desc"
     show_pkg_var st "subpackages" "$subpackages"
     set -f

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2024-03-17  2:31 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  9:48 [PR PATCH] [RFC] [WIP] use bash arrays for some template fields classabbyamp
2023-03-08 10:00 ` tranzystorek-io
2023-03-08 10:03 ` tranzystorek-io
2023-03-08 10:09 ` tranzystorek-io
2023-03-08 10:11 ` classabbyamp
2023-03-08 10:12 ` classabbyamp
2023-03-08 10:17 ` tranzystorek-io
2023-03-08 11:41 ` [PR REVIEW] " ahesford
2023-03-08 12:26 ` leahneukirchen
2023-03-08 18:02 ` paper42
2023-03-08 18:12 ` classabbyamp
2023-03-09  5:43 ` [PR REVIEW] " classabbyamp
2023-03-09  5:44 ` [PR PATCH] [Updated] " classabbyamp
2023-03-09  5:45 ` classabbyamp
2023-03-09 12:40 ` [PR REVIEW] " leahneukirchen
2023-03-09 12:42 ` leahneukirchen
2023-03-09 12:42 ` leahneukirchen
2023-03-09 12:43 ` leahneukirchen
2023-03-09 16:14 ` classabbyamp
2023-03-09 16:22 ` Duncaen
2023-03-09 16:37 ` [PR PATCH] [Updated] " classabbyamp
2023-03-09 16:38 ` classabbyamp
2023-03-09 16:38 ` classabbyamp
2023-06-08  2:05 ` github-actions
2023-06-08  2:35 ` classabbyamp
2023-09-07  1:44 ` github-actions
2023-09-07  1:55 ` classabbyamp
2023-11-02 13:42 ` [PR PATCH] [Updated] " classabbyamp
2023-11-02 15:54 ` classabbyamp
2023-11-02 15:56 ` classabbyamp
2023-11-02 16:31 ` [PR PATCH] [Updated] " classabbyamp
2023-11-02 16:44 ` classabbyamp
2024-02-01  1:45 ` github-actions
2024-03-17  2:13 ` [PR PATCH] [Updated] " classabbyamp
2024-03-17  2:31 ` classabbyamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).