Github messages for voidlinux
 help / color / mirror / Atom feed
From: Chocimier <Chocimier@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] xbps-src: add purge-binpkgs target
Date: Sat, 16 Jul 2022 21:49:43 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-38098@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 502 bytes --]

There is a new pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org purge-binpkgs
https://github.com/void-linux/void-packages/pull/38098

xbps-src: add purge-binpkgs target
Removes from local repository binary packages which
do not match template version.
Keeps in place packages for which template is missing.

Helps to sidestep #31347


A patch file from https://github.com/void-linux/void-packages/pull/38098.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-purge-binpkgs-38098.patch --]
[-- Type: text/x-diff, Size: 2934 bytes --]

From cb76c36a6acf71e0a0808a7ed2558c144a243dba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Sat, 16 Jul 2022 18:48:47 +0200
Subject: [PATCH] xbps-src: add purge-binpkgs target

Removes from local repository binary packages which
do not match template version.
Keeps in place packages for which template is missing.
---
 common/xbps-src/shutils/purge_binpkgs.sh | 35 ++++++++++++++++++++++++
 xbps-src                                 |  8 ++++++
 2 files changed, 43 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 000000000000..2e1c8135e28c
--- /dev/null
+++ b/common/xbps-src/shutils/purge_binpkgs.sh
@@ -0,0 +1,35 @@
+# vim: set ts=4 sw=4 et:
+
+purge_binpkgs() {
+    purge_directory() {
+        export XBPS_TARGET_ARCH="${XBPS_CROSS_BUILD:-${XBPS_MACHINE}}"
+        for filepath in "${1}"/*."$XBPS_TARGET_ARCH".xbps; do
+            ( # read_pkg exits is some cases. Use subshell to continue loop.
+                filename=${filepath##*/}
+                pkgname=${filename%-*.${XBPS_TARGET_ARCH}.xbps}
+                if [ "${pkgname%-dbg}" != "${pkgname}" ] && ! [ -e "${XBPS_SRCPKGDIR}/${pkgname}/template" ] && [ -e "${XBPS_SRCPKGDIR}/${pkgname%-dbg}/template" ]; then
+                    pkgname="${pkgname%-dbg}"
+                fi
+                export XBPS_TARGET_PKG="${pkgname}"
+                read_pkg ignore-problems
+                template_version="${version}_${revision}"
+                binpkg_version=${filename%.${XBPS_TARGET_ARCH}.xbps}
+                binpkg_version=${binpkg_version##*-}
+                if [ "${template_version}" = "_" ]; then
+                    :
+                elif [ "${binpkg_version}" != "${template_version}" ]; then
+                    rm -v "$filepath"
+                fi
+            )
+        done
+        xbps-rindex -c "${1}"
+        for i in debug multilib nonfree; do
+            if [ -d "${1}/${i}" ]; then
+                purge_directory "${1}/${i}"
+            fi
+        done
+    }
+
+    purge_directory "$XBPS_REPOSITORY"
+}
+
diff --git a/xbps-src b/xbps-src
index 4e8349091708..8ea7e0c5bc22 100755
--- a/xbps-src
+++ b/xbps-src
@@ -78,6 +78,11 @@ remove <pkgname>
 remove-autodeps
     Removes all package dependencies that were installed automatically.
 
+purge-binpkgs
+    Removes from local repository binary packages which
+    do not match template version.
+    Keeps in place packages for which template is missing.
+
 purge-distfiles
     Removes all obsolete distfiles in <hostdir>/sources.
 
@@ -824,6 +829,9 @@ case "$XBPS_TARGET" in
     purge-distfiles)
         purge_distfiles
         ;;
+    purge-binpkgs)
+        purge_binpkgs
+        ;;
     show)
         read_pkg ignore-problems
         show_pkg $XBPS_PRINT_VARIABLES

             reply	other threads:[~2022-07-16 19:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-16 19:49 Chocimier [this message]
2022-07-16 20:58 ` Duncaen
2022-10-15  2:16 ` github-actions
2022-10-30  2:14 ` [PR PATCH] [Closed]: " github-actions

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-38098@inbox.vuxu.org \
    --to=chocimier@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).