about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README2
-rwxr-xr-xgensum44
-rwxr-xr-xmindep33
3 files changed, 79 insertions, 0 deletions
diff --git a/README b/README
index 23fadf8..5822c02 100644
--- a/README
+++ b/README
@@ -3,6 +3,8 @@
 These are a few small utilities for use with XBPS:
 https://github.com/voidlinux/xbps
 
+  gensum [-i] TEMPLATE - update SHA256 sums in templates
+  mindep PKGS... - minimize list of PKGS by removing implicit dependencies
   xdiff [DIR] - merge XBPS .new-* files
   xgrep PATTERN PKGS... - search files limited to XBPS package contents
   xlg PKG - open short commit log for XBPS template
diff --git a/gensum b/gensum
new file mode 100755
index 0000000..4eb89ae
--- /dev/null
+++ b/gensum
@@ -0,0 +1,44 @@
+#!/bin/bash
+# gensum [-i] TEMPLATE - update SHA256 sums in templates
+
+case "$1" in
+	-i*) i=$1; shift
+esac
+
+if [ -f $1 ]; then
+	. "$1"
+elif [ -f $1/template ]; then
+	exec "$0" $i "$1/template"
+elif [ -f template ]; then
+	exec "$0" $i template
+else
+	echo Usage: gensum TEMPLATE
+fi
+
+if [ -d ../../hostdir/sources ]; then
+	XBPS_SRCDISTDIR=../../hostdir/sources
+elif [ -d ../hostdir/sources ]; then
+	XBPS_SRCDISTDIR=../hostdir/sources
+elif [ -d hostdir/sources ]; then
+	XBPS_SRCDISTDIR=hostdir/sources
+else
+	XBPS_SRCDISTDIR=~/xbps-packages/hostdir/sources/
+fi
+
+srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
+
+$XBPS_SRCDISTDIR/../../xbps-src -I fetch $pkgname
+
+sums=""
+for f in $distfiles; do
+	curfile=$(basename "${f#*>}")
+	distfile="$srcdir/$curfile"
+	sum=$(sha256sum $distfile)
+	sums+="${sum%  *}\n "
+done
+
+sed $i -e "/^checksum=/,/^[^ \t]/{
+		/^[ \t]/d
+		s/^checksum=.*/checksum=\"${sums%\n }\"/
+		/^checksum=\"[^ ]*\"/s/\"//g
+	}" "$1"
diff --git a/mindep b/mindep
new file mode 100755
index 0000000..27aa22f
--- /dev/null
+++ b/mindep
@@ -0,0 +1,33 @@
+#!/bin/sh
+# mindep PKGS... - minimize list of PKGS by removing implicit dependencies
+
+rdeps() {
+	for pkg; do
+		echo "$pkg>=0"
+		xbps-query -Rx $pkg
+	done | xargs -d'\n' -rn1 xbps-uhelper getpkgdepname | sort -u
+}
+
+RDEPS="$@"
+ORDEPS=
+
+while [ "$RDEPS" != "$ORDEPS" ]; do
+	ORDEPS=$RDEPS
+	RDEPS=$(rdeps $RDEPS)
+	echo RDEPS $RDEPS
+done	
+
+ORDEPS=
+while [ "$RDEPS" != "$ORDEPS" ]; do
+	ORDEPS=$RDEPS
+	SAT=
+	for pkg in $RDEPS; do
+		SAT=$({
+		printf '%s\n' $SAT
+		rdeps $pkg | grep -vx $pkg
+		} | sort -u)
+	done
+	RDEPS=$(echo "$RDEPS" | grep -Fvx -e "$SAT" | sort -u)
+done	
+
+echo $RDEPS