summaryrefslogtreecommitdiffstats
path: root/ship/src/punani
blob: 2c956f02f9c02a0241cde105521d36f03fdc5e2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh
#@info
#@include punani
punani(){
  _punani_usage='punani {install,remove,has,owner} PACKAGE...'
  _punani_select_packer || die 'no package manager found; no punani for you!'

  ACTION="$1"; shift

  if test $# = 0; then
    error 'no PACKAGE specified.'
    die "usage: $_punani_usage"
  fi

  for PKG; do
    RES="`_punani_resolve_package $PKG`" ||
      die "could not resolve '$PKG'; no punani for you!"

    case "$ACTION" in
      install)
        if punani_has $RES; then
          info "$RES already installed, skipping"
        else
          punani_install $RES || error "cannot install $RES with $PACKER"
        fi
        ;;
      remove)
        if ! punani_has $RES; then
          info "$RES not installed, skipping"
        else
          punani_remove $RES || error "cannot install $RES with $PACKER"
        fi
        ;;
      has)
        if punani_has $RES; then
          info "$RES is installed"
        else
          info "$RES is not installed"
        fi
        ;;
      owner)
        punani_owner $RES
        ;;
      *)
        error "bad action: $ACTION"
        die "usage: $_punani_usage"
    esac
  done
}
punani "$@"