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