From e0f7c21a68ddd244f99710ab19ac6e70cc32fa20 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 9 Aug 2013 21:33:58 -0400 Subject: arch-nspawn: avoid escaping mount_args eval is no longer involved in the execution of systemd-nspawn, so we no longer need a layer of escaping on the arguments. Signed-off-by: Dave Reisner Signed-off-by: Pierre Schmitz --- arch-nspawn.in | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index a05ca1c..6c6f1e3 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -56,20 +56,16 @@ host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/ # {{{ functions build_mount_args() { - local p declare -g mount_args=() if [[ -n $host_mirror_path ]]; then - printf -v p '%q' "$host_mirror_path" - mount_args+=(--bind-ro="$p") + mount_args+=(--bind-ro="$host_mirror_path") fi - printf -v p '%q' "${cache_dirs[0]}" - mount_args+=(--bind="$p") + mount_args+=(--bind="${cache_dirs[0]}") for cache_dir in ${cache_dirs[@]:1}; do - printf -v p '%q' "$cache_dir" - mount_args+=(--bind-ro="$p") + mount_args+=(--bind-ro="$cache_dir") done } -- cgit v1.2.3-70-g09d2 From 7267664ed86d17c63b12f05d10e8ffb33aab4938 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 9 Aug 2013 21:33:59 -0400 Subject: arch-nspawn: allow oddly named directories This fixes various errors one might encounter when trying to use a build root or cachedir with whitespace in it. Note that the cachedir fix is not a complete one, as pacman's output is unreliable (and not meant for parsing here). Signed-off-by: Dave Reisner Signed-off-by: Pierre Schmitz --- arch-nspawn.in | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/arch-nspawn.in b/arch-nspawn.in index 6c6f1e3..6900382 100644 --- a/arch-nspawn.in +++ b/arch-nspawn.in @@ -40,15 +40,15 @@ shift $(($OPTIND - 1)) (( $EUID != 0 )) && die 'This script must be run as root.' (( $# < 1 )) && die 'You must specify a directory.' -working_dir="$(readlink -f $1)" +working_dir=$(readlink -f "$1") shift 1 [[ -z $working_dir ]] && die 'Please specify a working directory.' if [[ -z $cache_dir ]]; then - cache_dirs=($(pacman -v $cache_conf 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g')) + cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g')) else - cache_dirs=(${cache_dir}) + cache_dirs=("$cache_dir") fi host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#') @@ -71,12 +71,12 @@ build_mount_args() { copy_hostconf () { cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d" - echo "Server = $host_mirror" > $working_dir/etc/pacman.d/mirrorlist + echo "Server = $host_mirror" >"$working_dir/etc/pacman.d/mirrorlist" - [[ -n $pac_conf ]] && cp $pac_conf $working_dir/etc/pacman.conf - [[ -n $makepkg_conf ]] && cp $makepkg_conf $working_dir/etc/makepkg.conf + [[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf" + [[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf" - sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i $working_dir/etc/pacman.conf + sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf" } # }}} @@ -94,7 +94,7 @@ copy_hostconf eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf") -machine_name="${working_dir//\//-}" +machine_name="${working_dir//[![:alnum:]_-]/-}" machine_name="${machine_name#-}" exec ${CARCH:+setarch "$CARCH"} systemd-nspawn 2>/dev/null \ -- cgit v1.2.3-70-g09d2 From 914ebe3a74287a7972fd4ba33ce3daa77ff96fc8 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 11 Aug 2013 18:09:25 -0400 Subject: ensure that PKGBUILDs aren't sourced via PATH Fixes FS#36378. Signed-off-by: Dave Reisner Signed-off-by: Pierre Schmitz --- checkpkg.in | 2 +- commitpkg.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/checkpkg.in b/checkpkg.in index 8e0f574..54149db 100644 --- a/checkpkg.in +++ b/checkpkg.in @@ -18,7 +18,7 @@ if [[ ! -f PKGBUILD ]]; then die 'This must be run in the directory of a built package.' fi -. PKGBUILD +. ./PKGBUILD if [[ $arch == 'any' ]]; then CARCH='any' fi diff --git a/commitpkg.in b/commitpkg.in index ad1005b..fe9348b 100644 --- a/commitpkg.in +++ b/commitpkg.in @@ -36,7 +36,7 @@ if [[ ! -f PKGBUILD ]]; then die 'No PKGBUILD file' fi -. PKGBUILD +. ./PKGBUILD pkgbase=${pkgbase:-$pkgname} case "$cmd" in -- cgit v1.2.3-70-g09d2 From 9c85d116f0425817b4a631e7a693dc5c948e2470 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 11 Aug 2013 19:36:31 -0400 Subject: checkpkg: avoid using PKGEXT to guess tarball name We can't rely on PKGEXT since it's not sourced from a controlled location. Case in point, if a user sets PKGEXT=.pkg.tar.gz, checkpkg fails and offers no easy workaround. Instead, use glob expansion to resolve the name of the tarball, bailing if it can't be found definitively. This involves some refactoring to avoid modifying PWD (which is advisable regardless). Signed-off-by: Dave Reisner Signed-off-by: Pierre Schmitz --- checkpkg.in | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/checkpkg.in b/checkpkg.in index 54149db..ef46399 100644 --- a/checkpkg.in +++ b/checkpkg.in @@ -1,5 +1,7 @@ #!/bin/bash +shopt -s extglob + m4_include(lib/common.sh) # Source makepkg.conf; fail if it is not found @@ -25,15 +27,17 @@ fi STARTDIR=$(pwd) TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX) -cd "$TEMPDIR" for _pkgname in "${pkgname[@]}"; do - pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT} + pkgfile=(${_pkgname}-$(get_full_version $_pkgname)-${CARCH}.pkg.tar?(.?z)) + if (( ${#pkgfile[*]} != 1 )); then + die 'Ambiguous package name: %s\n' "${pkgfile[*]}" + fi if [[ -f "$STARTDIR/$pkgfile" ]]; then - ln -s "$STARTDIR/$pkgfile" "$pkgfile" + ln -s "$STARTDIR/$pkgfile" "$TEMPDIR/$pkgfile" elif [[ -f "$PKGDEST/$pkgfile" ]]; then - ln -s "$PKGDEST/$pkgfile" "$pkgfile" + ln -s "$PKGDEST/$pkgfile" "$TEMPDIR/$pkgfile" else die "File \"$pkgfile\" doesn't exist" fi @@ -58,23 +62,21 @@ for _pkgname in "${pkgname[@]}"; do elif [[ -f "$STARTDIR/$oldpkg" ]]; then ln -s "$STARTDIR/$oldpkg" "$oldpkg" else - curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl" + curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl" fi fi - bsdtar tf "$oldpkg" | sort > "filelist-$_pkgname-old" - bsdtar tf "$pkgfile" | sort > "filelist-$_pkgname" + bsdtar tf "$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old" + bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname" - sdiff -s "filelist-$_pkgname-old" "filelist-$_pkgname" + sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" - if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then - mkdir -p pkg - cd pkg - bsdtar xf ../"$pkgfile" > /dev/null - diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do + if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then + mkdir -p "$TEMPDIR/pkg" + bsdtar -C "$TEMPDIR" xf ../"$pkgfile" #> /dev/null + diff "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do echo "${i}: " "$(objdump -p "$i" | grep SONAME)" done - cd .. else msg "No soname differences for $_pkgname." fi -- cgit v1.2.3-70-g09d2