about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-09-23 15:14:18 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-09-23 15:14:18 +0200
commit4fc6fbf76f1b9ed06c281b314925f694f7ece72a (patch)
tree3edb05da4b418d31b32f6b1d87794bbb2d7bf614
parent4ed63d17a32b2f8c3939f0465adb00b1f07c018a (diff)
downloadxtools-4fc6fbf76f1b9ed06c281b314925f694f7ece72a.tar.gz
xtools-4fc6fbf76f1b9ed06c281b314925f694f7ece72a.tar.xz
xtools-4fc6fbf76f1b9ed06c281b314925f694f7ece72a.zip
add xi
-rw-r--r--README1
-rwxr-xr-xxi20
2 files changed, 21 insertions, 0 deletions
diff --git a/README b/README
index 8debe7b..c915e18 100644
--- a/README
+++ b/README
@@ -14,6 +14,7 @@ https://github.com/voidlinux/xbps
   xgensum [-f] [-i] TEMPLATE - update SHA256 sums in templates
   xgrep PATTERN PKGS... - search files limited to XBPS package contents
   xhog - list installed XBPS packages ordered by size
+  xi PKGS... - like xbps-install -S, but take cwd repo and sudo/su into account
   xlg PKG - open short commit log for XBPS template
   xlint TEMPLATE - scan XBPS template for common mistakes
   xlocate [-u | PATTERN] - locate files in all XBPS packages
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 "$@"