19 Commits
v2.1 ... v2.8

Author SHA1 Message Date
fbt
8591081269 README 2015-02-09 19:37:55 +03:00
fbt
9e15b8200e trailing newline 2015-02-09 19:36:30 +03:00
fbt
bf18623e06 woo proper handling 2015-02-09 16:22:26 +03:00
fbt
34775cfe97 Readme update 2015-02-06 19:26:40 +03:00
fbt
9b3ea06c61 I'm on fire today. 2015-02-06 13:45:54 +03:00
fbt
f8cfeac03c And another bugfix. 2015-02-06 13:43:36 +03:00
fbt
422adf3d47 args_norm is not needed now.
+ a bugfix.
2015-02-06 13:42:10 +03:00
fbt
07d1805d13 I don't like getopts. Don't know why. I just don't. 2015-02-06 13:40:27 +03:00
fbt
3d148e6b4a Handle arguments with getopt: it supports arguments with spaces. 2015-02-06 11:25:36 +03:00
fbt
c8b1f67bdd Don't download existing sources 2015-02-06 09:28:40 +03:00
fbt
d1becc7836 Show versions in AUR searches, less jshon calls, read -r 2015-02-03 12:58:00 +03:00
fbt
b68c7c5949 A slight fix for the argument handler, doesn't really affect zpac in its current state. 2015-02-01 17:27:39 +03:00
fbt
8e575157f7 Handle -- properly 2015-01-31 18:54:41 +03:00
fbt
7d778ecd66 Better argument handling. 2015-01-31 18:45:47 +03:00
fbt
aa8929ff8e a fix for multiple dependencies. 2015-01-29 12:35:07 +03:00
fbt
2ab2fdd126 usage update 2015-01-28 10:38:56 +03:00
fbt
2c37b9e64e Mention cfg_workdir in the README 2015-01-28 10:13:07 +03:00
fbt
59432612de explicit and implicit action. Removed default one. 2015-01-28 10:11:51 +03:00
fbt
61a9cbd34d usage fix 2015-01-28 00:08:20 +03:00
2 changed files with 129 additions and 30 deletions

View File

@@ -2,11 +2,15 @@ zpac
---- ----
A very simple AUR/ABS helper. Doesn't build packages, only gets the sources. A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
$ zpac -h Usage: zpac [flags] <package>
Usage: zpac [flags] <package> Flags:
Flags:
-h Show this message. -h Show this message.
-s Search for <package>. -s Search for <package>.
-d Get the package sources (default). -S Search only in the sync db. Implies -s.
-A Search only in AUR. Implies -s.
-d Get the package sources (default). Set twice to also get the dependencies.
-f Force downloading package sources even if they are already present in the working directory.
-w <dir> Set the working directory.
You can override any value in the script in \$HOME/.config/zpac.rc.sh You can override any value in the script in \$HOME/.config/zpac.rc.sh
By default zpac downloads the sources into the current directory. Controlled by `$cfg_workdir`.

143
zpac
View File

@@ -18,8 +18,11 @@ usage() {
Flags: Flags:
-h Show this message. -h Show this message.
-s Search for <package>. -s Search for <package>.
-d Get the package sources (default). -S Search only in the sync db. Implies -s.
-D If used with -d, makes $_self download the dependencies from AUR too. -A Search only in AUR. Implies -s.
-d Get the package sources (default). Set twice to also get the dependencies.
-f Force downloading package sources even if they are already present in the working directory.
-w <dir> Set the working directory.
EOF EOF
} }
@@ -33,7 +36,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
@@ -54,21 +64,32 @@ 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"
)
(( flag_force )) || {
[[ -d "${cfg_workdir}/${pkg_base}" ]] && {
echo "Found ${pkg_base} in ${cfg_workdir}, skipping. Use -f to override."
return 17
}
}
cd "$cfg_workdir" cd "$cfg_workdir"
echo "Downloading ${cfg_aur_url}${tarball_path}" echo "Working in ${cfg_workdir}"
echo "Downloading ${pkg_base}"
{ curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || { { curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || {
err "Fail!" err "Fail!"
return 1 return 1
} }
echo ": ${cfg_workdir}/${pkg_base}"
if (( flag_get_deps )); then if (( flag_get_deps )); then
unset depends makedepends unset depends makedepends
@@ -84,11 +105,18 @@ aur.get() {
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
aur_deps=$( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" ) echo "Getting dependencies for ${pkg_base}."
aur_deps=( $( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" ) )
for i in "${aur_deps[@]}"; do for i in "${aur_deps[@]}"; do
aur.get < <(aur.info "$i") || { aur.get < <(aur.info "$i")
return "$?" _result="$?"
(( _result )) && {
(( _result == 17 )) || {
return "$_result"
}
} }
done done
fi fi
@@ -110,6 +138,41 @@ 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() {
declare arg opt c
declare -g argv
while (( $# )); do
unset -v arg opt c
case "$1" in
(--) argv+=( "$1" ); break;;
(--*)
IFS='=' read arg opt <<< "$1"
argv+=( "$arg" )
[[ "$opt" ]] && {
argv+=( "$opt" )
}
;;
(-*)
while read -n1 c
do
case "$c" in
-|'') :;;
*) argv+=( "-$c" );;
esac
done <<< "$1"
;;
(*) argv+=( "$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"
@@ -117,25 +180,51 @@ main() {
while (( $# )); do while (( $# )); do
case "$1" in case "$1" in
--help|-h) usage; return 0;; (--) shift; break;;
-s) action='search';; (-h) usage; return 0;;
-d) action='get';;
-D) flag_get_deps=1;;
--) shift; break;; (-s) action='search';;
-*) (-A)
action='search'
flag_search_aur=1;;
(-S)
action='search'
flag_search_syncdb=1;;
(-d)
if [[ "$action" == 'get' ]]; then
flag_get_deps=1
else
action='get'
fi
;;
(-w)
cfg_workdir="$2"
shift;;
(-f) flag_force=1;;
(-*)
err "Unknown key: $1" err "Unknown key: $1"
usage usage
return 1 return 1
;; ;;
*) break;; (*) break;;
esac esac
shift shift
done done
action=${action:-"get"} (( flag_search_aur && flag_search_syncdb )) && {
unset flag_search_aur flag_search_syncdb
}
[[ "$action" ]] || {
usage
return 1
}
if [[ "$1" ]]; then if [[ "$1" ]]; then
package="$1" package="$1"
@@ -158,7 +247,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
@@ -186,8 +275,13 @@ main() {
;; ;;
(search) (search)
if type -P package-query &>/dev/null; then if (( flag_search_aur )); then
package-query -ASs "$package" aur.search "$package" || {
err "No packages found."
return 1
}
elif (( flag_search_syncdb )); then
pacman -Ss "$package"
else else
aur.search "$package" || { flag_aur_search_fail=1; } aur.search "$package" || { flag_aur_search_fail=1; }
pacman -Ss "$package" 2>/dev/null || { flag_pacman_search_fail=1; } pacman -Ss "$package" 2>/dev/null || { flag_pacman_search_fail=1; }
@@ -201,4 +295,5 @@ main() {
esac esac
} }
main "$@" args_norm "$@"
main "${argv[@]}"