From ec16d6e4bd127e5d8b930fe5428ed6fe502a045c Mon Sep 17 00:00:00 2001 From: Morten Linderud Date: Sat, 25 Dec 2021 15:01:15 +0100 Subject: common: implement validity as a function Signed-off-by: Levente Polyak --- lib/common.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib') diff --git a/lib/common.sh b/lib/common.sh index 0092a45..a3f2f26 100644 --- a/lib/common.sh +++ b/lib/common.sh @@ -189,3 +189,16 @@ find_cached_package() { return 1 esac } + + +check_package_validity(){ + local pkgfile=$1 + if grep -q "packager = Unknown Packager" <(bsdtar -xOqf "$pkgfile" .PKGINFO); then + die "PACKAGER was not set when building package" + fi + hashsum=sha256sum + pkgbuild_hash=$(awk -v"hashsum=$hashsum" -F' = ' '$1 == "pkgbuild_"hashsum {print $2}' <(bsdtar -xOqf "$pkgfile" .BUILDINFO)) + if [[ "$pkgbuild_hash" != "$($hashsum PKGBUILD|cut -d' ' -f1)" ]]; then + die "PKGBUILD $hashsum mismatch: expected $pkgbuild_hash" + fi +} -- cgit v1.2.3-70-g09d2