summary refs log tree commit diff
path: root/mindep
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2014-07-31 15:59:20 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2014-07-31 15:59:20 +0200
commit88ebd48d4460fa750f1d3d4300791854492a90a8 (patch)
tree740c3c5bda3f4e5ca15b7ca6abd898c509179fac /mindep
parent8b1ac0bf2c0434749f5e7d87d9840c2030228174 (diff)
downloadxtools-88ebd48d4460fa750f1d3d4300791854492a90a8.tar.gz
xtools-88ebd48d4460fa750f1d3d4300791854492a90a8.tar.xz
xtools-88ebd48d4460fa750f1d3d4300791854492a90a8.zip
Add gensum and mindep
Diffstat (limited to 'mindep')
-rwxr-xr-xmindep33
1 files changed, 33 insertions, 0 deletions
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