From 72d7d1a3fdf60ba5679e83fd28dbd4693bbaffe1 Mon Sep 17 00:00:00 2001 From: Yuan Chiu Date: Wed, 23 Apr 2025 21:52:15 +0800 Subject: [PATCH] Fix Script: add first packages in Linux before --- .chezmoidata/packages.toml | 11 +++++++---- ...hange_before_linux-install-packages.sh.tmpl | 17 +++++++++++++++-- Readme.md | 18 ++++++++++++------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.chezmoidata/packages.toml b/.chezmoidata/packages.toml index 1f9b9e5..22236f1 100644 --- a/.chezmoidata/packages.toml +++ b/.chezmoidata/packages.toml @@ -23,10 +23,15 @@ casks = [ ] [packages.linux.manjaro] -pacman = [ +pacman_first = [ 'archlinux-keyring', - 'chezmoi', 'libpamac', + 'llvm', + 'llvm-libs', +] + +pacman = [ + 'chezmoi', 'yay', 'base-devel', 'fakeroot', @@ -42,8 +47,6 @@ pacman = [ 'go', 'nodejs', 'jdk-openjdk', - 'llvm', - 'llvm-libs', ] aur = [ diff --git a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl index 1bcb652..8f7765f 100644 --- a/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl +++ b/.chezmoiscripts/run_onchange_before_linux-install-packages.sh.tmpl @@ -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=() diff --git a/Readme.md b/Readme.md index 87a39a4..0867478 100644 --- a/Readme.md +++ b/Readme.md @@ -4,21 +4,27 @@ Yuan dotfile 安裝 (個人用途) -------------------------------------------------------------------------------- ### Linux / macOS -#### 1. 放置自己的金鑰(若是其他人要用,請直接跳過) +#### 安裝主dotfiles包 +``` +sh -c "$(curl -fsLS get.chezmoi.io)" -- init https://git.yuaner.tw/yuan/dotfiles-private.git --apply +``` + +
+ 私人用安裝方式 +##### 1. 放置自己的金鑰(若是其他人要用,請直接跳過) 將 `id_rsa` sshkey金鑰檔放到 `~/.ssh/id_rsa` -#### 2. 安裝主dotfiles包 +##### 2. 安裝主dotfiles包 ``` -#sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply ssh://git@git.yuaner.tw:10022/yuan/dotfiles.git #私人用 -sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply ssh://git@git.yuaner.tw:10022/yuan/dotfiles.git -vim +PlugInstall +qall +sh -c "$(curl -fsLS get.chezmoi.io)" -- init ssh://git@git.yuaner.tw:10022/yuan/dotfiles.git --apply ``` -#### 3. 安裝私人用的dotfiles包(若是其他人要用,請直接跳過) +##### 3. 安裝私人用的dotfiles包(若是其他人要用,請直接跳過) ``` chezmoi init --source ~/.local/share/chezmoi-private --config ~/.config/chezmoi-private/chezmoi.toml ssh://git@git.yuaner.tw:10022/yuan/dotfiles-private.git --apply chezmoi apply ``` +
#### 若需要刪掉重來 ```