Improve install_packages in linux.sh

This commit is contained in:
Shivam Mathur 2023-04-02 22:03:11 +05:30
parent ca308a6886
commit 6483a6ea70
No known key found for this signature in database
GPG Key ID: 3E13E4C8591ACC2A

View File

@ -15,10 +15,15 @@ self_hosted_helper() {
install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg install_packages apt-transport-https ca-certificates curl file make jq unzip autoconf automake gcc g++ gnupg
} }
# Function to fix broken packages.
fix_broken_packages() {
sudo apt --fix-broken install >/dev/null 2>&1
}
# Function to install a package # Function to install a package
install_packages() { install_packages() {
packages=("$@") packages=("$@")
$apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && $apt_install "${packages[@]}" >/dev/null 2>&1) $apt_install "${packages[@]}" >/dev/null 2>&1 || (update_lists && fix_broken_packages && $apt_install "${packages[@]}" >/dev/null 2>&1)
} }
# Function to disable an extension. # Function to disable an extension.