From 5cd8546ecef4cbba752a6ea009a7c7a97f1e6dd5 Mon Sep 17 00:00:00 2001 From: fbt Date: Tue, 27 Jan 2015 20:05:23 +0300 Subject: [PATCH] fixes --- zpac | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/zpac b/zpac index 9da797b..f08a628 100755 --- a/zpac +++ b/zpac @@ -6,7 +6,8 @@ _self="${0##*/}" cfg_workdir="/tmp/$USER/zpac" -cfg_aur_api='https://aur.archlinux.org/rpc.php' +cfg_aur_url='https://aur.archlinux.org' +cfg_aur_api="${cfg_aur_url}/rpc.php" echo() { printf '%s\n' "$*"; } err() { echo "$*" >&2; } @@ -22,14 +23,14 @@ usage() { } aur.get() { - local aur_url - local tarball_url=$(package-query -1 -AS -f %u "$1") - local pkg_base=$( curl "${cfg_aur_api}?type=info&arg=${1}" | jshon -e results -e PackageBase ) + local pkg_aur_info=$( curl "${cfg_aur_api}?type=info&arg=${1}" 2>/dev/null ) + local pkg_base=$( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" ) + local tarball_path=$( jshon -e results -e URLPath -u <<< "$pkg_aur_info" ) cd "$cfg_workdir" - echo "Downloading $tarball_url" - { curl -skL "$tarball_url" | gzip -d | tar x; } || { + echo "Downloading ${cfg_aur_url}${tarball_path}" + { curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || { err "Fail!" return 1 } @@ -42,11 +43,12 @@ aur.get() { for i in "${depends[@]}" "${makedepends[@]}"; do dep_name="${i/[<>=]*}" - dep_repo=$(package-query -1 -AS -f '%r' "${dep_name}") + dep_repo=$( package-query -1 -A -f '%r' "${dep_name}" ) if [[ "$dep_repo" == 'aur' ]]; then - [[ -d "${cfg_workdir}/${dep_name}" ]] - aur.get "$dep_name" || { return "$?"; } + [[ -d "${cfg_workdir}/${dep_name}" ]] || { + aur.get "$dep_name" || { return "$?"; } + } fi done fi