Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/common.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/common.sh b/lib/common.sh
index a3f2f26..0996247 100644
--- a/lib/common.sh
+++ b/lib/common.sh
@@ -202,3 +202,60 @@ check_package_validity(){
die "PKGBUILD $hashsum mismatch: expected $pkgbuild_hash"
fi
}
+
+
+# usage: grep_pkginfo pkgfile pattern
+grep_pkginfo() {
+ local _ret=()
+ mapfile -t _ret < <(bsdtar -xOqf "$1" ".PKGINFO" | grep "^${2} = ")
+ printf '%s\n' "${_ret[@]#${2} = }"
+}
+
+
+# Get the package name
+getpkgname() {
+ local _name
+
+ _name="$(grep_pkginfo "$1" "pkgname")"
+ if [[ -z $_name ]]; then
+ error "Package '%s' has no pkgname in the PKGINFO. Fail!" "$1"
+ exit 1
+ fi
+
+ echo "$_name"
+}
+
+
+# Get the package base or name as fallback
+getpkgbase() {
+ local _base
+
+ _base="$(grep_pkginfo "$1" "pkgbase")"
+ if [[ -z $_base ]]; then
+ getpkgname "$1"
+ else
+ echo "$_base"
+ fi
+}
+
+
+getpkgdesc() {
+ local _desc
+
+ _desc="$(grep_pkginfo "$1" "pkgdesc")"
+ if [[ -z $_desc ]]; then
+ error "Package '%s' has no pkgdesc in the PKGINFO. Fail!" "$1"
+ exit 1
+ fi
+
+ echo "$_desc"
+}
+
+
+is_debug_package() {
+ local pkgfile=${1} pkgbase pkgname pkgdesc
+ pkgbase="$(getpkgbase "${pkgfile}")"
+ pkgname="$(getpkgname "${pkgfile}")"
+ pkgdesc="$(getpkgdesc "${pkgfile}")"
+ [[ ${pkgdesc} == "Detached debugging symbols for "* && ${pkgbase}-debug = "${pkgname}" ]]
+}