From c2b33327aa7b8faf3c88aeaa007e7eb4bba4869f Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 25 Mar 2017 08:59:38 -0400 Subject: Handle split packages When a basic lookup fails, attempt to resolve the package name through archweb to get the pkgbase, under the assumption that this might be a split package. This adds jq as a new dependency. Closes #8. --- Makefile | 1 + archweb.inc.sh | 9 +++++++++ asp.in | 1 + package.inc.sh | 57 +++++++++++++++++++++++++++++++++++++++++---------------- 4 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 archweb.inc.sh diff --git a/Makefile b/Makefile index e01c275..eec6fe4 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ ZSH_COMPLETION = \ shell/zsh-completion INCLUDES = \ + archweb.inc.sh \ package.inc.sh \ remote.inc.sh \ util.inc.sh diff --git a/archweb.inc.sh b/archweb.inc.sh new file mode 100644 index 0000000..b660c29 --- /dev/null +++ b/archweb.inc.sh @@ -0,0 +1,9 @@ +archweb_get_pkgbase() { + local pkgbase + + pkgbase=$(curl -s "https://www.archlinux.org/packages/search/json/?q=$1" | + jq -r --arg pkgname "$1" 'limit(1; .results[] | select(.pkgname == $pkgname).pkgbase)') + [[ $pkgbase ]] || return 1 + + printf '%s\n' "$pkgbase" +} diff --git a/asp.in b/asp.in index 499af2f..6471aa1 100644 --- a/asp.in +++ b/asp.in @@ -10,6 +10,7 @@ OPT_FORCE=0 m4_include(util.inc.sh) m4_include(remote.inc.sh) m4_include(package.inc.sh) +m4_include(archweb.inc.sh) usage() { cat<