fix mgmt for termux
This commit is contained in:
parent
074131bb54
commit
21127d307d
4 changed files with 15 additions and 8 deletions
|
|
@ -0,0 +1,32 @@
|
|||
_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[@]}"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue