[packages/rpm-build-tools: 1/2] add a tool to cleanup your packages dir

glen glen at pld-linux.org
Sat Nov 3 10:17:36 CET 2012


commit 053ce15429546e205ce48d07315b1a90b48d3f0b
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Sat Nov 3 11:15:57 2012 +0200

    add a tool to cleanup your packages dir

 purge-packages.sh | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
---
diff --git a/purge-packages.sh b/purge-packages.sh
new file mode 100755
index 0000000..b8ca00c
--- /dev/null
+++ b/purge-packages.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Purges packages/ checkouts
+# - if package has clean state, the dir is removed
+# - otherwise git gc is called
+set -e
+
+topdir=$(rpm -E %_topdir)
+purgedir=$topdir/purged
+cd "$topdir"
+
+if [ -d "$purgedir" ]; then
+	echo >&2 "Previous pruge dir exists: $purgedir, remove it to resume"
+	exit 1
+fi
+
+install -d $purgedir
+for pkg in */.git; do
+	pkg=${pkg%/.git}
+	cd "$pkg"
+	status=$(git status -s)
+
+	# FIXME: does not currently handle if some pushes are not made!
+	if [ -n "$status" ]; then
+		cat <<-EOF
+		* Package $pkg - Untracked files. Invoke gc
+
+		$status
+		EOF
+		git gc
+	else
+		cat <<-EOF
+		* Package $pkg - State clean. Removing
+		EOF
+		mv ../$pkg $purgedir
+	fi
+	cd ..
+done
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/rpm-build-tools.git/commitdiff/9ca405b6e7e95c41a2f6cfe6b32900355b75d903



More information about the pld-cvs-commit mailing list