Code cleanup, thanks to [stronny](https://github.com/stronny)
This commit is contained in:
parent
d19dc0fbb1
commit
4351aa9450
61
zpac
61
zpac
|
@ -12,8 +12,10 @@ cfg_aur_api="${cfg_aur_url}/rpc.php"
|
|||
echo() { printf '%s\n' "$*"; }
|
||||
err() { echo "$*" >&2; }
|
||||
|
||||
_cat() { while read -r; do printf '%s\n' "$REPLY"; done }
|
||||
|
||||
usage() {
|
||||
readarray usage_block <<- EOF
|
||||
_cat <<- EOF
|
||||
Usage: $_self [flags] <package>
|
||||
Flags:
|
||||
-h Show this message.
|
||||
|
@ -24,47 +26,44 @@ usage() {
|
|||
-f Force downloading package sources even if they are already present in the working directory.
|
||||
-w <dir> Set the working directory.
|
||||
EOF
|
||||
|
||||
printf '%s' "${usage_block[@]}"
|
||||
}
|
||||
|
||||
aur.search() {
|
||||
local aur_api_search_data aur_search_result_num pkg
|
||||
declare aur_api_search_data aur_search_result_num aur_search_results version description
|
||||
|
||||
aur_api_search_data=$( curl -skL "${cfg_aur_api}?type=search&arg=${1}" )
|
||||
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
|
||||
|
||||
if (( aur_search_result_num )); then
|
||||
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) )
|
||||
# Exit if nothing was found
|
||||
(( aur_search_result_num )) || { return 1; }
|
||||
|
||||
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"
|
||||
)
|
||||
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) )
|
||||
|
||||
printf '%s %s\n %s\n' "aur/${aur_search_results[$i]}" "$version" "$description"
|
||||
done
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
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
|
||||
}
|
||||
|
||||
aur.info() {
|
||||
local pkg_aur_info=$( curl -skL "${cfg_aur_api}?type=info&arg=${1}" 2>/dev/null )
|
||||
local aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
||||
declare pkg_aur_info aur_query_result
|
||||
|
||||
pkg_aur_info=$( curl -skL "${cfg_aur_api}?type=info&arg=${1}" 2>/dev/null )
|
||||
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
|
||||
|
||||
if (( aur_query_result )); then
|
||||
echo "$pkg_aur_info"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
(( aur_query_result )) || { return 1; }
|
||||
|
||||
echo "$pkg_aur_info"
|
||||
}
|
||||
|
||||
aur.get() {
|
||||
local dep_name aur_api_multireq aur_deps_api_data aur_deps_count aur_deps pkg_aur_info pkg_base tarball_path
|
||||
declare 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
|
||||
|
||||
read -r pkg_aur_info
|
||||
|
||||
|
@ -93,8 +92,6 @@ aur.get() {
|
|||
}
|
||||
|
||||
if (( flag_get_deps )); then
|
||||
unset depends makedepends
|
||||
|
||||
cd "${cfg_workdir}/${pkg_base}"
|
||||
source PKGBUILD
|
||||
|
||||
|
@ -115,10 +112,8 @@ aur.get() {
|
|||
aur.get < <(aur.info "$i")
|
||||
_result="$?"
|
||||
|
||||
(( _result )) && {
|
||||
(( _result == 17 )) || {
|
||||
return "$_result"
|
||||
}
|
||||
(( _result > 0 && result != 17 )) && {
|
||||
return "$_result"
|
||||
}
|
||||
done
|
||||
fi
|
||||
|
@ -126,7 +121,7 @@ aur.get() {
|
|||
}
|
||||
|
||||
abs.get() {
|
||||
local pkg_repo svn_repo
|
||||
declare pkg_repo svn_repo
|
||||
|
||||
pkg_repo="$2"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user