summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--db-functions17
1 files changed, 13 insertions, 4 deletions
diff --git a/db-functions b/db-functions
index 11ef8e7..359e4c0 100644
--- a/db-functions
+++ b/db-functions
@@ -54,11 +54,20 @@ repo_unlock () { #repo_unlock repo-name arch
restore_umask
}
+# usage: _grep_pkginfo pkgfile pattern
+_grep_pkginfo() {
+ local _ret
+
+ _ret="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 -E "$pattern" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ echo "$_ret"
+}
+
+
# 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|')"
+ _base="$(_grep_pkginfo "$1" "^pkg(base|name)")"
if [ -z "$_base" ]; then
echo "ERROR: Package '$1' has no pkgbase or pkgname in the PKGINFO. Fail!"
exit 1
@@ -71,7 +80,7 @@ getpkgbase() {
getpkgname() {
local _name
- _name="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^pkgname" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ _name="$(_grep_pkginfo "$1" "^pkgname")"
if [ -z "$_name" ]; then
echo "ERROR: Package '$1' has no pkgname in the PKGINFO. Fail!"
exit 1
@@ -84,7 +93,7 @@ getpkgname() {
getpkgver() {
local _ver
- _ver="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^pkgver" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ _ver="$(_grep_pkginfo "$1" "^pkgver")"
if [ -z "$_ver" ]; then
echo "ERROR: Package '$1' has no pkgver in the PKGINFO. Fail!"
exit 1
@@ -95,7 +104,7 @@ getpkgver() {
check_pkg_arch () { #check_pkg_arch pkgfile arch
local _arch
- _arch="$(/usr/bin/bsdtar -xOqf "$1" .PKGINFO | /bin/grep -m 1 "^arch" | /bin/sed 's|\w*\s*=\s*\(.*\)|\1|')"
+ _arch="$(_grep_pkginfo "$1" "^arch")"
if [ -z "$_arch" ]; then
echo "ERROR: Package '$1' has no arch in the PKGINFO. Fail!"