Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
34775cfe97 | |||
9b3ea06c61 | |||
f8cfeac03c | |||
422adf3d47 | |||
07d1805d13 | |||
3d148e6b4a | |||
c8b1f67bdd | |||
d1becc7836 | |||
b68c7c5949 | |||
8e575157f7 | |||
7d778ecd66 | |||
aa8929ff8e | |||
2ab2fdd126 | |||
2c37b9e64e | |||
59432612de | |||
61a9cbd34d | |||
8ba3c36d4a | |||
3d960cd6e4 | |||
048d64fc46 |
@@ -7,4 +7,11 @@ A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
|
|||||||
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.
|
||||||
|
-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.
|
||||||
|
|
||||||
|
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`.
|
||||||
|
|
||||||
|
124
zpac
124
zpac
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
_self="${0##*/}"
|
_self="${0##*/}"
|
||||||
|
|
||||||
cfg_workdir="/tmp/$USER/zpac"
|
cfg_workdir="$PWD"
|
||||||
cfg_aur_url='https://aur.archlinux.org'
|
cfg_aur_url='https://aur.archlinux.org'
|
||||||
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
cfg_aur_api="${cfg_aur_url}/rpc.php"
|
||||||
|
|
||||||
@@ -18,8 +18,15 @@ 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.
|
||||||
|
|
||||||
|
Warning! Due to how the argument handling works, you can do this:
|
||||||
|
$ zpac -wdd /tmp/workdir package
|
||||||
|
Where /tmp/workdir is an argument to w. Don't do this. But it works, unfortunately.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -33,7 +40,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 +68,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,13 +109,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}."
|
||||||
|
|
||||||
echo "${aur_deps[@]}"
|
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
|
||||||
@@ -113,27 +143,66 @@ abs.get() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then
|
||||||
|
source "$HOME/.config/zpac.rc.sh"
|
||||||
|
fi
|
||||||
|
|
||||||
while (( $# )); do
|
while (( $# )); do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h) usage; return 0;;
|
(--) shift; break;;
|
||||||
|
|
||||||
-s) action='search';;
|
(-*)
|
||||||
-d) action='get';;
|
while read -n1 c
|
||||||
-D) flag_get_deps=1;;
|
do
|
||||||
|
case "$c" in
|
||||||
|
(-|'') :;;
|
||||||
|
|
||||||
--) shift; break;;
|
(h) usage; return 0;;
|
||||||
-*)
|
|
||||||
|
(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
|
||||||
;;
|
;;
|
||||||
|
esac
|
||||||
|
done <<< "$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"
|
||||||
@@ -156,7 +225,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
|
||||||
@@ -184,8 +253,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; }
|
||||||
|
Reference in New Issue
Block a user