Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
04ec3a81a5 | |||
8db246e7af | |||
c13a3a3fdc | |||
0b62cf2bc4 |
@@ -10,7 +10,8 @@ A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
|
|||||||
-A Search only in AUR. Implies -s.
|
-A Search only in AUR. Implies -s.
|
||||||
-d Get the package sources (default). Set twice to also get the dependencies.
|
-d Get the package sources (default). Set twice to also get the dependencies.
|
||||||
-n Don't update existing git repos.
|
-n Don't update existing git repos.
|
||||||
-U Print out all outdated AUR packages.
|
-u Print out all (and download if -d/-dd) outdated AUR packages.
|
||||||
|
-U <url> Set AUR url.
|
||||||
-w <dir> Set the working directory.
|
-w <dir> Set the working directory.
|
||||||
--nossl Set curl's --insecure flag.
|
--nossl Set curl's --insecure flag.
|
||||||
|
|
||||||
|
86
prm
86
prm
@@ -24,7 +24,8 @@ usage() {
|
|||||||
-A Search only in AUR. Implies -s.
|
-A Search only in AUR. Implies -s.
|
||||||
-d Get the package sources (default). Set twice to also get the dependencies.
|
-d Get the package sources (default). Set twice to also get the dependencies.
|
||||||
-n Don't update existing git repos.
|
-n Don't update existing git repos.
|
||||||
-U Print out all outdated AUR packages.
|
-u Print out all (and download if -d/-dd) outdated AUR packages.
|
||||||
|
-U <url> Set AUR url.
|
||||||
-w <dir> Set the working directory.
|
-w <dir> Set the working directory.
|
||||||
--nossl Set curl's --insecure flag.
|
--nossl Set curl's --insecure flag.
|
||||||
EOF
|
EOF
|
||||||
@@ -65,28 +66,40 @@ aur.info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
aur.get_updates() {
|
aur.get_updates() {
|
||||||
declare -a foreign_packages
|
declare -a foreign_packages updated_pkgs
|
||||||
declare p_aur_info p_localver p_aur_version
|
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 )
|
read -d '' -r -a foreign_packages < <( pacman -Qqm )
|
||||||
|
|
||||||
for p in "${foreign_packages[@]}"; do
|
for p in "${foreign_packages[@]}"; do
|
||||||
unset p_aur_info
|
aur_api_multireq+="&arg\[\]=$p"
|
||||||
read -r p_aur_info < <( aur.info "$p" )
|
done
|
||||||
|
|
||||||
if [[ "$p_aur_info" ]]; then
|
aur_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
|
||||||
read -r p_aur_version < <(
|
aur_api_data_length=$( jshon -e results -l <<< "$aur_api_data" )
|
||||||
jshon -e results -e Version -u <<< "$p_aur_info"
|
(( aur_api_data_length-- ))
|
||||||
)
|
|
||||||
|
|
||||||
read -r _ p_localver < <( pacman -Q "$p" )
|
for (( n=0; n<=aur_api_data_length; n++ )); do
|
||||||
|
read -r n_name < <( jshon -e results -e "$n" -e Name -u <<< "$aur_api_data")
|
||||||
|
read -r n_version < <( jshon -e results -e "$n" -e Version -u <<< "$aur_api_data" )
|
||||||
|
read -r l_name l_version < <( pacman -Q "$n_name" )
|
||||||
|
|
||||||
|
if (( $(vercmp "$n_version" "$l_version") )); then
|
||||||
if (( $(vercmp "$p_aur_version" "$p_localver") )); then
|
updated_pkgs+=( "$n_name" )
|
||||||
printf '%s\n' "$p"
|
printf '%s\n' "$n_name"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
done
|
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() {
|
aur.get() {
|
||||||
@@ -213,26 +226,26 @@ main() {
|
|||||||
|
|
||||||
(-h) usage; return 0;;
|
(-h) usage; return 0;;
|
||||||
|
|
||||||
(-s) action='search';;
|
(-s) flag_search=1;;
|
||||||
(-A)
|
(-A)
|
||||||
action='search'
|
flag_search=1
|
||||||
flag_search_aur=1;;
|
flag_search_aur=1;;
|
||||||
(-S)
|
(-S)
|
||||||
action='search'
|
flag_search=1
|
||||||
flag_search_syncdb=1;;
|
flag_search_syncdb=1;;
|
||||||
|
|
||||||
(-u)
|
(-U)
|
||||||
cfg_aur_url="$2"
|
cfg_aur_url="$2"
|
||||||
shift;;
|
shift;;
|
||||||
|
|
||||||
(-U)
|
(-u)
|
||||||
action='update';;
|
flag_update=1;;
|
||||||
|
|
||||||
(-d)
|
(-d)
|
||||||
if [[ "$action" == 'get' ]]; then
|
if (( flag_get )); then
|
||||||
flag_get_deps=1
|
flag_get_deps=1
|
||||||
else
|
else
|
||||||
action='get'
|
flag_get=1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -261,20 +274,30 @@ main() {
|
|||||||
|
|
||||||
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
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" ]] || {
|
[[ "$action" ]] || {
|
||||||
usage
|
usage
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ "$1" ]]; then
|
|
||||||
package="$1"
|
|
||||||
# else
|
|
||||||
# usage
|
|
||||||
# return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$action" in
|
case "$action" in
|
||||||
(get)
|
(get)
|
||||||
|
[[ "$package" ]] || {
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
[[ -d "$cfg_workdir" ]] || {
|
[[ -d "$cfg_workdir" ]] || {
|
||||||
mkdir -p "$cfg_workdir" || {
|
mkdir -p "$cfg_workdir" || {
|
||||||
err "Can't create workdir: %s\n" "$cfg_workdir"
|
err "Can't create workdir: %s\n" "$cfg_workdir"
|
||||||
@@ -315,6 +338,11 @@ main() {
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
(search)
|
(search)
|
||||||
|
[[ "$package" ]] || {
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
if (( flag_search_aur )); then
|
if (( flag_search_aur )); then
|
||||||
aur.search "$package" || {
|
aur.search "$package" || {
|
||||||
err "No packages found\n"
|
err "No packages found\n"
|
||||||
|
Reference in New Issue
Block a user