summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2009-07-09 17:24:15 +0200
committerAaron Griffin <aaronmgriffin@gmail.com>2009-07-14 23:43:47 +0200
commitd0386030626fda74e6dd370fcd3157c4d93501af (patch)
treefc1b50925e301bf05db2e2d6a636b5547913fe32
parent84a845a0690d6ffb96882699cdc8e9c0e497125d (diff)
downloaddbscripts-d0386030626fda74e6dd370fcd3157c4d93501af.tar.gz
dbscripts-d0386030626fda74e6dd370fcd3157c4d93501af.tar.xz
Read meta data from .PKGINFO instead of filename
Prefer pkgbase over pkgname in getpkgbase() Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
-rw-r--r--db-functions46
1 files changed, 31 insertions, 15 deletions
diff --git a/db-functions b/db-functions
index 966a713..11ef8e7 100644
--- a/db-functions
+++ b/db-functions
@@ -54,32 +54,48 @@ repo_unlock () { #repo_unlock repo-name arch
restore_umask
}
-# Get the package name from the filename
-# hackish, but should work for now
+# Get the package base or name
+getpkgbase() {
+ local _base
+
+ _base="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | sort | /bin/grep -m 1 -E "^pkg(base|name)" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ if [ -z "$_base" ]; then
+ echo "ERROR: Package '$1' has no pkgbase or pkgname in the PKGINFO. Fail!"
+ exit 1
+ fi
+
+ echo "$_base"
+}
+
+# Get the package name
getpkgname() {
- local tmp
+ local _name
- tmp=${1##*/}
- tmp=${tmp%$PKGEXT}
- tmp=${tmp%$SRCEXT}
- tmp=${tmp%-$CARCH}
- echo ${tmp%-*-*}
+ _name="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^pkgname" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ if [ -z "$_name" ]; then
+ echo "ERROR: Package '$1' has no pkgname in the PKGINFO. Fail!"
+ exit 1
+ fi
+
+ echo "$_name"
}
# Get the pkgver-pkgrel of this package
getpkgver() {
- local tmp
+ local _ver
+
+ _ver="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^pkgver" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ if [ -z "$_ver" ]; then
+ echo "ERROR: Package '$1' has no pkgver in the PKGINFO. Fail!"
+ exit 1
+ fi
- tmp=${1##*/}
- tmp=${tmp%$PKGEXT}
- tmp=${tmp%$SRCEXT}
- tmp=${tmp%-$CARCH}
- echo $tmp | sed 's|.*-\(.*-.*\)$|\1|g'
+ echo "$_ver"
}
check_pkg_arch () { #check_pkg_arch pkgfile arch
local _arch
- _arch="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep "^arch" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ _arch="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^arch" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
if [ -z "$_arch" ]; then
echo "ERROR: Package '$1' has no arch in the PKGINFO. Fail!"