This commit is contained in:
Jack L. Frost 2015-01-27 20:05:23 +03:00
parent e0b175f496
commit 5cd8546ece

20
zpac
View File

@ -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