From 1e56e41d638fcdddc291d9a8ea183b40f4802aae Mon Sep 17 00:00:00 2001 From: Andrew Fyfe Date: Wed, 27 Jun 2007 12:04:33 +0100 Subject: scripts/makepkg.in: Use bsdtar to find packages for xdelta. When looking for old packages to create a delta from used bsdtar to read the packages .PKGINFO to check it's name and arch instead of depending on the filename of th package. Signed-off-by: Andrew Fyfe --- scripts/makepkg.in | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/makepkg.in b/scripts/makepkg.in index 2cc43b18..a7cc7e51 100644 --- a/scripts/makepkg.in +++ b/scripts/makepkg.in @@ -594,6 +594,7 @@ extract_sources() { if [ $ret -ne 0 ]; then error "$(gettext "Failed to extract %s")" "$file" plain "$(gettext "Aborting...")" + exit 1 fi done @@ -828,20 +829,18 @@ create_xdelta() { local pkg_file=$1 local cache_dir="/var/cache/pacman/pkg" # TODO: autoconf me + local pkginfo="$(mktemp "$startdir"/xdelta-pkginfo.XXXXXXXXX)" local old_file old_version for old_file in $(ls {"$cache_dir","$PKGDEST"}/${pkgname}-*-*{,-$CARCH}$PKGEXT 2>/dev/null); do - if [[ "$old_file" =~ "$CARCH" ]]; then - old_version=${old_file%-$CARCH$PKGEXT} - else - old_version=${old_file%$PKGEXT} + bsdtar -xOf "$oldfile" .PKGINFO > "$pkginfo" || continue + if [ "$(cat "$pkginfo" | grep '^pkgname = ')" != "pkgname = $pkgname" ]; then + continue # Package name does not match. + elif [ "$(cat "$pkginfo" | grep '^arch = ')" != "arch = $CARCH" ] ; then + continue # Not same arch. fi - old_version=$(echo $old_version | \ - sed "s|^.*/${pkgname}-\([[:alnum:]_\.]*-[[:alnum:]_\.]*\)$|\1|" | \ - grep -v -e "^$cache_dir" -e "^$PKGDEST") - - [ "$old_version" = "" ] && continue + old_version="$(cat "$pkginfo" | grep '^pkgver = ' | sed 's/^pkgver = //')" # old_version may include the target package, only use the old versions local vercmp=$(vercmp "$old_version" "$latest_version") @@ -851,6 +850,8 @@ create_xdelta() { fi done + rm -f "$pkginfo" + if [ "$base_file" != "" ]; then msg "$(gettext "Making delta from version %s...")" "$latest_version" local delta_file="$PKGDEST/$pkgname-${latest_version}_to_$pkgver-$pkgrel-$CARCH.delta" -- cgit v1.2.3-70-g09d2