From 5f6304588e0be95684c0dab4e26e4735666a7a29 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 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 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 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 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