about summary refs log tree commit diff
path: root/xi
diff options
context:
space:
mode:
Diffstat (limited to 'xi')
-rwxr-xr-xxi20
1 files changed, 20 insertions, 0 deletions
diff --git a/xi b/xi
new file mode 100755
index 0000000..63a6db3
--- /dev/null
+++ b/xi
@@ -0,0 +1,20 @@
+#!/bin/sh
+# xi PKGS... - like xbps-install -S, but take cwd repo and sudo/su into account
+
+BRANCH=$(git symbolic-ref -q --short HEAD 2>/dev/null)
+ADDREPO="--repository=hostdir/binpkgs/$BRANCH
+	--repository=../hostdir/binpkgs/$BRANCH
+	--repository=../../hostdir/binpkgs/$BRANCH
+	--repository=hostdir/binpkgs
+	--repository=../hostdir/binpkgs
+	--repository=../../hostdir/binpkgs"
+
+SUDO=
+if command -v sudo >/dev/null &&
+   sudo -l | grep -q -e ' ALL$' -e xbps-install; then
+	SUDO=sudo
+elif [ "$(whoami)" != root ]; then
+	SUDO='su root -c '\''"$@"'\'' -- -'
+fi
+
+$SUDO xbps-install -S "$@"