33 lines
687 B
Bash
33 lines
687 B
Bash
|
|
_os() {
|
||
|
|
if command -v termux-setup-storage >/dev/null; then
|
||
|
|
echo "termux"
|
||
|
|
else
|
||
|
|
grep '^ID=' /etc/os-release | cut -d= -f2
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
missing=()
|
||
|
|
check_apply() {
|
||
|
|
while IFS= read -r package; do
|
||
|
|
cmd=$(echo "$package" | cut -d\; -f1)
|
||
|
|
pkg=$(echo "$package" | grep -Eo "$(_os):[^ ]+" || echo ":$cmd")
|
||
|
|
pkg=$(echo "$pkg" | cut -d: -f2)
|
||
|
|
[ -n "$pkg" ] || next
|
||
|
|
|
||
|
|
command -v "$cmd" >/dev/null || missing+=( "$pkg" )
|
||
|
|
done < ~/.config/mgmt/packages
|
||
|
|
|
||
|
|
[ ${#missing} -eq 0 ]
|
||
|
|
}
|
||
|
|
|
||
|
|
apply() {
|
||
|
|
case "$(_os)" in
|
||
|
|
ubuntu) manager="apt install" ;;
|
||
|
|
arch) manager="pacman -Syu" ;;
|
||
|
|
termux) manager="pkg install" ;;
|
||
|
|
*) return 1 ;;
|
||
|
|
esac
|
||
|
|
|
||
|
|
$manager "${missing[@]}"
|
||
|
|
}
|