From dd0d7f790227cc0b5437c67360956d9413ea8f1d Mon Sep 17 00:00:00 2001 From: fbt Date: Wed, 10 Jun 2015 14:15:52 +0300 Subject: [PATCH] support AUR 4 --- prm | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/prm b/prm index e396cbb..5eb4c4a 100755 --- a/prm +++ b/prm @@ -6,8 +6,9 @@ _self="${0##*/}" cfg_workdir="$PWD" -cfg_aur_url='https://aur.archlinux.org' -cfg_aur_api="${cfg_aur_url}/rpc.php" + +# Version 3 by default. For now +cfg_aur_version='3' err() { printf "$@" >&2; } @@ -66,12 +67,18 @@ aur.get() { read -r pkg_aur_info - { - read -r pkg_base - read -r tarball_path - } < <( - jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info" - ) + # A temporary hack till AUR4 becomes the main version + if (( cfg_aur_version == 4 )); then + read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" ) + tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz" + else + { + read -r pkg_base + read -r tarball_path + } < <( + jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info" + ) + fi (( flag_force )) || { [[ -d "${cfg_workdir}/${pkg_base}" ]] && { @@ -188,6 +195,14 @@ main() { action='search' flag_search_syncdb=1;; + (-V) + cfg_aur_version="$2" + shift;; + + (-u) + cfg_aur_url="$2" + shift;; + (-d) if [[ "$action" == 'get' ]]; then flag_get_deps=1 @@ -217,6 +232,16 @@ main() { unset flag_search_aur flag_search_syncdb } + if [[ -z "$cfg_aur_url" ]]; then + if (( cfg_aur_version == 3 )); then + cfg_aur_url="https://aur.archlinux.org" + else + cfg_aur_url="https://aur4.archlinux.org" + fi + fi + + cfg_aur_api="${cfg_aur_url}/rpc.php" + [[ "$action" ]] || { usage return 1