Github messages for voidlinux
 help / color / mirror / Atom feed
From: classabbyamp <classabbyamp@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [RFC] [WIP] use bash arrays for some template fields
Date: Thu, 02 Nov 2023 16:54:07 +0100	[thread overview]
Message-ID: <20231102155407.KbQqNKIYYsQ7O8y7JRvZsweJjZK7t2ZCCIDVFfTcN1Y@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-42656@inbox.vuxu.org>

[-- 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() {

  parent reply	other threads:[~2023-11-02 15:54 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08  9:48 [PR PATCH] " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231102155407.KbQqNKIYYsQ7O8y7JRvZsweJjZK7t2ZCCIDVFfTcN1Y@z \
    --to=classabbyamp@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).