diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-02 23:17:55 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-06-02 23:17:55 -0400 |
commit | 7691cb7d1e5378fbecb3e833a830aac6432fe105 (patch) | |
tree | e0e01946f94bf8af4adafb00590973c407146bd5 | |
parent | 5f183002d8149790b06bf3d5787ad4decee8b259 (diff) |
db-functions: learn some new functions from Arch Linux upstream
-rw-r--r-- | db-functions | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/db-functions b/db-functions index bd87064..cf1b8eb 100644 --- a/db-functions +++ b/db-functions @@ -163,6 +163,13 @@ _grep_pkginfo() { echo "${_ret#${2} = }" } +# usage: _grep_buildinfo pkgfile pattern +_grep_buildinfo() { + local _ret + + _ret="$(/usr/bin/bsdtar -xOqf "$1" .BUILDINFO | grep -m 1 "^${2} = ")" + echo "${_ret#${2} = }" +} # Get the package base or name as fallback getpkgbase() { @@ -225,6 +232,24 @@ getpkgarch() { echo "$_ver" } +check_packager() { + local _packager + + _packager=$(_grep_pkginfo "$1" "packager") + [[ $_packager && $_packager != 'Unknown Packager' ]] +} + +check_buildinfo() { + /usr/bin/bsdtar -tf "$1" .BUILDINFO >/dev/null 2>&1 +} + +check_builddir() { + local _builddir + + _builddir=$(_grep_buildinfo "$1" "builddir") + [[ $_builddir && $_builddir = '/build' ]] +} + getpkgfile() { if [[ ${#} -ne 1 ]]; then error 'No canonical package found!' |