about summary refs log tree commit diff
path: root/xgensum
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-09-15 00:33:09 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2014-09-15 00:33:09 +0200
commit6c64b2c423c551d83799fcc868c7e0a05e02bf63 (patch)
treee08fb19d65993f17f29deb82e488db68e8b3401f /xgensum
parent685083146fdd618ca4314657665f014a82ba981b (diff)
downloadxtools-6c64b2c423c551d83799fcc868c7e0a05e02bf63.tar.gz
xtools-6c64b2c423c551d83799fcc868c7e0a05e02bf63.tar.xz
xtools-6c64b2c423c551d83799fcc868c7e0a05e02bf63.zip
mv gensum xgensum
Diffstat (limited to 'xgensum')
-rwxr-xr-xxgensum44
1 files changed, 44 insertions, 0 deletions
diff --git a/xgensum b/xgensum
new file mode 100755
index 0000000..3df9e82
--- /dev/null
+++ b/xgensum
@@ -0,0 +1,44 @@
+#!/bin/bash
+# xgensum [-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"