4 Commits
v2.3 ... v2.5

74
zpac
View File

@@ -18,10 +18,10 @@ usage() {
Flags: Flags:
-h Show this message. -h Show this message.
-s Search for <package>. -s Search for <package>.
-S Search only in the sync db. Implies -s. -S Search only in the sync db. Implies -s.
-A Search only in AUR. Implies -s. -A Search only in AUR. Implies -s.
-d Get the package sources (default). -d Get the package sources (default).
-D Get the dependencies also. Implies -d. Set twice to also get the dependencies.
EOF EOF
} }
@@ -35,7 +35,14 @@ aur.search() {
aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) ) aur_search_results=( $( jshon -e results -a -e Name -u <<< "$aur_api_search_data" ) )
for i in "${!aur_search_results[@]}"; do for i in "${!aur_search_results[@]}"; do
printf 'aur/%s\n %s\n' "${aur_search_results[${i}]}" "$( jshon -e results -e $i -e Description -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"
done done
else else
return 1 return 1
@@ -56,10 +63,14 @@ 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 local dep_name aur_api_multireq aur_deps_api_data aur_deps_count aur_deps pkg_aur_info pkg_base tarball_path
read pkg_aur_info read -r pkg_aur_info
pkg_base=$( jshon -e results -e PackageBase -u <<< "$pkg_aur_info" ) {
tarball_path=$( jshon -e results -e URLPath -u <<< "$pkg_aur_info" ) read -r pkg_base
read -r tarball_path
} < <(
jshon -e results -e PackageBase -u -p -e URLPath -u <<< "$pkg_aur_info"
)
cd "$cfg_workdir" cd "$cfg_workdir"
@@ -112,6 +123,40 @@ abs.get() {
svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}" svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
} }
args_norm() {
while (( $# )); do
unset -v arg opt c keys
case "$1" in
--) printf '%s\n' '--'; break;;
--*)
IFS='=' read -r arg opt <<< "$1"
printf '%s\n' "$arg"
[[ "$opt" ]] && {
printf '%s\n' "$opt"
}
;;
-*)
while read -r -n1 c
do
case "$c" in
-|'') :;;
*) keys+=( "-$c" );;
esac
done <<< "$1"
printf '%s\n' "${keys[@]}"
;;
*) printf '%s\n' "$1";;
esac
shift
done
}
main() { main() {
if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then
source "$HOME/.config/zpac.rc.sh" source "$HOME/.config/zpac.rc.sh"
@@ -129,10 +174,13 @@ main() {
action='search' action='search'
flag_search_syncdb=1;; flag_search_syncdb=1;;
(-d) action='get';; (-d)
(-D) if [[ "$action" == 'get' ]]; then
action='get' flag_get_deps=1
flag_get_deps=1;; else
action='get'
fi
;;
(--) shift; break;; (--) shift; break;;
(-*) (-*)
@@ -176,7 +224,7 @@ main() {
if (( ! "$?" )); then if (( ! "$?" )); then
repo='aur' repo='aur'
else else
while read; do while read -r; do
if [[ "$REPLY" =~ ^Repository ]]; then if [[ "$REPLY" =~ ^Repository ]]; then
repo="${REPLY##* }" repo="${REPLY##* }"
fi fi
@@ -224,4 +272,4 @@ main() {
esac esac
} }
main "$@" main $(args_norm "$@")