summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2022-08-31 02:00:28 +0200
committerLevente Polyak <anthraxx@archlinux.org>2022-08-31 02:26:47 +0200
commitf4e8047d654254bbd3614ecaa448b41fa1f056d7 (patch)
treea1270817f598922c5f3a76d30a5108cc457fd7c6 /src
parent70a3041ff8b1cb85f14dc565d225b3f5ffd8b1d8 (diff)
downloaddevtools-f4e8047d654254bbd3614ecaa448b41fa1f056d7.tar.xz
diffpkg: prefer to search inside the pool dir if available
On certain packaging machines where the pacman cache gets updated very infrequently, the behavior of diffpkg may not function correctly as old packages were to be downloaded as diff target. In such cases we look for a pool directory first and search via a glob for an available pool package sorted by version. The pool search glob has three glob segments each disallowing the dash delimiter to split across pkgrel, pkgver and arch. This will return the correct package from the pool without considering overly eager wildcards that potentially match different pkgnames. The default pool search directory is /srv/ftp/pool
Diffstat (limited to 'src')
-rw-r--r--src/diffpkg.in28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/diffpkg.in b/src/diffpkg.in
index baeb546..5bae805 100644
--- a/src/diffpkg.in
+++ b/src/diffpkg.in
@@ -24,6 +24,7 @@ usage() {
OPTIONS
-M, --makepkg-config Set an alternate makepkg configuration file
+ -P, --pool=DIR Search diff target in pool dir (default '/srv/ftp/pool')
-v, --verbose Provide more detailed/unfiltered output
-h, --help Show this help text
@@ -44,6 +45,8 @@ _EOF_
}
MAKEPKG_CONF=/etc/makepkg.conf
+POOLDIR=/srv/ftp/pool
+
VERBOSE=0
TARLIST=0
DIFFOSCOPE=0
@@ -63,6 +66,7 @@ while (( $# )); do
exit 0
;;
-M|--makepkg-config)
+ (( $# <= 1 )) && die "missing argument for %s" "$1"
MAKEPKG_CONF="$2"
shift 2
;;
@@ -112,6 +116,15 @@ while (( $# )); do
DIFFWIDTH="$1"
shift
;;
+ -P|--pool)
+ (( $# <= 1 )) && die "missing argument for %s" "$1"
+ POOLDIR="$2"
+ shift 2
+ ;;
+ --pool=*)
+ POOLDIR="${1#*=}"
+ shift
+ ;;
--)
shift
break
@@ -248,8 +261,19 @@ fetch_pkg() {
pkg=$1 ;;
esac
- [[ -n $pkgurl ]] || pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
- die "Couldn't download previous package for %s." "$pkg"
+ if [[ -z ${pkgurl} ]]; then
+ # Try to find latest package in pool dir
+ if [[ -d ${POOLDIR} ]]; then
+ shopt -s extglob nullglob
+ pkgurl=$(printf "%s\n" "${POOLDIR}"/*/"${_pkgname}"-!(*-*)-!(*-*)-!(*-*).pkg.tar!(*.sig)|sort -Vr|head -1)
+ shopt -u extglob nullglob
+ fi
+ # Search via pacman database if no pool file exists
+ if [[ ! -f ${pkgurl} ]]; then
+ pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$pkg") ||
+ die "Couldn't download previous package for %s." "$pkg"
+ fi
+ fi
pkg=${pkgurl##*/}
pkgdest=$(mktemp -t -d "${pkg}-XXXXXX")/${pkg}