[arch-projects] [devtools] [PATCH 0/4] Resend of 10/19 patchset
This is a resend of an earlier patch set from 10/19. It's changed in shape and size a bit, but it's all been running locally and building packages for Arch without any problems... Dave Reisner (4): save and reuse original argv when auto-elevating makechroot: die if we encounter an unexpected option makechrootpkg: don't run namcap if makepkg fails makechrootpkg: treat makepkg_args as array arch-nspawn.in | 4 +++- archbuild.in | 6 ++++-- makechrootpkg.in | 27 ++++++++++++++++----------- mkarchroot.in | 4 +++- 4 files changed, 26 insertions(+), 15 deletions(-) -- 2.1.2
Fixes FS#42277. --- arch-nspawn.in | 4 +++- archbuild.in | 6 ++++-- makechrootpkg.in | 6 ++++-- mkarchroot.in | 4 +++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index b85d360..19f1410 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -26,6 +26,8 @@ usage() { exit 1 } +orig_argv=("$@") + while getopts 'hC:M:c:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; @@ -38,7 +40,7 @@ done shift $(($OPTIND - 1)) (( $# < 1 )) && die 'You must specify a directory.' -check_root "$0" "$@" +check_root "$0" "${orig_argv[@]}" working_dir=$(readlink -f "$1") shift 1 diff --git a/archbuild.in b/archbuild.in index dc45c7f..9c5d706 100644 --- a/archbuild.in +++ b/archbuild.in @@ -29,6 +29,8 @@ usage() { exit 1 } +orig_argv=("$@") + while getopts 'hcr:' arg; do case "${arg}" in c) clean_first=true ;; @@ -37,11 +39,11 @@ while getopts 'hcr:' arg; do esac done +check_root "$0" "${orig_argv[@]}" + # Pass all arguments after -- right to makepkg makechrootpkg_args+=("${@:$OPTIND}") -check_root "$0" "$@" - if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then msg "Creating chroot for [${repo}] (${arch})..." diff --git a/makechrootpkg.in b/makechrootpkg.in index a340116..8957974 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -66,6 +66,8 @@ usage() { exit 1 } +orig_argv=("$@") + while getopts 'hcur:I:l:nTD:d:' arg; do case "$arg" in h) usage ;; @@ -81,10 +83,10 @@ while getopts 'hcur:I:l:nTD:d:' arg; do esac done -check_root "$0" "$@" - [[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.' +check_root "$0" "${orig_argv[@]}" + # Canonicalize chrootdir, getting rid of trailing / chrootdir=$(readlink -e "$passeddir") [[ ! -d $chrootdir ]] && die "No chroot dir defined, or invalid path '%s'" "$passeddir" diff --git a/mkarchroot.in b/mkarchroot.in index 5f3d6fe..78384da 100644 --- a/mkarchroot.in +++ b/mkarchroot.in @@ -24,6 +24,8 @@ usage() { exit 1 } +orig_argv=("$@") + while getopts 'hC:M:c:' arg; do case "$arg" in C) pac_conf="$OPTARG" ;; @@ -37,7 +39,7 @@ shift $(($OPTIND - 1)) (( $# < 2 )) && die 'You must specify a directory and one or more packages.' -check_root "$0" "$@" +check_root "$0" "${orig_argv[@]}" working_dir="$(readlink -f $1)" shift 1 -- 2.1.2
--- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 8957974..1fbd3b4 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -70,7 +70,6 @@ orig_argv=("$@") while getopts 'hcur:I:l:nTD:d:' arg; do case "$arg" in - h) usage ;; c) clean_first=true ;; D) bindmounts_ro+=(--bind-ro="$OPTARG") ;; d) bindmounts_rw+=(--bind="$OPTARG") ;; @@ -80,6 +79,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do l) copy="$OPTARG" ;; n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; T) temp_chroot=true; copy+="-$$" ;; + h|*) usage ;; esac done -- 2.1.2
Fixes a regression introduced by 285a4e94cd, which made namcap a "compile time" option. --- makechrootpkg.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index 1fbd3b4..c8cb169 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -265,7 +265,7 @@ EOF # This is a little gross, but this way the script is recreated every time in the # working copy { - printf $'#!/bin/bash\n%s\n_chrootbuild %q %q\n' "$(declare -f _chrootbuild)" \ + printf $'#!/bin/bash\n%s\n_chrootbuild %q %q || exit\n' "$(declare -f _chrootbuild)" \ "$makepkg_args" "$run_namcap" if $run_namcap; then cat <<'EOF' -- 2.1.2
--- makechrootpkg.in | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/makechrootpkg.in b/makechrootpkg.in index c8cb169..26deaca 100644 --- a/makechrootpkg.in +++ b/makechrootpkg.in @@ -12,7 +12,7 @@ m4_include(lib/common.sh) shopt -s nullglob -makepkg_args='-s --noconfirm -L --holdver' +makepkg_args=(-s --noconfirm -L --holdver) repack=false update_first=false clean_first=false @@ -46,7 +46,7 @@ usage() { echo 'command:' echo ' mkarchroot <chrootdir>/root base-devel' echo '' - echo "Default makepkg args: $makepkg_args" + echo "Default makepkg args: ${makepkg_args[*]}" echo '' echo 'Flags:' echo '-h This help' @@ -77,7 +77,7 @@ while getopts 'hcur:I:l:nTD:d:' arg; do r) passeddir="$OPTARG" ;; I) install_pkgs+=("$OPTARG") ;; l) copy="$OPTARG" ;; - n) run_namcap=true; makepkg_args="$makepkg_args -i" ;; + n) run_namcap=true; makepkg_args+=(-i) ;; T) temp_chroot=true; copy+="-$$" ;; h|*) usage ;; esac @@ -102,7 +102,7 @@ else fi # Pass all arguments after -- right to makepkg -makepkg_args="$makepkg_args ${*:$OPTIND}" +makepkg_args+=("${@:$OPTIND}") # See if -R was passed to makepkg for arg in "${@:OPTIND}"; do @@ -265,8 +265,12 @@ EOF # This is a little gross, but this way the script is recreated every time in the # working copy { - printf $'#!/bin/bash\n%s\n_chrootbuild %q %q || exit\n' "$(declare -f _chrootbuild)" \ - "$makepkg_args" "$run_namcap" + printf '#!/bin/bash\n' + declare -f _chrootbuild + printf '_chrootbuild' + printf ' %q' "${makepkg_args[@]}" + printf ' || exit\n' + if $run_namcap; then cat <<'EOF' pacman -S --needed --noconfirm namcap @@ -302,7 +306,6 @@ download_sources() { _chrootbuild() { # This function isn't run in makechrootpkg, # so no global variables - local makepkg_args="$1" . /etc/profile export HOME=/build @@ -338,7 +341,7 @@ _chrootbuild() { exit 1 fi - sudo -u builduser makepkg $makepkg_args + sudo -u builduser makepkg "$@" } move_products() { -- 2.1.2
participants (1)
-
Dave Reisner