Skip to content

Commit

Permalink
avoid re-downloading pkginfos when installing or removing packages
Browse files Browse the repository at this point in the history
  • Loading branch information
niaow committed Nov 22, 2017
1 parent cb19378 commit 9124f04
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lpkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ infoval() {

# fetch and verify package info
fetchinfo() {
fetch "$REPO" "pkgs/$1.pkginfo" "$tmpdir/$1.pkginfo" || return $?
fetch "$REPO" "pkgs/$1.pkginfo.minisig" "$tmpdir/$1.pkginfo.minisig" || return $?
minisign -Vm "$tmpdir/$1.pkginfo" -p "$LPKGDIR/pubkey.pub" || return 4
local iv="$(infoval "$tmpdir/$1.pkginfo" NAME)" || return $?
if [ "$iv" != "$1" ]; then
echo "Package name mismatch: requested $1 but got $iv" >&2
return 4
if [ ( -e "$LPKGDIR/db/$1/pkginfo.sh" ) -a ( "$UPDATE" -ne 1 ) ]; then
cp "$LPKGDIR/db/$1/pkginfo.sh" "$tmpdir/$1.pkginfo" || return $?
else
fetch "$REPO" "pkgs/$1.pkginfo" "$tmpdir/$1.pkginfo" || return $?
fetch "$REPO" "pkgs/$1.pkginfo.minisig" "$tmpdir/$1.pkginfo.minisig" || return $?
minisign -Vm "$tmpdir/$1.pkginfo" -p "$LPKGDIR/pubkey.pub" || return 4
local iv="$(infoval "$tmpdir/$1.pkginfo" NAME)" || return $?
if [ "$iv" != "$1" ]; then
echo "Package name mismatch: requested $1 but got $iv" >&2
return 4
fi
fi
}

Expand Down Expand Up @@ -238,6 +242,7 @@ elif [ "$1" == "install" ]; then
done
tmpcleanup
elif [ "$1" == "update" ]; then
UPDATE=1
setup || fail "Failed to create temporary directory" 2
pins=$(cat "$LPKGDIR/pins.list") || fail "Failed to read pin list" 2
transact $pins || fail "Transaction failed" 3
Expand Down

0 comments on commit 9124f04

Please sign in to comment.