Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
4939405926 | |||
e9bdb6b4e1 | |||
df42e43a49 | |||
7fedda7342 | |||
|
cdc83819f5 | ||
|
96b7584153 | ||
aacf420a68 | |||
|
56a2817649 | ||
|
97d6852e92 | ||
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.
|
||||||
|
|
||||||
|
|
144
prm
144
prm
|
@ -24,39 +24,35 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
aur.search() {
|
aur.search() {
|
||||||
declare i aur_api_search_data aur_search_result_num aur_search_results version description
|
declare i aur_api_search_data aur_search_result_num version description
|
||||||
|
|
||||||
aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=search&arg=${1}" )
|
aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=search&arg=${1}" )
|
||||||
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
|
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
|
||||||
|
|
||||||
# Exit if nothing was found
|
# Exit if nothing was found
|
||||||
(( aur_search_result_num )) || { return 1; }
|
(( aur_search_result_num )) || { return 1; }
|
||||||
|
|
||||||
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) )
|
while {
|
||||||
|
read -r name
|
||||||
for i in "${!aur_search_results[@]}"; do
|
|
||||||
{
|
|
||||||
read -r version
|
read -r version
|
||||||
read -r description
|
read -r description
|
||||||
} < <(
|
} do
|
||||||
jshon -e results -e $i -e Version -u -p -e Description -u <<< "$aur_api_search_data"
|
printf '%s %s\n %s\n' "aur/$name" "$version" "$description"
|
||||||
)
|
done < <( jshon -C -e results -a -e Name -u -p -e Version -u -p -e Description -u <<< "$aur_api_search_data" )
|
||||||
|
|
||||||
printf '%s %s\n %s\n' "aur/${aur_search_results[$i]}" "$version" "$description"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
aur.info() {
|
aur.info() {
|
||||||
declare pkg_aur_info aur_query_result
|
declare pkg_aur_info aur_query_result
|
||||||
|
|
||||||
pkg_aur_info=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=info&v=2&arg=${1}" 2>/dev/null )
|
pkg_aur_info=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info&arg=${1}" 2>/dev/null )
|
||||||
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
||||||
|
|
||||||
(( aur_query_result )) || { return 1; }
|
(( aur_query_result )) || { return 1; }
|
||||||
|
@ -65,38 +61,48 @@ 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=info${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() {
|
||||||
declare i pkg_aur_info pkg_base tarball_path depends makedepends dep_name aur_api_multireq dep_name aur_deps_api_data aur_deps_count aur_deps
|
declare i pkg_aur_info pkg_base depends makedepends dep_name aur_api_multireq dep_name aur_deps_api_data aur_deps_count aur_deps
|
||||||
|
|
||||||
read -r pkg_aur_info
|
read -r pkg_aur_info
|
||||||
|
|
||||||
# A temporary hack till AUR4 becomes the main version
|
read -r pkg_base < <( jshon -e results -a -e Name -u <<< "$pkg_aur_info" )
|
||||||
read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
|
|
||||||
tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz"
|
|
||||||
|
|
||||||
cd "$cfg_workdir"
|
cd "$cfg_workdir"
|
||||||
|
|
||||||
|
@ -123,8 +129,8 @@ aur.get() {
|
||||||
cd "${cfg_workdir}/${pkg_base}"
|
cd "${cfg_workdir}/${pkg_base}"
|
||||||
|
|
||||||
read -d '' -r -a depends < <(
|
read -d '' -r -a depends < <(
|
||||||
jshon -e results -e Depends -a -u <<< "$pkg_aur_info" 2>/dev/null
|
jshon -Q -e results -a -e Depends -a -u <<< "$pkg_aur_info"
|
||||||
jshon -e results -e MakeDepends -a -u <<< "$pkg_aur_info" 2>/dev/null
|
jshon -Q -e results -a -e MakeDepends -a -u <<< "$pkg_aur_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
for i in "${depends[@]}"; do
|
for i in "${depends[@]}"; do
|
||||||
|
@ -132,7 +138,7 @@ aur.get() {
|
||||||
aur_api_multireq+="&arg\[\]=$dep_name"
|
aur_api_multireq+="&arg\[\]=$dep_name"
|
||||||
done
|
done
|
||||||
|
|
||||||
aur_deps_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
|
aur_deps_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info${aur_api_multireq}" )
|
||||||
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
|
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
|
||||||
|
|
||||||
if (( aur_deps_count )); then
|
if (( aur_deps_count )); then
|
||||||
|
@ -153,18 +159,7 @@ aur.get() {
|
||||||
}
|
}
|
||||||
|
|
||||||
abs.get() {
|
abs.get() {
|
||||||
declare pkg_repo svn_repo
|
git clone "https://gitlab.archlinux.org/archlinux/packaging/packages/$1.git" "$cfg_workdir/$1"
|
||||||
|
|
||||||
pkg_repo="$2"
|
|
||||||
|
|
||||||
case "$pkg_repo" in
|
|
||||||
(community|multilib)
|
|
||||||
svn_repo='community';;
|
|
||||||
(*)
|
|
||||||
svn_repo='packages';;
|
|
||||||
esac
|
|
||||||
|
|
||||||
svn export "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_argv() {
|
set_argv() {
|
||||||
|
@ -213,26 +208,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
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -259,22 +254,25 @@ main() {
|
||||||
unset flag_search_aur flag_search_syncdb
|
unset flag_search_aur flag_search_syncdb
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
cfg_aur_api="${cfg_aur_url}/rpc?v=5"
|
||||||
|
|
||||||
|
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
|
|
||||||
(get)
|
|
||||||
[[ -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"
|
||||||
|
@ -282,16 +280,19 @@ main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "$action" in
|
||||||
|
(get)
|
||||||
|
[[ "$package" ]] || {
|
||||||
|
usage
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
pkg_aur_info=$( aur.info "$package" )
|
pkg_aur_info=$( aur.info "$package" )
|
||||||
|
|
||||||
if (( ! "$?" )); then
|
if (( ! "$?" )); then
|
||||||
repo='aur'
|
repo='aur'
|
||||||
else
|
else
|
||||||
while read -r; do
|
read -r repo < <( pacman -Sp --print-format '%r' "$package" )
|
||||||
if [[ "$REPLY" =~ ^Repository ]]; then
|
|
||||||
repo="${REPLY##* }"
|
|
||||||
fi
|
|
||||||
done < <( pacman -Si "$package" )
|
|
||||||
|
|
||||||
[[ "$repo" ]] || {
|
[[ "$repo" ]] || {
|
||||||
err "Can't find package %s\n" "$package"
|
err "Can't find package %s\n" "$package"
|
||||||
|
@ -315,6 +316,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"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user