From 27441f201c2394a991427f6a47199dd40024497b Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 20 Oct 2013 16:17:45 -0400 Subject: common: implement find_cached_package This function (currently) searches through $PWD and $PKGDEST looking for a tarball matching the requested package name, architecture, and pkgver. If found, it writes the full path to the located package to stdout and returns 0, else 1. If more than 1 match is found, it's treated as an error and the user will need to figure out what to do. Use this in checkpkg and commitpkg, which previously implemented their own less complete logic, to locate the build artifacts they rely on. Signed-off-by: Dave Reisner Signed-off-by: Pierre Schmitz --- commitpkg.in | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) (limited to 'commitpkg.in') diff --git a/commitpkg.in b/commitpkg.in index 8dcbd7c..1095006 100644 --- a/commitpkg.in +++ b/commitpkg.in @@ -2,22 +2,6 @@ m4_include(lib/common.sh) -getpkgfile() { - case $# in - 0) - error 'No canonical package found!' - return 1 - ;; - [!1]) - error 'Failed to canonicalize package name -- multiple packages found:' - msg2 '%s' "$@" - return 1 - ;; - esac - - echo "$1" -} - # Source makepkg.conf; fail if it is not found if [[ -r '/etc/makepkg.conf' ]]; then source '/etc/makepkg.conf' @@ -99,9 +83,8 @@ for _arch in ${arch[@]}; do for _pkgname in ${pkgname[@]}; do fullver=$(get_full_version $_pkgname) - if pkgfile=$(shopt -s nullglob; - getpkgfile "${PKGDEST+$PKGDEST/}$_pkgname-$fullver-${_arch}".pkg.tar.?z); then - if grep -q "packager = Unknown Packager" <(bsdtar -xOqf $pkgfile .PKGINFO); then + if pkgfile=$(find_cached_package "$_pkgname" "$_arch" "$fullver"); then + if grep -q "packager = Unknown Packager" <(bsdtar -xOqf "$pkgfile" .PKGINFO); then die "PACKAGER was not set when building package" fi fi @@ -151,8 +134,7 @@ for _arch in ${arch[@]}; do for _pkgname in ${pkgname[@]}; do fullver=$(get_full_version $_pkgname) - if ! pkgfile=$(shopt -s nullglob; - getpkgfile "${PKGDEST+$PKGDEST/}$_pkgname-$fullver-${_arch}".pkg.tar.?z); then + if ! pkgfile=$(find_cached_package "$_pkgname" "$fullver" "${_arch}"); then warning "Skipping $_pkgname-$fullver-$_arch: failed to locate package file" skip_arches+=($_arch) continue 2 -- cgit v1.2.3-70-g09d2