summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLevente Polyak <anthraxx@archlinux.org>2022-09-12 02:24:25 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-05-19 22:27:12 +0200
commit95424a88eb11e06b7290fcabd6e3a6cf2b9cc9b3 (patch)
tree3fc623155d87ca6be0a60f0d8ae570e3ec39a5f8
parent3d3176beb6eb0319809be386cd903fa03bdabc73 (diff)
downloaddevtools-95424a88eb11e06b7290fcabd6e3a6cf2b9cc9b3.tar.xz
pkgrepo: add option to clone all existing packages
This can be very handy for cache warming on the repo server or to perform mass operations on all PKGBUILDs. Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
-rw-r--r--contrib/completion/zsh/_devtools.in1
-rw-r--r--src/pkgrepo.in17
2 files changed, 18 insertions, 0 deletions
diff --git a/contrib/completion/zsh/_devtools.in b/contrib/completion/zsh/_devtools.in
index f6417df..06e05e1 100644
--- a/contrib/completion/zsh/_devtools.in
+++ b/contrib/completion/zsh/_devtools.in
@@ -24,6 +24,7 @@ _pkgrepo_cmds=(
_pkgrepo_clone_args=(
'(-m --maintainer=)'{-m,--maintainer=}'[Clone all packages of the named maintainer]:maintainer:'
'(-u --unprivileged)'{-u,--unprivileged}'[Read-only access without packager info as Git author]'
+ '--universe[Clone all existing packages, useful for cache warming]'
'(-h --help)'{-h,--help}'[Display usage]'
'*:packages:_devtools_completions_all_packages'
)
diff --git a/src/pkgrepo.in b/src/pkgrepo.in
index 2804cba..13f8847 100644
--- a/src/pkgrepo.in
+++ b/src/pkgrepo.in
@@ -49,6 +49,7 @@ usage_clone() {
-m, --maintainer=NAME Clone all packages of the named maintainer
-u, --unprivileged Clone package with read-only access and without
packager info as Git author.
+ --universe Clone all existing packages, useful for cache warming
-h, --help Show this help text
_EOF_
}
@@ -83,6 +84,7 @@ CONFIGURE=0
# options
GIT_REPO_BASE_URL=${GIT_PACKAGING_URL_SSH}
UNPRIVILEGED=0
+CLONE_ALL=0
MAINTAINER=
PACKAGER_NAME=
PACKAGER_EMAIL=
@@ -137,6 +139,10 @@ if (( CLONE )); then
MAINTAINER="${1#*=}"
shift
;;
+ --all)
+ CLONE_ALL=1
+ shift
+ ;;
--)
shift
break
@@ -214,6 +220,17 @@ if [[ -n ${MAINTAINER} ]]; then
stat_done
fi
+# Query all released packages
+if (( CLONE_ALL )); then
+ stat_busy "Query all released packages"
+ max_pages=$(curl --silent --location --fail --retry 3 --retry-delay 3 "https://archlinux.org/packages/search/json/?sort=name" | jq -r '.num_pages')
+ mapfile -t pkgbases < <(for page in $(seq "${max_pages}"); do
+ curl --silent --location --fail --retry 3 --retry-delay 3 "https://archlinux.org/packages/search/json/?sort=name&page=${page}" | jq -r '.results[].pkgbase'
+ stat_progress
+ done | sort --unique)
+ stat_done
+fi
+
for pkgbase in "${pkgbases[@]}"; do
if (( CLONE )); then
if [[ ! -d ${pkgbase} ]]; then