Skip to content
Snippets Groups Projects
Commit b04f0d25 authored by Alad Wenter's avatar Alad Wenter
Browse files

pkglist: add --depth, migrate to new URIs, fixes

parent f298afd9
No related branches found
No related tags found
No related merge requests found
...@@ -5,13 +5,13 @@ set -o errexit ...@@ -5,13 +5,13 @@ set -o errexit
argv0=pkglist argv0=pkglist
XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state}
AUR_LOCATION=${AUR_LOCATION:-'https://aur.archlinux.org'} AUR_LOCATION=${AUR_LOCATION:-'https://aur.archlinux.org'}
AUR_ARCHIVE=${AUR_ARCHIVE:-$AUR_LOCATION} AUR_ARCHIVE=${AUR_ARCHIVE:-$AUR_LOCATION/archives}
AUR_ARCHIVE_ROOT=${AUR_ARCHIVE_ROOT:-$XDG_STATE_HOME/aurweb-archive} AUR_ARCHIVE_ROOT=${AUR_ARCHIVE_ROOT:-$XDG_STATE_HOME/aurweb-archive}
PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
export GIT_HTTP_USER_AGENT=aurutils export GIT_HTTP_USER_AGENT=aurutils
# default options # default arguments
ttl=600 mode=cat pkglist=pkgname.json archive=pkgnames use_system_time=0 use_gc=0 ttl=600 mode=json pkglist=pkgname.json archive=pkgnames use_system_time=0 use_gc=0
usage() { usage() {
printf >&2 'usage: %s [-bqsi] [-t ttl]\n' "$argv0" printf >&2 'usage: %s [-bqsi] [-t ttl]\n' "$argv0"
...@@ -22,7 +22,7 @@ source /usr/share/makepkg/util/parseopts.sh ...@@ -22,7 +22,7 @@ source /usr/share/makepkg/util/parseopts.sh
opt_short='t:bQiqun' opt_short='t:bQiqun'
opt_long=('pkgbase' 'pkgname' 'ttl:' 'users' 'quiet' 'systime' 'info' opt_long=('pkgbase' 'pkgname' 'ttl:' 'users' 'quiet' 'systime' 'info'
'info-pkgbase' 'gc' 'plain') 'info-pkgbase' 'gc' 'plain' 'depth:')
opt_hidden=('dump-options' 'time:') opt_hidden=('dump-options' 'time:')
if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
...@@ -30,7 +30,7 @@ if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then ...@@ -30,7 +30,7 @@ if ! parseopts "$opt_short" "${opt_long[@]}" "${opt_hidden[@]}" -- "$@"; then
fi fi
set -- "${OPTRET[@]}" set -- "${OPTRET[@]}"
unset mode unset clone_args
while true; do while true; do
case "$1" in case "$1" in
-b|--pkgbase) -b|--pkgbase)
...@@ -43,8 +43,10 @@ while true; do ...@@ -43,8 +43,10 @@ while true; do
pkglist=pkgname.json; archive=metadata ;; pkglist=pkgname.json; archive=metadata ;;
--info-pkgbase) --info-pkgbase)
pkglist=pkgbase.json; archive=metadata ;; pkglist=pkgbase.json; archive=metadata ;;
-q|-u|--quiet) -q|--quiet)
mode=none ;; mode=none ;;
-u)
mode=none ;; # deprecated
-t|--time|--ttl) -t|--time|--ttl)
shift; ttl=$1 ;; shift; ttl=$1 ;;
-Q|--systime) -Q|--systime)
...@@ -53,6 +55,8 @@ while true; do ...@@ -53,6 +55,8 @@ while true; do
mode=plain ;; mode=plain ;;
--gc) --gc)
use_gc=1 ;; use_gc=1 ;;
--depth)
shift; clone_args+=(--depth "$1") ;;
--dump-options) --dump-options)
printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"} printf -- '--%s\n' "${opt_long[@]}" ${AUR_DEBUG+"${opt_hidden[@]}"}
printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g' printf -- '%s' "${opt_short}" | sed 's/.:\?/-&\n/g'
...@@ -62,7 +66,11 @@ while true; do ...@@ -62,7 +66,11 @@ while true; do
shift shift
done done
if ! [[ $ttl =~ -?[0-9]+ ]]; then if [[ $mode == "plain" ]] && [[ $archive == "metadata" ]]; then
printf >&2 'error: --plain cannot be used with --info\n'
exit 1
elif ! [[ $ttl =~ -?[0-9]+ ]]; then
printf >&2 "error: --ttl requires an integer ('%s' provided)\n" "$ttl" printf >&2 "error: --ttl requires an integer ('%s' provided)\n" "$ttl"
exit 1 exit 1
fi fi
...@@ -70,11 +78,11 @@ fi ...@@ -70,11 +78,11 @@ fi
mkdir -p "$AUR_ARCHIVE_ROOT" mkdir -p "$AUR_ARCHIVE_ROOT"
# aurweb git archive # aurweb git archive
if [[ ! -d $AUR_ARCHIVE_ROOT/.git ]]; then if [[ ! -d $AUR_ARCHIVE_ROOT/$archive/.git ]]; then
git clone "$AUR_ARCHIVE/$archive".git "$AUR_ARCHIVE_ROOT/$archive" git clone "${clone_args[@]}" "$AUR_ARCHIVE/$archive".git "$AUR_ARCHIVE_ROOT/$archive"
else else
git() { command git -C "$AUR_ARCHIVE_ROOT" "$@"; } git() { command git -C "$AUR_ARCHIVE_ROOT/$archive" "$@"; }
if (( ttl < 0 )); then if (( ttl < 0 )); then
: # skip upgrades : # skip upgrades
...@@ -90,7 +98,7 @@ else ...@@ -90,7 +98,7 @@ else
git fetch git fetch
rev_u=$(git rev-parse FETCH_HEAD) rev_u=$(git rev-parse FETCH_HEAD)
sec_d=$(git log "$rev_u" --pretty="format:%ct") sec_d=$(git log -1 "$rev_u" --pretty="format:%ct")
# Since any new revisions are retrieved by git-fetch, merge them # Since any new revisions are retrieved by git-fetch, merge them
# regardless of --ttl settings. To improve performance, `prefetch` tasks # regardless of --ttl settings. To improve performance, `prefetch` tasks
...@@ -103,15 +111,17 @@ else ...@@ -103,15 +111,17 @@ else
if (( use_gc )); then if (( use_gc )); then
git gc --aggressive git gc --aggressive
fi fi
fi fi >&2
cd "$AUR_ARCHIVE_ROOT/$archive" cd "$AUR_ARCHIVE_ROOT/$archive"
case $mode in case $mode in
cat) json)
cat "$pkglist" ;; tr -d '\n' < "$pkglist" | tr -s ' '
printf '\n' ;;
plain) plain)
tr -d '"][' "$pkglist" | tr -s ',' '\n' ;; # Relies on `pkgname` containing alphanumerics and @ . _ + -
tr -d '"][ ' < "$pkglist" | tr -s ',' '\n' ;;
none) none)
printf '%s\n' "$PWD/$pkglist" ;; printf '%s\n' "$PWD/$pkglist" ;;
esac esac
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment