* [PR PATCH] xbps-src: add purge-binpkgs action
@ 2024-02-14 4:57 classabbyamp
2024-02-16 13:46 ` [PR REVIEW] " ftpd
` (5 more replies)
0 siblings, 6 replies; 7+ messages in thread
From: classabbyamp @ 2024-02-14 4:57 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 562 bytes --]
There is a new pull request by classabbyamp against master on the void-packages repository
https://github.com/classabbyamp/void-packages begone-fowl-demons
https://github.com/void-linux/void-packages/pull/48715
xbps-src: add purge-binpkgs action
gets rid of binpkgs that don't match what's in srcpkgs/ (different version or missing) and cleans all repodatas.
WIP: need to document this better
#### Testing the changes
- I tested the changes in this PR: **briefly**
A patch file from https://github.com/void-linux/void-packages/pull/48715.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-begone-fowl-demons-48715.patch --]
[-- Type: text/x-diff, Size: 3615 bytes --]
From 31a0cc6c0abce0324301d37dc03ffc27af923350 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 13 Feb 2024 23:56:22 -0500
Subject: [PATCH] xbps-src: add purge-binpkgs action
---
common/xbps-src/shutils/purge_binpkgs.sh | 80 ++++++++++++++++++++++++
xbps-src | 6 ++
2 files changed, 86 insertions(+)
create mode 100644 common/xbps-src/shutils/purge_binpkgs.sh
diff --git a/common/xbps-src/shutils/purge_binpkgs.sh b/common/xbps-src/shutils/purge_binpkgs.sh
new file mode 100644
index 00000000000000..259e7ca9ec843f
--- /dev/null
+++ b/common/xbps-src/shutils/purge_binpkgs.sh
@@ -0,0 +1,80 @@
+# scans binpkgs for packages that don't match the current version and removes them.
+
+purge_binpkgs() {
+ local max cur percent pnew dir rdata arch template pkg ver rev
+ local binpkg pkgfile pkgver pkgname version repos
+ local -a binpkg_dirs templates binpkgs
+ local -A versions
+
+ if [ -z "$XBPS_REPOSITORY" ]; then
+ msg_error "The variable \$XBPS_REPOSITORY is not set."
+ exit 1
+ fi
+
+ # Scan all templates for their current versions
+ mapfile -t templates < <(find srcpkgs -mindepth 1 -maxdepth 1 -type d -printf "srcpkgs/%f/template\n")
+ max="${#templates[@]}"
+ cur=0
+ if [ -z "$max" ]; then
+ msg_error "No srcpkgs/*/template files found. Wrong working directory?"
+ exit 1
+ fi
+ percent=-1
+ for template in "${templates[@]}"; do
+ pkg="${template#*/}"
+ pkg="${pkg%/*}"
+ if [ ! -L "srcpkgs/$pkg" ]; then
+ ver="$(grep -Eh "^version=.*$" "${template}")"
+ rev="$(grep -Eh "^revision=.*$" "${template}")"
+ versions["$pkg"]="${ver#*=}_${rev#*=}"
+ fi
+ cur=$((cur + 1))
+ pnew=$((100 * cur / max))
+ if [ $pnew -ne $percent ]; then
+ percent="$pnew"
+ printf "\rScanning templates: %3d%% (%d/%d)" "$percent" "$cur" "$max"
+ fi
+ done
+ echo
+
+ binpkgs=("$XBPS_REPOSITORY"/**/*.xbps)
+ max=${#binpkgs[@]}
+ if [ -z "$max" ]; then
+ msg_error "No binpkgs found in '$XBPS_REPOSITORY'"
+ exit 1
+ fi
+ cur=0
+ for binpkg in "${binpkgs[@]}"; do
+ pkgfile="${binpkg##*/}"
+ pkgver="${pkgfile%.*.*}"
+ pkgname="$(find -P srcpkgs -maxdepth 2 -samefile "srcpkgs/${pkgver%-*}/template" 2>/dev/null | cut -d/ -f2)"
+ [ -z "$pkgname" ] && pkgname="${pkgver%-*}"
+ version="${pkgver##*-}"
+ # existing package
+ if [ -n "${versions[$pkgname]}" ]; then
+ # remove if not matching the template version
+ if ! xbps-uhelper cmpver "${versions[$pkgname]}" "$version"; then
+ rm -vf "$binpkg"
+ cur=$((cur + 1))
+ fi
+ else
+ # nonexistant package, remove
+ rm -vf "$binpkg"
+ cur=$((cur + 1))
+ fi
+ done
+
+ mapfile -t binpkg_dirs < <(find "$XBPS_REPOSITORY" -type d)
+ repos=0
+ for dir in "${binpkg_dirs[@]}"; do
+ for rdata in "$dir"/*-repodata; do
+ arch="${rdata##*/}"
+ arch="${arch%-repodata}"
+ XBPS_TARGET_ARCH="${arch}" xbps-rindex -c "$dir"
+ repos=$((repos + 1))
+ done
+ done
+ echo "Cleaned $cur/$max binpkgs in $XBPS_REPOSITORY"
+ echo "Cleaned $repos repositories in $XBPS_REPOSITORY"
+ echo "Done."
+}
diff --git a/xbps-src b/xbps-src
index 77695b9f510d34..760cf311d3e2e6 100755
--- a/xbps-src
+++ b/xbps-src
@@ -84,6 +84,9 @@ remove-autodeps
purge-distfiles
Removes all obsolete distfiles in <hostdir>/sources.
+purge-distfiles
+ Removes all obsolete packages in <hostdir>/binpkgs.
+
show <pkgname>
Show information for the specified package.
@@ -860,6 +863,9 @@ case "$XBPS_TARGET" in
list)
$XBPS_QUERY_CMD -l
;;
+ purge-binpkgs)
+ purge_binpkgs
+ ;;
purge-distfiles)
purge_distfiles
;;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PR REVIEW] xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
@ 2024-02-16 13:46 ` ftpd
2024-02-16 13:46 ` Calandracas606
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: ftpd @ 2024-02-16 13:46 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 177 bytes --]
New review comment by ftpd on void-packages repository
https://github.com/void-linux/void-packages/pull/48715#discussion_r1492478845
Comment:
Shouldn't it be `purge-binpkgs`?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PR REVIEW] xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
2024-02-16 13:46 ` [PR REVIEW] " ftpd
@ 2024-02-16 13:46 ` Calandracas606
2024-02-16 13:57 ` Calandracas606
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Calandracas606 @ 2024-02-16 13:46 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
New review comment by Calandracas606 on void-packages repository
https://github.com/void-linux/void-packages/pull/48715#discussion_r1492479280
Comment:
Typo? should this say `purge-binpkgs`
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PR REVIEW] xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
2024-02-16 13:46 ` [PR REVIEW] " ftpd
2024-02-16 13:46 ` Calandracas606
@ 2024-02-16 13:57 ` Calandracas606
2024-02-18 1:28 ` [PR PATCH] [Updated] " classabbyamp
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Calandracas606 @ 2024-02-16 13:57 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
New review comment by Calandracas606 on void-packages repository
https://github.com/void-linux/void-packages/pull/48715#discussion_r1492479280
Comment:
Typo? should this say `purge-binpkgs`
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PR PATCH] [Updated] xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
` (2 preceding siblings ...)
2024-02-16 13:57 ` Calandracas606
@ 2024-02-18 1:28 ` classabbyamp
2024-05-25 1:46 ` github-actions
2024-06-08 1:47 ` [PR PATCH] [Closed]: " github-actions
5 siblings, 0 replies; 7+ messages in thread
From: classabbyamp @ 2024-02-18 1:28 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 567 bytes --]
There is an updated pull request by classabbyamp against master on the void-packages repository
https://github.com/classabbyamp/void-packages begone-fowl-demons
https://github.com/void-linux/void-packages/pull/48715
xbps-src: add purge-binpkgs action
gets rid of binpkgs that don't match what's in srcpkgs/ (different version or missing) and cleans all repodatas.
WIP: need to document this better
#### Testing the changes
- I tested the changes in this PR: **briefly**
A patch file from https://github.com/void-linux/void-packages/pull/48715.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-begone-fowl-demons-48715.patch --]
[-- Type: text/x-diff, Size: 3635 bytes --]
From b2da60f68a153b1876f8416de3033623518ae000 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 13 Feb 2024 23:56:22 -0500
Subject: [PATCH] xbps-src: add purge-binpkgs action
---
common/xbps-src/shutils/purge_binpkgs.sh | 80 ++++++++++++++++++++++++
xbps-src | 6 ++
2 files changed, 86 insertions(+)
create mode 100644 common/xbps-src/shutils/purge_binpkgs.sh
diff --git a/common/xbps-src/shutils/purge_binpkgs.sh b/common/xbps-src/shutils/purge_binpkgs.sh
new file mode 100644
index 0000000000000..259e7ca9ec843
--- /dev/null
+++ b/common/xbps-src/shutils/purge_binpkgs.sh
@@ -0,0 +1,80 @@
+# scans binpkgs for packages that don't match the current version and removes them.
+
+purge_binpkgs() {
+ local max cur percent pnew dir rdata arch template pkg ver rev
+ local binpkg pkgfile pkgver pkgname version repos
+ local -a binpkg_dirs templates binpkgs
+ local -A versions
+
+ if [ -z "$XBPS_REPOSITORY" ]; then
+ msg_error "The variable \$XBPS_REPOSITORY is not set."
+ exit 1
+ fi
+
+ # Scan all templates for their current versions
+ mapfile -t templates < <(find srcpkgs -mindepth 1 -maxdepth 1 -type d -printf "srcpkgs/%f/template\n")
+ max="${#templates[@]}"
+ cur=0
+ if [ -z "$max" ]; then
+ msg_error "No srcpkgs/*/template files found. Wrong working directory?"
+ exit 1
+ fi
+ percent=-1
+ for template in "${templates[@]}"; do
+ pkg="${template#*/}"
+ pkg="${pkg%/*}"
+ if [ ! -L "srcpkgs/$pkg" ]; then
+ ver="$(grep -Eh "^version=.*$" "${template}")"
+ rev="$(grep -Eh "^revision=.*$" "${template}")"
+ versions["$pkg"]="${ver#*=}_${rev#*=}"
+ fi
+ cur=$((cur + 1))
+ pnew=$((100 * cur / max))
+ if [ $pnew -ne $percent ]; then
+ percent="$pnew"
+ printf "\rScanning templates: %3d%% (%d/%d)" "$percent" "$cur" "$max"
+ fi
+ done
+ echo
+
+ binpkgs=("$XBPS_REPOSITORY"/**/*.xbps)
+ max=${#binpkgs[@]}
+ if [ -z "$max" ]; then
+ msg_error "No binpkgs found in '$XBPS_REPOSITORY'"
+ exit 1
+ fi
+ cur=0
+ for binpkg in "${binpkgs[@]}"; do
+ pkgfile="${binpkg##*/}"
+ pkgver="${pkgfile%.*.*}"
+ pkgname="$(find -P srcpkgs -maxdepth 2 -samefile "srcpkgs/${pkgver%-*}/template" 2>/dev/null | cut -d/ -f2)"
+ [ -z "$pkgname" ] && pkgname="${pkgver%-*}"
+ version="${pkgver##*-}"
+ # existing package
+ if [ -n "${versions[$pkgname]}" ]; then
+ # remove if not matching the template version
+ if ! xbps-uhelper cmpver "${versions[$pkgname]}" "$version"; then
+ rm -vf "$binpkg"
+ cur=$((cur + 1))
+ fi
+ else
+ # nonexistant package, remove
+ rm -vf "$binpkg"
+ cur=$((cur + 1))
+ fi
+ done
+
+ mapfile -t binpkg_dirs < <(find "$XBPS_REPOSITORY" -type d)
+ repos=0
+ for dir in "${binpkg_dirs[@]}"; do
+ for rdata in "$dir"/*-repodata; do
+ arch="${rdata##*/}"
+ arch="${arch%-repodata}"
+ XBPS_TARGET_ARCH="${arch}" xbps-rindex -c "$dir"
+ repos=$((repos + 1))
+ done
+ done
+ echo "Cleaned $cur/$max binpkgs in $XBPS_REPOSITORY"
+ echo "Cleaned $repos repositories in $XBPS_REPOSITORY"
+ echo "Done."
+}
diff --git a/xbps-src b/xbps-src
index 77695b9f510d3..b6542d4c4f255 100755
--- a/xbps-src
+++ b/xbps-src
@@ -81,6 +81,9 @@ remove <pkgname>
remove-autodeps
Removes all package dependencies that were installed automatically.
+purge-binpkgs
+ Removes all obsolete packages in <hostdir>/binpkgs.
+
purge-distfiles
Removes all obsolete distfiles in <hostdir>/sources.
@@ -860,6 +863,9 @@ case "$XBPS_TARGET" in
list)
$XBPS_QUERY_CMD -l
;;
+ purge-binpkgs)
+ purge_binpkgs
+ ;;
purge-distfiles)
purge_distfiles
;;
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
` (3 preceding siblings ...)
2024-02-18 1:28 ` [PR PATCH] [Updated] " classabbyamp
@ 2024-05-25 1:46 ` github-actions
2024-06-08 1:47 ` [PR PATCH] [Closed]: " github-actions
5 siblings, 0 replies; 7+ messages in thread
From: github-actions @ 2024-05-25 1:46 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
New comment by github-actions[bot] on void-packages repository
https://github.com/void-linux/void-packages/pull/48715#issuecomment-2130654236
Comment:
Pull Requests become stale 90 days after last activity and are closed 14 days after that. If this pull request is still relevant bump it or assign it.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PR PATCH] [Closed]: xbps-src: add purge-binpkgs action
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
` (4 preceding siblings ...)
2024-05-25 1:46 ` github-actions
@ 2024-06-08 1:47 ` github-actions
5 siblings, 0 replies; 7+ messages in thread
From: github-actions @ 2024-06-08 1:47 UTC (permalink / raw)
To: ml
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
There's a closed pull request on the void-packages repository
xbps-src: add purge-binpkgs action
https://github.com/void-linux/void-packages/pull/48715
Description:
gets rid of binpkgs that don't match what's in srcpkgs/ (different version or missing) and cleans all repodatas.
WIP: need to document this better
#### Testing the changes
- I tested the changes in this PR: **briefly**
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-06-08 1:47 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-14 4:57 [PR PATCH] xbps-src: add purge-binpkgs action classabbyamp
2024-02-16 13:46 ` [PR REVIEW] " ftpd
2024-02-16 13:46 ` Calandracas606
2024-02-16 13:57 ` Calandracas606
2024-02-18 1:28 ` [PR PATCH] [Updated] " classabbyamp
2024-05-25 1:46 ` github-actions
2024-06-08 1:47 ` [PR PATCH] [Closed]: " github-actions
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).