support for downloading updated packages

This commit is contained in:
Jack L. Frost 2015-09-25 18:12:04 +03:00
parent 0b62cf2bc4
commit c13a3a3fdc

55
prm
View File

@ -24,7 +24,8 @@ usage() {
-A Search only in AUR. Implies -s.
-d Get the package sources (default). Set twice to also get the dependencies.
-n Don't update existing git repos.
-U Print out all outdated AUR packages.
-u Print out all outdated AUR packages.
-U <url> Set AUR url.
-w <dir> Set the working directory.
--nossl Set curl's --insecure flag.
EOF
@ -65,8 +66,8 @@ aur.info() {
}
aur.get_updates() {
declare -a foreign_packages
declare p_aur_info p_localver p_aur_version aur_api_multireq aur_api_data
declare -a foreign_packages updated_pkgs
declare aur_api_multireq aur_api_data aur_api_data_length n p u n_name n_version l_name l_version
read -d '' -r -a foreign_packages < <( pacman -Qqm )
@ -75,7 +76,6 @@ aur.get_updates() {
done
aur_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
aur_api_data_length=$( jshon -e results -l <<< "$aur_api_data" )
(( aur_api_data_length-- ))
@ -85,9 +85,21 @@ aur.get_updates() {
read -r l_name l_version < <( pacman -Q "$n_name" )
if (( $(vercmp "$n_version" "$l_version") )); then
updated_pkgs+=( "$n_name" )
printf '%s\n' "$n_name"
fi
done
if ! (( ${#updated_pkgs[@]} )); then
printf 'No updates found\n'
return 0
fi
if (( flag_get )); then
for u in "${updated_pkgs[@]}"; do
aur.get < <( aur.info "$u" )
done
fi
}
aur.get() {
@ -214,26 +226,26 @@ main() {
(-h) usage; return 0;;
(-s) action='search';;
(-s) flag_search=1;;
(-A)
action='search'
flag_search=1
flag_search_aur=1;;
(-S)
action='search'
flag_search=1
flag_search_syncdb=1;;
(-u)
(-U)
cfg_aur_url="$2"
shift;;
(-U)
action='update';;
(-u)
flag_update=1;;
(-d)
if [[ "$action" == 'get' ]]; then
if (( flag_get )); then
flag_get_deps=1
else
action='get'
flag_get=1
fi
;;
@ -262,18 +274,23 @@ main() {
cfg_aur_api="${cfg_aur_url}/rpc.php"
if (( flag_search )); then
action=search
elif (( flag_update )); then
action=update
elif (( flag_get )); then
action=get
fi
if [[ "$1" ]]; then
package="$1"
fi
[[ "$action" ]] || {
usage
return 1
}
if [[ "$1" ]]; then
package="$1"
# else
# usage
# return 1
fi
case "$action" in
(get)
[[ "$package" ]] || {