summaryrefslogtreecommitdiffstats
path: root/ship
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-11-14 12:03:26 +0100
committertv <tv@nomic.retiolum>2013-11-14 12:06:06 +0100
commit172580f2642426a4ee01ef039d9ba126482bb357 (patch)
tree1fadfaeab29347345f77670f7c530663a2d892f2 /ship
parentbabcdd4b4d203c98e3e2c7a5e70b9f1273b60f7c (diff)
ship punani: simplify package manager selection
Diffstat (limited to 'ship')
-rw-r--r--ship/lib/punani19
1 files changed, 9 insertions, 10 deletions
diff --git a/ship/lib/punani b/ship/lib/punani
index ca2e3534..e07d77af 100644
--- a/ship/lib/punani
+++ b/ship/lib/punani
@@ -5,31 +5,30 @@
_punani_resolve_package(){
eval "echo \"\${_punanidb_${PACKER}_$1}\""
}
+
+KNOWN_PACKERS='pacman aptget yum brew'
+_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;}
+_punani_pacman_remove(){ pacman -Rcs "$@" ;}
+_punani_pacman_has(){ pacman -Q "$1" >/dev/null;}
_punani_aptget_install(){ apt-get -y install "$@" ;}
_punani_aptget_remove(){ apt-get -y remove "$@" ;}
_punani_aptget_has() { dpkg -s "$1" | grep -q "Status: install";}
_punani_yum_install(){ yum -y install "$@" ;}
_punani_yum_remove(){ yum -y remove "$@" ;}
_punani_yum_has() { rpm -qa --qf "%{NAME}\n"| egrep "^${1}\$" >/dev/null ;}
-_punani_pacman_install(){ pacman --noconfirm -S --needed "$@" ;}
-_punani_pacman_remove(){ pacman -Rcs "$@" ;}
-_punani_pacman_has(){ pacman -Q "$1" >/dev/null;}
_punani_brew_install(){ brew install "$@"; }
_punani_brew_remove(){ brew remove "$@";}
_punani_brew_has(){ error "not implemented"; return 1 ;}
punani(){
+ for PACKER in ${KNOWN_PACKERS:-null}; do
+ exists "$PACKER" && info "using $PACKER" && break
+ done || die 'Error 2: no package manager found; no punani for you!'
+
ACTION="$1"; shift
PKGS="$*"
- for p in apt-get pacman yum brew;do
- exists "$p" && PACKER=`printf "%s" "$p" | sed 's/-//g'` && break
- done
-
- [ -z "${PACKER:-}" ] && error "Error 2: no known package manager found; no punani for you!" && return 1
- info "using $PACKER for install"
[ -z "$PKGS" ] && error "no PACKAGE specified." && ACTION="usage"
-
for PKG in $PKGS; do
RES="`_punani_resolve_package $PKG`"
test -z "$RES" && error "could not resolve '$PKG'; no punani for you!"&& return 23