about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--README2
-rwxr-xr-xxbulk31
2 files changed, 23 insertions, 10 deletions
diff --git a/README b/README
index 91d9833..ef26b53 100644
--- a/README
+++ b/README
@@ -3,7 +3,7 @@
 These are a few small utilities for use with XBPS:
 https://github.com/voidlinux/xbps
 
-  xbulk [-n] [-k] [-xbps_src_flags] PKG... - simple XBPS bulk builder
+  xbulk [-n] [-k] [xbps-src flags...] PKGS... - simple XBPS bulk builder
   xbump PKGNAME [git commit options] - git commit a version bump
   xdiff [-u] [DIR] - merge XBPS .new-* files
   xdistdir - figure out XBPS_DISTDIR
diff --git a/xbulk b/xbulk
index 4fe17f1..833910f 100755
--- a/xbulk
+++ b/xbulk
@@ -1,20 +1,33 @@
 #!/bin/sh
-# xbulk [-n] [-k] [-xbps_src_flags] PKG... - simple XBPS bulk builder
+# xbulk [-n] [-k] [xbps-src flags...] PKGS... - simple XBPS bulk builder
 
 ARGS=
 MAKEARGS=
+PKGS=
+
+mainpkg() {
+	dir=$(readlink -f srcpkgs/"$1")
+	echo ${dir##*/}
+}
 
-{
 for pkg; do
-case $pkg in
-	-n|-k) MAKEARGS="$MAKEARGS $pkg";;
-	-*) ARGS="$ARGS $pkg";;
-	*)
+	case $pkg in
+		-n|-k) MAKEARGS="$MAKEARGS $pkg";;
+		-*) ARGS="$ARGS $pkg";;
+		*) PKGS="$PKGS
+$(mainpkg $pkg)"
+	esac
+done
+
+{
+for pkg in $PKGS; do
 	echo all: pkg-$pkg
-	for dep in $(./xbps-src show-build-deps $pkg | sed '1d;s|[<>].*$||g'); do
-		echo pkg-$pkg: pkg-$dep
+	for dep in $(./xbps-src show-build-deps $pkg |
+			sed '1d;s|[<>].*$||g'); do
+		mainpkg $dep |
+		grep -Fx "$PKGS" |
+		sed 's/^/pkg-'$pkg': pkg-/'
 	done
-esac
 done
 printf '%s\n' pkg-%: "	pkg=\$@; ./xbps-src $ARGS pkg \$\${pkg#pkg-}"
 } | make -f - $MAKEARGS