Compare commits

...

60 Commits
v1.0 ... master

Author SHA1 Message Date
Jack L. Frost 4939405926 ABS is not using SVN anymore
Signed-off-by: fbt <fbt@fleshless.org>
2023-10-26 14:54:30 +00:00
Jack L. Frost e9bdb6b4e1 rpc url
Signed-off-by: fbt <fbt@fleshless.org>
2022-02-14 22:20:00 +03:00
Jack L. Frost df42e43a49 just create the dir 2016-04-01 13:19:52 +03:00
Jack L. Frost 7fedda7342 Should probably feed pacman the package name
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:29:43 +03:00
Alad Wenter cdc83819f5 Use pacman -Sp for figuring out the repo a package is in
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:27:46 +03:00
Alad Wenter 96b7584153 Use one jshon call for search results
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-17 02:25:32 +03:00
Jack L. Frost aacf420a68 There is no more tarball
Signed-off-by: fbt <fbt@fleshless.org>
2016-03-01 08:32:19 +03:00
Alad Wenter 56a2817649 Fix jshon calls
Signed-off-by: fbt <fbt@fleshless.org>
2016-02-29 18:49:49 +03:00
Alad Wenter 97d6852e92 Use RPC v5
Signed-off-by: fbt <fbt@fleshless.org>
2016-02-29 18:41:08 +03:00
Jack L. Frost 04ec3a81a5 README also 2015-09-25 18:15:58 +03:00
Jack L. Frost 8db246e7af help update 2015-09-25 18:14:45 +03:00
Jack L. Frost c13a3a3fdc support for downloading updated packages 2015-09-25 18:12:04 +03:00
Jack L. Frost 0b62cf2bc4 Don't query AUR for each package dammit 2015-09-25 17:56:23 +03:00
Jack L. Frost 351a03c515 update! 2015-09-23 18:05:45 +03:00
Jack L. Frost 8e2ed7b9f9 Update usage and README 2015-09-21 14:18:24 +03:00
Jack L. Frost e7252333b0 A few improvements:
* Use the new RPC format to avoid sourcing the PKGBUILD.
* A separate switch for curl's insecure mode: --nossl.
* Clone the AUR git repos instead of downloading the targballs.
2015-09-21 14:14:54 +03:00
Jack L. Frost 0496e2c887 there is one AUR now 2015-08-09 15:55:10 +03:00
Jack L. Frost a450ff9708 use aur4 by default 2015-06-22 13:31:03 +03:00
Jack L. Frost dd0d7f7902 support AUR 4 2015-06-10 14:15:52 +03:00
Jack L. Frost 840ab9254c export instead of checkout 2015-05-22 17:53:16 +03:00
Jack L. Frost b2dc6c01d7 ughx2 2015-02-25 16:30:32 +03:00
Jack L. Frost c1490bb339 ugh 2015-02-25 16:22:45 +03:00
Jack L. Frost d26cd45116 rename the bloody script will ya 2015-02-25 16:20:42 +03:00
Jack L. Frost 73004f978c zpac is now PRM 2015-02-25 16:17:02 +03:00
Jack L. Frost 1c136aab43 Stop overriding echo, just use printf instead. 2015-02-20 17:50:36 +03:00
Jack L. Frost 4351aa9450 Code cleanup, thanks to [stronny](https://github.com/stronny) 2015-02-20 17:34:46 +03:00
Jack L. Frost d19dc0fbb1 readarray! 2015-02-20 16:43:53 +03:00
Jack L. Frost b2cb42c371 a better usage function 2015-02-20 16:16:15 +03:00
Jack L. Frost 95c0ffa43b better name foe the args normalizer 2015-02-13 12:20:45 +03:00
Jack L. Frost 8591081269 README 2015-02-09 19:37:55 +03:00
Jack L. Frost 9e15b8200e trailing newline 2015-02-09 19:36:30 +03:00
Jack L. Frost bf18623e06 woo proper handling 2015-02-09 16:22:26 +03:00
Jack L. Frost 34775cfe97 Readme update 2015-02-06 19:26:40 +03:00
Jack L. Frost 9b3ea06c61 I'm on fire today. 2015-02-06 13:45:54 +03:00
Jack L. Frost f8cfeac03c And another bugfix. 2015-02-06 13:43:36 +03:00
Jack L. Frost 422adf3d47 args_norm is not needed now.
+ a bugfix.
2015-02-06 13:42:10 +03:00
Jack L. Frost 07d1805d13 I don't like getopts. Don't know why. I just don't. 2015-02-06 13:40:27 +03:00
Jack L. Frost 3d148e6b4a Handle arguments with getopt: it supports arguments with spaces. 2015-02-06 11:25:36 +03:00
Jack L. Frost c8b1f67bdd Don't download existing sources 2015-02-06 09:28:40 +03:00
Jack L. Frost d1becc7836 Show versions in AUR searches, less jshon calls, read -r 2015-02-03 12:58:00 +03:00
Jack L. Frost 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
Jack L. Frost 8e575157f7 Handle -- properly 2015-01-31 18:54:41 +03:00
Jack L. Frost 7d778ecd66 Better argument handling. 2015-01-31 18:45:47 +03:00
Jack L. Frost aa8929ff8e a fix for multiple dependencies. 2015-01-29 12:35:07 +03:00
Jack L. Frost 2ab2fdd126 usage update 2015-01-28 10:38:56 +03:00
Jack L. Frost 2c37b9e64e Mention cfg_workdir in the README 2015-01-28 10:13:07 +03:00
Jack L. Frost 59432612de explicit and implicit action. Removed default one. 2015-01-28 10:11:51 +03:00
Jack L. Frost 61a9cbd34d usage fix 2015-01-28 00:08:20 +03:00
Jack L. Frost 8ba3c36d4a config support, README 2015-01-28 00:06:21 +03:00
Jack L. Frost 3d960cd6e4 Config support 2015-01-28 00:05:27 +03:00
Jack L. Frost 048d64fc46 stray debug message 2015-01-27 23:58:11 +03:00
Jack L. Frost b484a167f4 consistency 2015-01-27 23:52:16 +03:00
Jack L. Frost 40f797ac20 Getting rid of package-query 2015-01-27 23:50:10 +03:00
Jack L. Frost 1fdde28724 Use the API derectly. Massive speed boost. Almost as fast as cower \m/ 2015-01-27 23:12:56 +03:00
Jack L. Frost 5cd8546ece fixes 2015-01-27 20:05:23 +03:00
Jack L. Frost e0b175f496 Ask the API for the package base 2015-01-27 19:52:45 +03:00
Jack L. Frost 9de0ce1e8d Fix for working with package groups 2015-01-27 19:34:57 +03:00
Jack L. Frost aa4062634c get AUR deps too 2015-01-27 19:17:26 +03:00
Jack L. Frost c1324aeccc Mention the license in the header 2015-01-27 18:52:16 +03:00
Jack L. Frost bcf746b858 license 2015-01-27 18:51:41 +03:00
4 changed files with 376 additions and 111 deletions

13
LICENSE Normal file
View File

@ -0,0 +1,13 @@
Copyright (c) 2012-2014, Jack L. Frost <fbt@fleshless.org>
Permission to use, copy, modify, and/or distribute this software for any purpose with or without
fee is hereby granted, provided that the above copyright notice and this permission notice appear
in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.

View File

@ -1,10 +1,19 @@
zpac
----
prm
---
A very simple AUR/ABS helper. Doesn't build packages, only gets the sources.
$ zpac -h
Usage: zpac [flags] <package>
Usage: prm [flags] <package>
Flags:
-h Show this message.
-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.
-n Don't update existing git repos.
-u Print out all (and download if -d/-dd) outdated AUR packages.
-U <url> Set AUR url.
-w <dir> Set the working directory.
--nossl Set curl's --insecure flag.
You can override any value in the script in \$HOME/.config/prm.rc.sh
By default prm downloads the sources into the current directory. Controlled by `$cfg_workdir`.

349
prm Executable file
View File

@ -0,0 +1,349 @@
#!/usr/bin/env bash
# Author: Jack L. Frost <fbt@fleshless.org>
# Licensed under the Internet Software Consortium (ISC) license.
# See LICENSE for its text.
_self="${0##*/}"
cfg_workdir="$PWD"
cfg_aur_url="https://aur.archlinux.org"
cfg_curl_opts=( '--silent' '--location' )
err() { printf "$@" >&2; }
_cat() { while read -r; do printf '%s\n' "$REPLY"; done }
usage() {
_cat <<- EOF
Usage: $_self [flags] <package>
Flags:
-h Show this message.
-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). Set twice to also get the dependencies.
-n Don't update existing git repos.
-u Print out all (and download if -d/-dd) outdated AUR packages.
-U <url> Set AUR url.
-w <dir> Set the working directory.
--nossl Set curl's --insecure flag.
EOF
}
aur.search() {
declare i aur_api_search_data aur_search_result_num version description
aur_api_search_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=search&arg=${1}" )
aur_search_result_num=$( jshon -e resultcount -u <<< "$aur_api_search_data" )
# Exit if nothing was found
(( aur_search_result_num )) || { return 1; }
while {
read -r name
read -r version
read -r description
} do
printf '%s %s\n %s\n' "aur/$name" "$version" "$description"
done < <( jshon -C -e results -a -e Name -u -p -e Version -u -p -e Description -u <<< "$aur_api_search_data" )
}
aur.info() {
declare pkg_aur_info aur_query_result
pkg_aur_info=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info&arg=${1}" 2>/dev/null )
aur_query_result=$( jshon -e resultcount -u <<< "$pkg_aur_info" )
(( aur_query_result )) || { return 1; }
printf '%s' "$pkg_aur_info"
}
aur.get_updates() {
declare -a foreign_packages updated_pkgs
declare aur_api_multireq aur_api_data aur_api_data_length n p u n_name n_version l_name l_version
read -d '' -r -a foreign_packages < <( pacman -Qqm )
for p in "${foreign_packages[@]}"; do
aur_api_multireq+="&arg\[\]=$p"
done
aur_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info${aur_api_multireq}" )
aur_api_data_length=$( jshon -e results -l <<< "$aur_api_data" )
(( aur_api_data_length-- ))
for (( n=0; n<=aur_api_data_length; n++ )); do
read -r n_name < <( jshon -e results -e "$n" -e Name -u <<< "$aur_api_data")
read -r n_version < <( jshon -e results -e "$n" -e Version -u <<< "$aur_api_data" )
read -r l_name l_version < <( pacman -Q "$n_name" )
if (( $(vercmp "$n_version" "$l_version") )); then
updated_pkgs+=( "$n_name" )
printf '%s\n' "$n_name"
fi
done
if ! (( ${#updated_pkgs[@]} )); then
printf 'No updates found\n'
return 0
fi
if (( flag_get )); then
for u in "${updated_pkgs[@]}"; do
aur.get < <( aur.info "$u" )
done
fi
}
aur.get() {
declare i pkg_aur_info pkg_base 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_base < <( jshon -e results -a -e Name -u <<< "$pkg_aur_info" )
cd "$cfg_workdir"
printf 'Working in %s\n' "${cfg_workdir}"
if [[ -d "$pkg_base" ]]; then
if ! (( flag_nopull )); then
printf 'Updating %s\n' "$pkg_base"
cd "$pkg_base"
git pull || {
err 'Fail!'
return 21
}
fi
else
printf 'Cloning %s\n' "$pkg_base"
git clone "https://aur.archlinux.org/${pkg_base}.git" || {
err 'Fail!'
return 19
}
fi
if (( flag_get_deps )); then
cd "${cfg_workdir}/${pkg_base}"
read -d '' -r -a depends < <(
jshon -Q -e results -a -e Depends -a -u <<< "$pkg_aur_info"
jshon -Q -e results -a -e MakeDepends -a -u <<< "$pkg_aur_info"
)
for i in "${depends[@]}"; do
dep_name="${i/[<>=]*}"
aur_api_multireq+="&arg\[\]=$dep_name"
done
aur_deps_api_data=$( curl "${cfg_curl_opts[@]}" "${cfg_aur_api}&type=info${aur_api_multireq}" )
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
if (( aur_deps_count )); then
printf "Getting dependencies for %s\n" "${pkg_base}"
aur_deps=( $( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" ) )
for i in "${aur_deps[@]}"; do
aur.get < <(aur.info "$i")
_result="$?"
if (( _result > 0 && result != 17 )); then
return "$_result"
fi
done
fi
fi
}
abs.get() {
git clone "https://gitlab.archlinux.org/archlinux/packaging/packages/$1.git" "$cfg_workdir/$1"
}
set_argv() {
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() {
if [[ -f "$HOME/.config/prm.rc.sh" ]]; then
source "$HOME/.config/prm.rc.sh"
fi
while (( $# )); do
case "$1" in
(--) shift; break;;
(-h) usage; return 0;;
(-s) flag_search=1;;
(-A)
flag_search=1
flag_search_aur=1;;
(-S)
flag_search=1
flag_search_syncdb=1;;
(-U)
cfg_aur_url="$2"
shift;;
(-u)
flag_update=1;;
(-d)
if (( flag_get )); then
flag_get_deps=1
else
flag_get=1
fi
;;
(-w)
cfg_workdir="$2"
shift;;
(-n) flag_nopull=1;;
(--nossl) cfg_curl_opts+=( '--insecure' );;
(-*)
err "Unknown key: %s\n" "$1"
usage
return 1
;;
(*) break;;
esac
shift
done
(( flag_search_aur && flag_search_syncdb )) && {
unset flag_search_aur flag_search_syncdb
}
cfg_aur_api="${cfg_aur_url}/rpc?v=5"
if (( flag_search )); then
action=search
elif (( flag_update )); then
action=update
elif (( flag_get )); then
action=get
fi
if [[ "$1" ]]; then
package="$1"
fi
[[ "$action" ]] || {
usage
return 1
}
[[ -d "$cfg_workdir" ]] || {
mkdir -p "$cfg_workdir" || {
err "Can't create workdir: %s\n" "$cfg_workdir"
return 1
}
}
case "$action" in
(get)
[[ "$package" ]] || {
usage
return 1
}
pkg_aur_info=$( aur.info "$package" )
if (( ! "$?" )); then
repo='aur'
else
read -r repo < <( pacman -Sp --print-format '%r' "$package" )
[[ "$repo" ]] || {
err "Can't find package %s\n" "$package"
return 1
}
fi
printf "Found %s in %s\n" "$package" "$repo"
case "$repo" in
(aur)
aur.get <<< "$pkg_aur_info";;
(core|extra|community|multilib)
abs.get "$package" "$repo";;
(*)
err "Repository %s not supported\n" "$repo"
return 1;;
esac
;;
(search)
[[ "$package" ]] || {
usage
return 1
}
if (( flag_search_aur )); then
aur.search "$package" || {
err "No packages found\n"
return 1
}
elif (( flag_search_syncdb )); then
pacman -Ss "$package"
else
aur.search "$package" || { flag_aur_search_fail=1; }
pacman -Ss "$package" 2>/dev/null || { flag_pacman_search_fail=1; }
if (( flag_aur_search_fail && flag_pacman_search_fail )); then
err "No packages found\n"
return 1
fi
fi
;;
(update)
aur.get_updates
;;
esac
}
set_argv "$@"
main "${argv[@]}"

106
zpac
View File

@ -1,106 +0,0 @@
#!/usr/bin/env bash
_self="${0##*/}"
cfg_workdir="/tmp/$USER/zpac"
echo() { printf '%s\n' "$*"; }
err() { echo "$*" >&2; }
usage() {
while read; do echo "$REPLY"; done <<- EOF
Usage: $_self [flags] <package>
Flags:
-h Show this message.
-s Search for <package>.
-d Get the package sources (default).
EOF
}
aur.get() {
local tarball_url=$(package-query -1 -AS -f %u "$1")
cd "$cfg_workdir"
echo "Downloading $tarball_url"
{ curl "$tarball_url" | gzip -d | tar x; } || {
err "Fail!"
return 1
}
}
abs.get() {
local svn_repo
case "$package_repo" in
(community|multilib)
svn_repo='community';;
(*)
svn_repo='packages';;
esac
svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
}
main() {
while (( $# )); do
case "$1" in
--help|-h) usage; return 0;;
-s) action='search';;
-d) action='get';;
--) shift; break;;
-*)
err "Unknown key: $1"
usage
return 1
;;
*) break;;
esac
shift
done
action=${action:-"get"}
package="$1"
case "$action" in
(get)
[[ -d "$cfg_workdir" ]] || {
mkdir -p "$cfg_workdir" || {
err "Can't create workdir: ${cfg_workdir}."
return 1
}
}
IFS='/' read repo _ < <( package-query -AS -f '%r/%n' "$package" )
if [[ "$?" > 0 ]]; then
err "Can't find package: $package"
return 1
fi
echo "Found ${package} in ${repo}."
case "$repo" in
(aur)
aur.get "$package";;
(core|extra|community|multilib)
abs.get "$package";;
(*)
err "Repository $repo not supported."
return 1;;
esac
;;
(search)
package-query -ASs "$package"
;;
esac
}
main "$@"