2018-02-22 04:15:49 +00:00
|
|
|
#!/bin/bash
|
2021-02-05 00:05:51 +00:00
|
|
|
# Description: Debian Package Manager
|
2018-02-27 05:15:14 +00:00
|
|
|
set -e
|
2018-02-22 04:15:49 +00:00
|
|
|
|
|
|
|
function _apt {
|
|
|
|
local pkg=$1
|
|
|
|
if ! dpkg -s $pkg >/dev/null 2>&1; then
|
2018-02-28 06:25:27 +00:00
|
|
|
if [ -z "$__apt_updated" ]; then
|
2020-06-25 01:31:00 +00:00
|
|
|
_apt_update
|
2018-02-28 06:25:27 +00:00
|
|
|
fi
|
2018-02-22 04:15:49 +00:00
|
|
|
_run "[apt] Install $pkg" sudo apt-get install -y $1
|
|
|
|
else
|
|
|
|
echo "[apt] $pkg is already installed, skipping."
|
|
|
|
fi
|
|
|
|
}
|
2018-02-23 21:17:52 +00:00
|
|
|
|
2020-06-25 01:31:00 +00:00
|
|
|
function _apt_update {
|
|
|
|
_run "Update APT cache" sudo apt-get update
|
|
|
|
__apt_updated=yes
|
|
|
|
}
|
|
|
|
|
|
|
|
function _apt_source {
|
|
|
|
_run "[apt] Add Source: $1" sudo add-apt-repository -u -y "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
function _dpkg {
|
|
|
|
local pkg=$1
|
|
|
|
local url=$2
|
|
|
|
if ! dpkg -s $pkg >/dev/null 2>&1; then
|
|
|
|
local download=$(mktemp -d)
|
|
|
|
_run "[dpkg] Downloading $pkg" curl -q -o "$download/$pkg.deb" "$url"
|
|
|
|
_run "[dpkg] Installing $pkg" sudo dpkg -i "$download/$pkg.deb"
|
|
|
|
rm -rf "$download"
|
|
|
|
else
|
|
|
|
echo "[dpkg] $pkg is already installed, skipping."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-02-23 21:17:52 +00:00
|
|
|
_apt software-properties-common
|
|
|
|
|
|
|
|
function _ppa {
|
2020-06-25 01:31:00 +00:00
|
|
|
_apt_source ppa:$1
|
2018-02-23 21:17:52 +00:00
|
|
|
}
|