From 942c92c999af9bd6b31bfd3af22599c931f42ee4 Mon Sep 17 00:00:00 2001 From: classabbyamp 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 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 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 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