checkapk: fix size difference output when multiple info matches

I rebuilt networkmanager locally and was greeted with this:
>>> Size difference for networkmanager: 16 MiB -> 2772 KiB

It turns out networkmanager-elogind provides networkmanager so apk info
will list both, and the former is much bigger so it looked like the
rebuilt package was much smaller when there was almost no difference (as
expected)

Fix by matching on exact package name for both lines; this is already
what we were doing with the local package anyway and the apk fetch
correctly picks the correct package in this case
This commit is contained in:
Dominique Martinet 2024-07-26 17:11:34 +09:00 committed by Natanael Copa
parent d235d5c5a4
commit d9f3f05b50

View File

@ -98,16 +98,15 @@ for i in $pkgname $subpackages; do
die "the built package ($_pkgname) is already in the repo" die "the built package ($_pkgname) is already in the repo"
fi fi
# For our local repo (newsize) apk info might return multiple packages, e.g. if different # apk info could return multiple lines if multiple packages share a provide
# version of the package where built previously. However, for a repo only one of pkgname=pkgver-rpkgrel can exist. # (e.g. dnsmasq); filter with the exact package name and take the second line:
# Filter out this specific pkgver with grep, as it can have only one match, then take the second line:
# 7zip-23.01-r0 installed size: # 7zip-23.01-r0 installed size:
# 1668 KiB # 1668 KiB
newsize="$(apk info --repositories-file /dev/null --repository "$REPODEST"/$repo --size $_pkgname | \ newsize="$(apk info --repositories-file /dev/null --repository "$REPODEST"/$repo --size $_pkgname | \
grep -F "$pkg" -A1 | \ grep -F "$pkg" -A1 | \
tail -n1)" tail -n1)"
oldsize="$(apk info --repositories-file "$tmpdir"/repositories --size "$_pkgname" | \ oldsize="$(apk info --repositories-file "$tmpdir"/repositories --size "$_pkgname" | \
grep -F "$_pkgname" -A1 | \ grep -F "$oldpkg" -A1 | \
tail -n1)" tail -n1)"
if [ "$oldsize" = "$newsize" ]; then if [ "$oldsize" = "$newsize" ]; then