summaryrefslogtreecommitdiffstats
path: root/.graveyard/punani/bin
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-05 13:07:46 +0100
committertv <tv@nomic.retiolum>2013-11-05 13:07:46 +0100
commitae627d2aa73ea6862af3985f1c07e95c6d493275 (patch)
treedea1eb74dccd7a14eff03e03baf2eed239a5ac72 /.graveyard/punani/bin
parentbf87133ae8e2ce6eb7923dc22c29b8f162c8756a (diff)
//punani: RIP
Diffstat (limited to '.graveyard/punani/bin')
-rwxr-xr-x.graveyard/punani/bin/punani70
1 files changed, 70 insertions, 0 deletions
diff --git a/.graveyard/punani/bin/punani b/.graveyard/punani/bin/punani
new file mode 100755
index 00000000..23ba5e00
--- /dev/null
+++ b/.graveyard/punani/bin/punani
@@ -0,0 +1,70 @@
+#! /bin/sh
+set -euf
+
+PUNANI_HOST="${PUNANI_HOST-http://euer.krebsco.de:9111}"
+ACTION="$1"; shift
+PKGS="$*"
+
+## find package manager
+if ! :; then : # dummy case, so the rest has a common format
+
+elif for PACKER_CMD in aptitude apt-get
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='-y install'
+ REMOVE_PARAM='-y remove'
+
+elif for PACKER_CMD in bauerbill packer yaourt pacman
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='--noconfirm -S --needed'
+ REMOVE_PARAM='-Rcs'
+
+elif for PACKER_CMD in yum
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='-y install'
+ REMOVE_PARAM='-y remove'
+
+elif for PACKER_CMD in brew
+ do type $PACKER_CMD 2>/dev/null 1>&2 && break; done; then
+ INSTALL_PARAM='install'
+ REMOVE_PARAM='remove'
+
+
+
+else
+ echo "Error 2: no known package manager found; no punani for you!" >&2
+ exit 23
+fi
+
+## find package name
+if test -n "$PKGS"; then
+ for PKG in $PKGS; do
+ RES="`wget -O- $PUNANI_HOST/$PACKER_CMD/$PKG 2>/dev/null || :`"
+ if [ ! "$RES" ]; then
+ echo "Error 2: could not resolve '$PKG'; no punani for you!" >&2
+ exit 23
+ fi
+ RESOLVED="${RESOLVED+$RESOLVED }$RES"
+ done
+else
+ echo "Error 1: no PACKAGE specified." >&2
+ ACTION="usage"
+fi
+
+## dispatch
+case "$ACTION" in
+ install)
+ set -x
+ for PKG in $RESOLVED; do
+ sudo $PACKER_CMD $INSTALL_PARAM $PKG || echo "Cannot install $PKG!"
+ done
+ ;;
+ remove)
+ set -x
+ for PKG in $RESOLVED; do
+ sudo $PACKER_CMD $REMOVE_PARAM $PKG || echo "Cannot remove $PKG!"
+ done
+ ;;
+ *)
+ echo "usage: `basename $0` (install|remove) PACKAGE..."
+ exit 23
+esac