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 <dreisner@archlinux.org>
Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
This commit is contained in:
Dave Reisner 2013-08-11 19:36:31 -04:00 committed by Pierre Schmitz
parent 914ebe3a74
commit 9c85d116f0
1 changed files with 16 additions and 14 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
shopt -s extglob
m4_include(lib/common.sh) m4_include(lib/common.sh)
# Source makepkg.conf; fail if it is not found # Source makepkg.conf; fail if it is not found
@ -25,15 +27,17 @@ fi
STARTDIR=$(pwd) STARTDIR=$(pwd)
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX) TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
cd "$TEMPDIR"
for _pkgname in "${pkgname[@]}"; do 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 if [[ -f "$STARTDIR/$pkgfile" ]]; then
ln -s "$STARTDIR/$pkgfile" "$pkgfile" ln -s "$STARTDIR/$pkgfile" "$TEMPDIR/$pkgfile"
elif [[ -f "$PKGDEST/$pkgfile" ]]; then elif [[ -f "$PKGDEST/$pkgfile" ]]; then
ln -s "$PKGDEST/$pkgfile" "$pkgfile" ln -s "$PKGDEST/$pkgfile" "$TEMPDIR/$pkgfile"
else else
die "File \"$pkgfile\" doesn't exist" die "File \"$pkgfile\" doesn't exist"
fi fi
@ -58,23 +62,21 @@ for _pkgname in "${pkgname[@]}"; do
elif [[ -f "$STARTDIR/$oldpkg" ]]; then elif [[ -f "$STARTDIR/$oldpkg" ]]; then
ln -s "$STARTDIR/$oldpkg" "$oldpkg" ln -s "$STARTDIR/$oldpkg" "$oldpkg"
else else
curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl" curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
fi fi
fi fi
bsdtar tf "$oldpkg" | sort > "filelist-$_pkgname-old" bsdtar tf "$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
bsdtar tf "$pkgfile" | sort > "filelist-$_pkgname" 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 if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then
mkdir -p pkg mkdir -p "$TEMPDIR/pkg"
cd pkg bsdtar -C "$TEMPDIR" xf ../"$pkgfile" #> /dev/null
bsdtar xf ../"$pkgfile" > /dev/null diff "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
echo "${i}: " "$(objdump -p "$i" | grep SONAME)" echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
done done
cd ..
else else
msg "No soname differences for $_pkgname." msg "No soname differences for $_pkgname."
fi fi