Fix Script: add first packages in Linux before

This commit is contained in:
2025-04-23 21:52:15 +08:00
parent e757bcc18b
commit 72d7d1a3fd
3 changed files with 34 additions and 12 deletions

View File

@@ -5,6 +5,7 @@
{{- /* https://github.com/mriehl/dotfiles/blob/master/run_onchange_packages.sh.tmpl */ -}}
#!/usr/bin/env bash
pacmanFirst_packages=( {{.packages.linux.manjaro.pacman_first | quoteList | join " " }})
pacman_packages=( {{.packages.linux.manjaro.pacman | quoteList | join " " }})
aur_packages=( {{.packages.linux.manjaro.aur | quoteList | join " " }})
@@ -14,6 +15,18 @@ is_installed() {
[[ " ${installed_packages[*]} " =~ " $1 " ]]
}
to_install_pacmanFirst=()
for package in "${pacmanFirst_packages[@]}"; do
if ! is_installed "$package"; then
to_install_pacmanFirst+=("$package")
fi
done
if [[ ${#to_install_pacmanFirst[@]} -gt 0 ]]; then
echo " - Installing missing packages via pacman: ${to_install_pacmanFirst[@]}"
sudo pacman -S --needed --noconfirm "${to_install_pacmanFirst[@]}"
fi
to_install_pacman=()
for package in "${pacman_packages[@]}"; do
if ! is_installed "$package"; then
@@ -23,12 +36,12 @@ done
if [[ ${#to_install_pacman[@]} -gt 0 ]]; then
echo " - Installing missing packages via pacman: ${to_install_pacman[@]}"
sudo pacman -S --noconfirm "${to_install_pacman[@]}"
sudo pacman -S --needed --noconfirm "${to_install_pacman[@]}"
fi
if ! is_installed "yay"; then
echo " - Installing yay"
sudo pacman -S --noconfirm yay
sudo pacman -S --needed --noconfirm yay
fi
to_install_aur=()