summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-07-08 23:38:09 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-07-08 23:38:09 -0400
commit39eab667a29c618436d7338265aeec4891ecfcd5 (patch)
tree17fff5db6992a595c2c552a373d4de2a4c6752a7
parenta68c835ef5ea2527893c87b51797735734b1613f (diff)
check that all cached packages exist before trying to extract anything
This might be a slight slowdown because of reduced parallelism, but it makes the user experience nicer, improved diagnostics, and avoids a common case where it runs for a long time before failing (fail early).
-rwxr-xr-xpristine-etc-keeper24
1 files changed, 19 insertions, 5 deletions
diff --git a/pristine-etc-keeper b/pristine-etc-keeper
index a6a395c..a8a3954 100755
--- a/pristine-etc-keeper
+++ b/pristine-etc-keeper
@@ -26,10 +26,24 @@ commit() (
rm -rf etc/
+ local err=false
+ local files=()
while IFS=' ' read -r pkgname pkgver arch; do
- file=("/var/cache/pacman/pkg/$pkgname-$pkgver-$arch".pkg.tar.*)
- bsdtar xpfv "$file" etc
+ local file=("/var/cache/pacman/pkg/$pkgname-$pkgver-$arch".pkg.tar.*)
+ if ! test -f "$file"; then
+ printf "ERROR: no cached package for %s %s %s\n" "$pkgname" "$pkgver" "$arch"
+ err=true
+ fi
+ files+=("$file")
done < <(join <(pacman-etc-name-ver|sort) <(pacman-all-name-arch|sort))
+ if $err; then
+ return 1
+ fi
+ local file
+ for file in "${files[@]}"; do
+ printf " -> %s\n" "$file"
+ bsdtar xpvf "$file" etc
+ done
touch etc/.gitignore
ln -sr etc.git etc/.git
@@ -68,14 +82,14 @@ main() {
while true; do
lock
if ! [[ -f /var/lib/pristine-etc/spool ]]; then
- exit 0
+ return 0
fi
msg="$(cat /var/lib/pristine-etc/spool)"
rm -f /var/lib/pristine-etc/spool
unlock
- commit "$msg"
- pull
+ commit "$msg" || return $?
+ pull || return $?
done
}