blob: f47c688e904d27b0bed8f9ddb6c00643de70b1b7 (
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/usr/bin/env sh
#
# Custom functions for debian-like systems.
#
# Machine architecture
trashman_debian_arch() {
local arch="`uname -m`"
# Fix arch
if [ "$arch" = "x86_64" ]; then
arch="amd64"
fi
echo $arch
}
# Check if package is installed
trashman_apt_check() {
if [ -z "$1" ]; then
return
fi
#dpkg -s $1 > /dev/null 2>&1
# See https://stackoverflow.com/questions/1298066/check-if-a-package-is-installed-and-then-install-it-if-its-not#1298103
dpkg-query -W -f='${Status}' $1 > /dev/null 2>&1 | grep -q '^install ok'
return $?
}
trashman_apt_update() {
$SUDO apt-get update
}
trashman_apt_install() {
if [ -z "$1" ]; then
return
fi
trashman_apt_update
local install=""
for package in $*; do
if ! trashman_apt_check $package; then
install="$install $package"
fi
done
LC_ALL=C DEBIAN_FRONTEND=noninteractive $SUDO apt-get install -y $install || exit 1
}
# Install an apt repository key
trashman_install_apt_key() {
local orig="$1"
local dest="$2"
if [ ! -e "$orig" ]; then
exit 1
fi
$SUDO cp $orig /etc/apt/trusted.gpg.d/$dest || exit 1
$SUDO chown root.root /etc/apt/trusted.gpg.d/$dest && $SUDO chmod 644 /etc/apt/trusted.gpg.d/$dest || exit 1
}
# Determine Debian major version name
trashman_debian_major_version_name {
if [ ! -e "/etc/debian_version" ];
return 1
fi
local number="`cut -d . -f 1 /etc/debian_version`"
if [ "$number" == "12" ]; then
echo "bookworm"
elif [ "$number" == "11" ]; then
echo "bullseye"
elif [ "$number" == "10" ]; then
echo "buster"
elif [ "$number" == "9" ]; then
echo "stretch"
fi
}
|