blob: 618ce6ad5d0ba643f24191c60b2cee99cee503aa (
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env bash
# OS independent package management
pkg() {
local system="bashtard/pkg"
local action=$1 ; shift
local pkg
pkg="$(config "pkg.$1")" ; shift
if [[ -z $pkg ]]
then
crit "$system" "No package name for $pkg"
return 1
fi
if [[ "$(type -t "pkg_$action")" != "function" ]]
then
crit "$system" "Invalid package manager action $action"
return 1
fi
"pkg_$action" "$pkg"
}
pkg_install() {
local system="bashtard/pkg/install"
local app=$1 ; shift
case "${BASHTARD_PLATFORM[key]}" in
freebsd) set -- /usr/sbin/pkg install -y "$app" ;;
linux-debian*) set -- apt install -y "$app" ;;
linux-gentoo) set -- emerge --ask=n --update "$app" ;;
*)
crit "$system" "No package manager configured for ${BASHTARD_PLATFORM[key]}"
return 1
;;
esac
notice "$system" "$*"
# shellcheck disable=SC2068
$@
}
pkg_uninstall() {
local system="bashtard/pkg/uninstall"
local app=$1 ; shift
case "${BASHTARD_PLATFORM[key]}" in
freebsd) set -- /usr/sbin/pkg uninstall -y "$app" ;;
linux-debian*) set -- apt remove -y "$app" ;;
linux-gentoo) set -- emerge --ask=n --unmerge "$app" ;;
*)
crit "$system" "No package manager configured for ${BASHTARD_PLATFORM[key]}"
return 1
;;
esac
notice "$system" "$*"
# shellcheck disable=SC2068
$@
}
|