From a0f73ceca409fa8995af16eee8440c1467c5f1bf Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Sat, 13 Sep 2008 17:49:59 -0500 Subject: Validate a package file's architecture Apparently, people seem to be renaming files as a "hack" and breaking things. Let's make sure they edited the PKGINFO too Signed-off-by: Aaron Griffin --- db-functions | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'db-functions') diff --git a/db-functions b/db-functions index 25bca78..663067e 100644 --- a/db-functions +++ b/db-functions @@ -46,4 +46,21 @@ getpkgname() { echo ${tmp%-*-*} } +check_pkg_arch () { #check_pkg_arch pkgfile arch + local arch + _arch="$(/usr/bin/bsdtar -xOf "$1" .PKGINFO | /bin/grep "^arch" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')" + + if [ -z "$_arch" ]; then + echo "ERROR: Package '$1' has no arch in the PKGINFO. Fail!" + return 1 + fi + if [ "$_arch" = "$2" ]; then + echo "yay" + return 0 + else + echo "nay" + return 1 + fi +} + # vim: set ts=4 sw=4 noet ft=sh: -- cgit v1.2.3-24-g4f1b