feat: platform_install - add dpkg-url option

This commit is contained in:
2024-08-04 17:18:58 +03:00
parent da544fb558
commit 3b8d4052d4
2 changed files with 21 additions and 8 deletions

View File

@@ -115,13 +115,8 @@ fi
if [[ ! -f $(which delta) ]]; then
if ask "Install delta?"; then
echo_yellow "Installing delta..."
if is_mac; then
platform_install git-delta
else
tmpf=$(mktemp -d)/delta.deb
curl -L https://github.com/dandavison/delta/releases/download/0.17.0/git-delta_0.17.0_amd64.deb -o $tmpf
dpkg -i $tmpf
fi
dpkg_url="https://github.com/dandavison/delta/releases/download/0.17.0/git-delta_0.17.0_amd64.deb"
platform_install --dpkg-url $dpkg_url git-delta
fi
fi

View File

@@ -706,12 +706,30 @@ peerdepls() {
}
platform_install() {
if [[ $# -eq 0 ]]; then
echo_red "Usage: platform_install [--dpkg-url dpkg-url] <package>"
return 1
fi
if [[ $# -gt 1 ]]; then
case $1 in
--dpkg-url)
dpkg_url=$2
shift 2
;;
esac
fi
pkg="$@"
if is_mac; then
brew install $pkg
elif is_linux; then
sudo apt install $pkg
if [[ ! -z "$dpkg_url" ]]; then
curl -sL $dpkg_url | sudo dpkg -i
else
sudo apt install $pkg
fi
fi
}