Compare commits

...

9 Commits

Author SHA1 Message Date
Jack L. Frost 4939405926 ABS is not using SVN anymore
Signed-off-by: fbt <fbt@fleshless.org>
2023-10-26 14:54:30 +00:00
Jack L. Frost e9bdb6b4e1 rpc url
Signed-off-by: fbt <fbt@fleshless.org>
2022-02-14 22:20:00 +03:00
Jack L. Frost df42e43a49 just create the dir 2016-04-01 13:19:52 +03:00
Jack L. Frost 7fedda7342 Should probably feed pacman the package name
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:29:43 +03:00
Alad Wenter cdc83819f5 Use pacman -Sp for figuring out the repo a package is in
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:27:46 +03:00
Alad Wenter 96b7584153 Use one jshon call for search results
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:25:32 +03:00
Jack L. Frost aacf420a68 There is no more tarball
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-01 08:32:19 +03:00
Alad Wenter 56a2817649 Fix jshon calls
Signed-off-by: fbt <fbt@fleshless.org>
2016-02-29 18:49:49 +03:00
Alad Wenter 97d6852e92 Use RPC v5
Signed-off-by: fbt <fbt@fleshless.org>
2016-02-29 18:41:08 +03:00
1 changed files with 26 additions and 48 deletions

74
prm
View File

@ -32,32 +32,27 @@ usage() {
}
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" )
# Exit if nothing was found
(( aur_search_result_num )) || { return 1; }
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) )
for i in "${!aur_search_results[@]}"; do
{
read -r version
read -r description
} < <(
jshon -e results -e $i -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
while {
read -r name
read -r version
read -r description
} do
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" )
}
aur.info() {
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 )) || { return 1; }
@ -75,7 +70,7 @@ aur.get_updates() {
aur_api_multireq+="&arg\[\]=$p"
done
aur_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}?type=multiinfo${aur_api_multireq}" )
aur_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info${aur_api_multireq}" )
aur_api_data_length=$( jshon -e results -l <<< "$aur_api_data" )
(( aur_api_data_length-- ))
@ -103,13 +98,11 @@ aur.get_updates() {
}
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
# A temporary hack till AUR4 becomes the main version
read -r pkg_base < <( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" )
tarball_path="/cgit/aur.git/snapshot/${pkg_base}.tar.gz"
read -r pkg_base < <( jshon -e results -a -e Name -u <<< "$pkg_aur_info" )
cd "$cfg_workdir"
@ -136,8 +129,8 @@ aur.get() {
cd "${cfg_workdir}/${pkg_base}"
read -d '' -r -a depends < <(
jshon -e results -e Depends -a -u <<< "$pkg_aur_info" 2>/dev/null
jshon -e results -e MakeDepends -a -u <<< "$pkg_aur_info" 2>/dev/null
jshon -Q -e results -a -e Depends -a -u <<< "$pkg_aur_info"
jshon -Q -e results -a -e MakeDepends -a -u <<< "$pkg_aur_info"
)
for i in "${depends[@]}"; do
@ -145,7 +138,7 @@ aur.get() {
aur_api_multireq+="&arg\[\]=$dep_name"
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" )
if (( aur_deps_count )); then
@ -166,18 +159,7 @@ aur.get() {
}
abs.get() {
declare pkg_repo svn_repo
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}"
git clone "https://gitlab.archlinux.org/archlinux/packaging/packages/$1.git" "$cfg_workdir/$1"
}
set_argv() {
@ -272,7 +254,7 @@ main() {
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
@ -291,6 +273,13 @@ main() {
return 1
}
[[ -d "$cfg_workdir" ]] || {
mkdir -p "$cfg_workdir" || {
err "Can't create workdir: %s\n" "$cfg_workdir"
return 1
}
}
case "$action" in
(get)
[[ "$package" ]] || {
@ -298,23 +287,12 @@ main() {
return 1
}
[[ -d "$cfg_workdir" ]] || {
mkdir -p "$cfg_workdir" || {
err "Can't create workdir: %s\n" "$cfg_workdir"
return 1
}
}
pkg_aur_info=$( aur.info "$package" )
if (( ! "$?" )); then
repo='aur'
else
while read -r; do
if [[ "$REPLY" =~ ^Repository ]]; then
repo="${REPLY##* }"
fi
done < <( pacman -Si "$package" )
read -r repo < <( pacman -Sp --print-format '%r' "$package" )
[[ "$repo" ]] || {
err "Can't find package %s\n" "$package"