diff --git a/.chezmoidata/packages.toml b/.chezmoidata/packages.toml index 22236f1..69d7bcf 100644 --- a/.chezmoidata/packages.toml +++ b/.chezmoidata/packages.toml @@ -23,7 +23,7 @@ casks = [ ] [packages.linux.manjaro] -pacman_first = [ +pacman_force = [ 'archlinux-keyring', 'libpamac', 'llvm', diff --git a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl index 8f7765f..56f7253 100644 --- a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl @@ -5,7 +5,9 @@ {{- /* 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 " " }}) +LOCKFILE="/var/lib/pacman/db.lck" + +pacmanForce_packages=( {{.packages.linux.manjaro.pacman_force | quoteList | join " " }}) pacman_packages=( {{.packages.linux.manjaro.pacman | quoteList | join " " }}) aur_packages=( {{.packages.linux.manjaro.aur | quoteList | join " " }}) @@ -15,18 +17,28 @@ is_installed() { [[ " ${installed_packages[*]} " =~ " $1 " ]] } -to_install_pacmanFirst=() -for package in "${pacmanFirst_packages[@]}"; do - if ! is_installed "$package"; then - to_install_pacmanFirst+=("$package") - fi +to_install_pacmanForce=() +for package in "${pacmanForce_packages[@]}"; do + to_install_pacmanForce+=("$package") 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[@]}" +# 等待鎖定檔案被移除 +echo "等待 pacman 鎖定檔案被移除..." +while [ -e "$LOCKFILE" ]; do + sleep 1 +done + +if [[ ${#to_install_pacmanForce[@]} -gt 0 ]]; then + echo " - Installing missing packages via pacman: ${to_install_pacmanForce[@]}" + sudo pacman -S --needed --noconfirm "${to_install_pacmanForce[@]}" fi +# 等待鎖定檔案被移除 +echo "等待 pacman 鎖定檔案被移除..." +while [ -e "$LOCKFILE" ]; do + sleep 1 +done + to_install_pacman=() for package in "${pacman_packages[@]}"; do if ! is_installed "$package"; then