From b1bf056f831456ad72a6e2fecf9849ad53afe1b9 Mon Sep 17 00:00:00 2001 From: Joel Beckmeyer Date: Fri, 10 Oct 2025 10:06:58 -0400 Subject: [PATCH] new xxclean xbps helper script --- dot_local/bin/executable_xxclean | 37 ++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 dot_local/bin/executable_xxclean diff --git a/dot_local/bin/executable_xxclean b/dot_local/bin/executable_xxclean new file mode 100644 index 0000000..d0810bc --- /dev/null +++ b/dot_local/bin/executable_xxclean @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +# Get current git branch +branch=$(git rev-parse --abbrev-ref HEAD) + +# Construct path +binpkgs_dir="$XBPS_DISTDIR/hostdir/binpkgs/${branch}" + +# Check if directory exists +if [ ! -d "$binpkgs_dir" ]; then + echo "Error: Directory '$binpkgs_dir' does not exist" + exit 1 +fi + +echo "Cleaning old packages in: $binpkgs_dir" +echo "Current branch: $branch" +echo + +# Get unique package names (strip version info) +for pkg in $(find "$binpkgs_dir" -maxdepth 1 -name '*.xbps' -type f -printf '%f\n' | sed 's/-[0-9].*//' | sort -u); do + # Find all versions of this package, sorted by modification time (newest first) + # Keep only the first (newest), remove the rest + find "$binpkgs_dir" -maxdepth 1 -name "${pkg}-*.xbps" -type f -printf '%T@ %p\n' | \ + sort -rn | \ + tail -n +2 | \ + cut -d' ' -f2- | \ + while read -r old_pkg; do + echo "Removing: $(basename "$old_pkg")" + rm -f "$old_pkg" + done +done + +xbps-rindex -c "$binpkgs_dir" + +echo "Done!"