summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README2
-rwxr-xr-xxgensum21
2 files changed, 18 insertions, 5 deletions
diff --git a/README b/README
index 253c219..4f9efa8 100644
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ https://github.com/voidlinux/xbps
   xdiff [-u|-l] [DIR] - merge/diff/list XBPS .new-* files
   xdistdir - figure out XBPS_DISTDIR
   xdowngrade PKGS.xbps... - install XBPS package directly from .xbps file
-  xgensum [-i] TEMPLATE - update SHA256 sums in templates
+  xgensum [-f] [-i] TEMPLATE - update SHA256 sums in templates
   xgrep PATTERN PKGS... - search files limited to XBPS package contents
   xhog - list installed XBPS packages ordered by size
   xlg PKG - open short commit log for XBPS template
diff --git a/xgensum b/xgensum
index c22a43b..38b1136 100755
--- a/xgensum
+++ b/xgensum
@@ -1,5 +1,9 @@
 #!/bin/bash
-# xgensum [-i] TEMPLATE - update SHA256 sums in templates
+# xgensum [-f] [-i] TEMPLATE - update SHA256 sums in templates
+
+case "$1" in
+	-f) f=$1; shift
+esac
 
 case "$1" in
 	-i*) i=$1; shift
@@ -8,17 +12,26 @@ esac
 if [ -f $1 ]; then
 	. "$1"
 elif [ -f $1/template ]; then
-	exec "$0" $i "$1/template"
+	exec "$0" $f $i "$1/template"
 elif [ -f template ]; then
-	exec "$0" $i template
+	exec "$0" $f $i template
 else
-	echo Usage: gensum TEMPLATE
+	echo 'Usage: xgensum [-f] [-i] TEMPLATE'
 fi
 
 XBPS_DISTDIR=$(xdistdir)
 XBPS_SRCDISTDIR=$($XBPS_DISTDIR/xbps-src show-var XBPS_SRCDISTDIR | tail -1)
 srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
 
+if [ "$f" = -f ]; then
+	for f in $distfiles; do
+		curfile=$(basename "${f#*>}")
+		distfile="$srcdir/$curfile"
+		rm -vf "$distfile"
+	done
+	$XBPS_DISTDIR/xbps-src -I clean $pkgname
+fi
+
 $XBPS_DISTDIR/xbps-src -I fetch $pkgname
 
 sums=""