summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-14 13:23:07 +0100
committertv <tv@nomic.retiolum>2013-11-14 13:23:07 +0100
commitfb6e147d3ccc17a79cbb2bd91d154b6d9570228d (patch)
tree2afee6fdacd7d7db15b78025a9a2fe4cf6cbc0ce
parent552fad7605bb3befe1928a8f1fdb1a129acd5c4b (diff)
ship punani: abstract has/install/remove
-rw-r--r--ship/lib/punani33
1 files changed, 26 insertions, 7 deletions
diff --git a/ship/lib/punani b/ship/lib/punani
index 8eef474b..8efa9e8d 100644
--- a/ship/lib/punani
+++ b/ship/lib/punani
@@ -20,6 +20,21 @@ _punani_brew_install(){ brew install "$@"; }
_punani_brew_remove(){ brew remove "$@";}
_punani_brew_has(){ error "not implemented"; return 1 ;}
+## usage: _punani_has PACKAGE
+_punani_has() {
+ eval "_punani_${PACKER}_has \"\$1\""
+}
+
+## usage: _punani_install PACKAGE
+_punani_install() {
+ eval "_punani_${PACKER}_install \"\$1\""
+}
+
+## usage: _punani_remove PACKAGE
+_punani_remove() {
+ eval "_punani_${PACKER}_remove \"\$1\""
+}
+
_punani_usage='punani {install,remove,has} PACKAGE...'
punani(){
for p in ${KNOWN_PACKERS:-null}; do
@@ -39,17 +54,21 @@ punani(){
case "$ACTION" in
install)
- eval _punani_${PACKER}_has $RES && info "$RES already installed, skipping" && continue
- ! is_root && error "punani requires super-user rights for installing" && return 1
- eval _punani_${PACKER}_install $RES || error "cannot install $RES with $PACKER"
+ if _punani_has $RES; then
+ info "$RES already installed, skipping"
+ else
+ _punani_install $RES || error "cannot install $RES with $PACKER"
+ fi
;;
remove)
- ! eval _punani_${PACKER}_has $RES && info "$RES not installed, skipping" && continue
- ! is_root && error "punani requires super-user rights for removing" && return 1
- eval _punani_${PACKER}_remove $RES || error "cannot install $RES with $PACKER"
+ if ! _punani_has $RES; then
+ info "$RES not installed, skipping"
+ else
+ _punani_remove $RES || error "cannot install $RES with $PACKER"
+ fi
;;
has)
- if eval _punani_${PACKER}_has $RES ;then
+ if _punani_has $RES; then
info "$RES is installed"
else
info "$RES is not installed"