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##*/}" _self="${0##*/}"
cfg_workdir="/tmp/$USER/zpac" 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' "$*"; } echo() { printf '%s\n' "$*"; }
err() { echo "$*" >&2; } err() { echo "$*" >&2; }
@ -22,14 +23,14 @@ usage() {
} }
aur.get() { aur.get() {
local aur_url local pkg_aur_info=$( curl "${cfg_aur_api}?type=info&arg=${1}" 2>/dev/null )
local tarball_url=$(package-query -1 -AS -f %u "$1") local pkg_base=$( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
local pkg_base=$( curl "${cfg_aur_api}?type=info&arg=${1}" | jshon -e results -e PackageBase ) local tarball_path=$( jshon -e results -e URLPath -u <<< "$pkg_aur_info" )
cd "$cfg_workdir" cd "$cfg_workdir"
echo "Downloading $tarball_url" echo "Downloading ${cfg_aur_url}${tarball_path}"
{ curl -skL "$tarball_url" | gzip -d | tar x; } || { { curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || {
err "Fail!" err "Fail!"
return 1 return 1
} }
@ -42,11 +43,12 @@ aur.get() {
for i in "${depends[@]}" "${makedepends[@]}"; do for i in "${depends[@]}" "${makedepends[@]}"; do
dep_name="${i/[<>=]*}" 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 if [[ "$dep_repo" == 'aur' ]]; then
[[ -d "${cfg_workdir}/${dep_name}" ]] [[ -d "${cfg_workdir}/${dep_name}" ]] || {
aur.get "$dep_name" || { return "$?"; } aur.get "$dep_name" || { return "$?"; }
}
fi fi
done done
fi fi