Skip to content

Commit 9124f04

Browse files
committed
avoid re-downloading pkginfos when installing or removing packages
1 parent cb19378 commit 9124f04

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lpkg.sh

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,17 @@ infoval() {
3434

3535
# fetch and verify package info
3636
fetchinfo() {
37-
fetch "$REPO" "pkgs/$1.pkginfo" "$tmpdir/$1.pkginfo" || return $?
38-
fetch "$REPO" "pkgs/$1.pkginfo.minisig" "$tmpdir/$1.pkginfo.minisig" || return $?
39-
minisign -Vm "$tmpdir/$1.pkginfo" -p "$LPKGDIR/pubkey.pub" || return 4
40-
local iv="$(infoval "$tmpdir/$1.pkginfo" NAME)" || return $?
41-
if [ "$iv" != "$1" ]; then
42-
echo "Package name mismatch: requested $1 but got $iv" >&2
43-
return 4
37+
if [ ( -e "$LPKGDIR/db/$1/pkginfo.sh" ) -a ( "$UPDATE" -ne 1 ) ]; then
38+
cp "$LPKGDIR/db/$1/pkginfo.sh" "$tmpdir/$1.pkginfo" || return $?
39+
else
40+
fetch "$REPO" "pkgs/$1.pkginfo" "$tmpdir/$1.pkginfo" || return $?
41+
fetch "$REPO" "pkgs/$1.pkginfo.minisig" "$tmpdir/$1.pkginfo.minisig" || return $?
42+
minisign -Vm "$tmpdir/$1.pkginfo" -p "$LPKGDIR/pubkey.pub" || return 4
43+
local iv="$(infoval "$tmpdir/$1.pkginfo" NAME)" || return $?
44+
if [ "$iv" != "$1" ]; then
45+
echo "Package name mismatch: requested $1 but got $iv" >&2
46+
return 4
47+
fi
4448
fi
4549
}
4650

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

0 commit comments

Comments
 (0)