feat(repos): add AUR helper selection and improve yay installation error handling
- commit
- 5e6ac715a8fa15d3b5e64e18fe375fe3f73d2335
- author
- bnema · · 2025-10-19 19:32 UTC
- committer
- bnema · · 2025-10-19 16:42 UTC
- parent
- 54d5fb4
- signature
- unsigned
2 files · +49 -29
M install/repos/all.sh +23 -1
| @@ -2,6 +2,28 @@ | |||
| 2 | 2 | # Repository setup phase | |
| 3 | 3 | ||
| 4 | 4 | stop_log_output # Stop for interactive prompts | |
| 5 | - | source "$ARCHUP_INSTALL/repos/yay.sh" # Interactive (gum confirm) | |
| 5 | + | ||
| 6 | + | # AUR Support prompt | |
| 7 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "AUR Support" | |
| 8 | + | echo | |
| 9 | + | ||
| 10 | + | if gum confirm "Enable AUR support?" --padding "0 0 1 $PADDING_LEFT"; then | |
| 11 | + | export ARCHUP_AUR="enabled" | |
| 12 | + | ||
| 13 | + | # Choose AUR helper | |
| 14 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Choose AUR Helper" | |
| 15 | + | AUR_HELPER=$(gum choose --cursor.foreground 6 --padding "0 0 1 $PADDING_LEFT" "paru" "yay") | |
| 16 | + | ||
| 17 | + | if [ "$AUR_HELPER" = "paru" ]; then | |
| 18 | + | source "$ARCHUP_INSTALL/repos/paru.sh" | |
| 19 | + | else | |
| 20 | + | source "$ARCHUP_INSTALL/repos/yay.sh" | |
| 21 | + | fi | |
| 22 | + | else | |
| 23 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[SKIP] Skipping AUR support" | |
| 24 | + | echo "AUR: disabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 25 | + | export ARCHUP_AUR="disabled" | |
| 26 | + | fi | |
| 27 | + | ||
| 6 | 28 | source "$ARCHUP_INSTALL/repos/chaotic.sh" # Interactive (gum confirm) | |
| 7 | 29 | start_log_output # Resume (will be stopped by stop_install_log) | |
| @@ -2,6 +2,28 @@ | |||||
| 2 | # Repository setup phase | 2 | # Repository setup phase | ||
| 3 | 3 | ||||
| 4 | stop_log_output # Stop for interactive prompts | 4 | stop_log_output # Stop for interactive prompts | ||
| 5 | - | source "$ARCHUP_INSTALL/repos/yay.sh" # Interactive (gum confirm) | 5 | + | |
| 6 | + | # AUR Support prompt | |||
| 7 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "AUR Support" | |||
| 8 | + | echo | |||
| 9 | + | ||||
| 10 | + | if gum confirm "Enable AUR support?" --padding "0 0 1 $PADDING_LEFT"; then | |||
| 11 | + | export ARCHUP_AUR="enabled" | |||
| 12 | + | ||||
| 13 | + | # Choose AUR helper | |||
| 14 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Choose AUR Helper" | |||
| 15 | + | AUR_HELPER=$(gum choose --cursor.foreground 6 --padding "0 0 1 $PADDING_LEFT" "paru" "yay") | |||
| 16 | + | ||||
| 17 | + | if [ "$AUR_HELPER" = "paru" ]; then | |||
| 18 | + | source "$ARCHUP_INSTALL/repos/paru.sh" | |||
| 19 | + | else | |||
| 20 | + | source "$ARCHUP_INSTALL/repos/yay.sh" | |||
| 21 | + | fi | |||
| 22 | + | else | |||
| 23 | + | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[SKIP] Skipping AUR support" | |||
| 24 | + | echo "AUR: disabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 25 | + | export ARCHUP_AUR="disabled" | |||
| 26 | + | fi | |||
| 27 | + | ||||
| 6 | source "$ARCHUP_INSTALL/repos/chaotic.sh" # Interactive (gum confirm) | 28 | source "$ARCHUP_INSTALL/repos/chaotic.sh" # Interactive (gum confirm) | ||
| 7 | start_log_output # Resume (will be stopped by stop_install_log) | 29 | start_log_output # Resume (will be stopped by stop_install_log) | ||
M install/repos/yay.sh +26 -28
| @@ -1,20 +1,7 @@ | |||
| 1 | 1 | #!/bin/bash | |
| 2 | 2 | # Install yay AUR helper | |
| 3 | 3 | ||
| 4 | - | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "AUR Support" | |
| 5 | - | echo | |
| 6 | - | ||
| 7 | - | # Ask if user wants AUR support | |
| 8 | - | if ! gum confirm "Enable AUR support (install yay)?" --padding "0 0 1 $PADDING_LEFT"; then | |
| 9 | - | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[SKIP] Skipping AUR support" | |
| 10 | - | echo "AUR: disabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 11 | - | export ARCHUP_AUR="disabled" | |
| 12 | - | return 0 | |
| 13 | - | fi | |
| 14 | - | ||
| 15 | - | export ARCHUP_AUR="enabled" | |
| 16 | - | ||
| 17 | - | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing yay AUR helper..." | |
| 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing yay..." | |
| 18 | 5 | gum style --padding "0 0 1 $PADDING_LEFT" "This may take a few minutes..." | |
| 19 | 6 | ||
| 20 | 7 | # Install base-devel if not already installed (required for building AUR packages) | |
| @@ -23,29 +10,40 @@ arch-chroot /mnt pacman -S --noconfirm --needed base-devel git >> "$ARCHUP_INSTA | |||
| 23 | 10 | # Get the username created during installation | |
| 24 | 11 | USERNAME=$(arch-chroot /mnt ls /home | head -1) | |
| 25 | 12 | ||
| 26 | - | if [ -z "$USERNAME" ]; then | |
| 27 | - | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Error: Could not find user for yay installation" | |
| 13 | + | if [[ -z "${USERNAME}" ]]; then | |
| 14 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Could not find user for yay installation" | |
| 28 | 15 | echo "ERROR: No user found for yay installation" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 29 | 16 | export ARCHUP_AUR="failed" | |
| 30 | 17 | return 1 | |
| 31 | 18 | fi | |
| 32 | 19 | ||
| 33 | - | # Clone yay-bin from AUR as the user (not root) | |
| 34 | - | arch-chroot /mnt su - "$USERNAME" -c "cd /tmp && git clone https://aur.archlinux.org/yay-bin.git" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | |
| 35 | - | ||
| 36 | - | # Build and install yay as the user | |
| 37 | - | arch-chroot /mnt su - "$USERNAME" -c "cd /tmp/yay-bin && makepkg -si --noconfirm" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | |
| 38 | - | ||
| 39 | - | # Clean up | |
| 40 | - | arch-chroot /mnt rm -rf /tmp/yay-bin >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 20 | + | # Build yay as user and install as root | |
| 21 | + | echo "Building yay package..." >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 22 | + | if ! arch-chroot /mnt bash <<CHROOT_SCRIPT >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 23 | + | set -e | |
| 24 | + | set -u | |
| 25 | + | set -o pipefail | |
| 26 | + | cd /tmp | |
| 27 | + | su ${USERNAME} -c "git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -s --noconfirm" | |
| 28 | + | cd yay-bin | |
| 29 | + | pacman -U --noconfirm yay-bin-*.pkg.tar.zst | |
| 30 | + | cd /tmp | |
| 31 | + | rm -rf yay-bin | |
| 32 | + | CHROOT_SCRIPT | |
| 33 | + | then | |
| 34 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay installation failed" | |
| 35 | + | echo "ERROR: yay installation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 36 | + | export ARCHUP_AUR="failed" | |
| 37 | + | return 1 | |
| 38 | + | fi | |
| 41 | 39 | ||
| 42 | 40 | # Verify installation | |
| 43 | - | if arch-chroot /mnt su - "$USERNAME" -c "yay --version" >/dev/null 2>&1; then | |
| 41 | + | if arch-chroot /mnt su - "${USERNAME}" -c "yay --version" >/dev/null 2>&1; then | |
| 44 | 42 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "[OK] yay installed successfully" | |
| 45 | - | echo "AUR: enabled (yay installed for user: $USERNAME)" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 43 | + | echo "AUR: enabled (yay installed for user: ${USERNAME})" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 46 | 44 | else | |
| 47 | - | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay installation failed" | |
| 48 | - | echo "ERROR: yay installation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 45 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay verification failed" | |
| 46 | + | echo "ERROR: yay verification failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 49 | 47 | export ARCHUP_AUR="failed" | |
| 50 | 48 | return 1 | |
| 51 | 49 | fi | |
| @@ -1,20 +1,7 @@ | |||||
| 1 | #!/bin/bash | 1 | #!/bin/bash | ||
| 2 | # Install yay AUR helper | 2 | # Install yay AUR helper | ||
| 3 | 3 | ||||
| 4 | - | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "AUR Support" | 4 | + | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing yay..." |
| 5 | - | echo | |||
| 6 | - | ||||
| 7 | - | # Ask if user wants AUR support | |||
| 8 | - | if ! gum confirm "Enable AUR support (install yay)?" --padding "0 0 1 $PADDING_LEFT"; then | |||
| 9 | - | gum style --foreground 3 --padding "0 0 1 $PADDING_LEFT" "[SKIP] Skipping AUR support" | |||
| 10 | - | echo "AUR: disabled" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 11 | - | export ARCHUP_AUR="disabled" | |||
| 12 | - | return 0 | |||
| 13 | - | fi | |||
| 14 | - | ||||
| 15 | - | export ARCHUP_AUR="enabled" | |||
| 16 | - | ||||
| 17 | - | gum style --foreground 6 --padding "1 0 0 $PADDING_LEFT" "Installing yay AUR helper..." | |||
| 18 | gum style --padding "0 0 1 $PADDING_LEFT" "This may take a few minutes..." | 5 | gum style --padding "0 0 1 $PADDING_LEFT" "This may take a few minutes..." | ||
| 19 | 6 | ||||
| 20 | # Install base-devel if not already installed (required for building AUR packages) | 7 | # Install base-devel if not already installed (required for building AUR packages) | ||
| @@ -23,29 +10,40 @@ arch-chroot /mnt pacman -S --noconfirm --needed base-devel git >> "$ARCHUP_INSTA | |||||
| 23 | # Get the username created during installation | 10 | # Get the username created during installation | ||
| 24 | USERNAME=$(arch-chroot /mnt ls /home | head -1) | 11 | USERNAME=$(arch-chroot /mnt ls /home | head -1) | ||
| 25 | 12 | ||||
| 26 | - | if [ -z "$USERNAME" ]; then | 13 | + | if [[ -z "${USERNAME}" ]]; then |
| 27 | - | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Error: Could not find user for yay installation" | 14 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] Could not find user for yay installation" |
| 28 | echo "ERROR: No user found for yay installation" >> "$ARCHUP_INSTALL_LOG_FILE" | 15 | echo "ERROR: No user found for yay installation" >> "$ARCHUP_INSTALL_LOG_FILE" | ||
| 29 | export ARCHUP_AUR="failed" | 16 | export ARCHUP_AUR="failed" | ||
| 30 | return 1 | 17 | return 1 | ||
| 31 | fi | 18 | fi | ||
| 32 | 19 | ||||
| 33 | - | # Clone yay-bin from AUR as the user (not root) | 20 | + | # Build yay as user and install as root |
| 34 | - | arch-chroot /mnt su - "$USERNAME" -c "cd /tmp && git clone https://aur.archlinux.org/yay-bin.git" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | 21 | + | echo "Building yay package..." >> "$ARCHUP_INSTALL_LOG_FILE" |
| 35 | - | 22 | + | if ! arch-chroot /mnt bash <<CHROOT_SCRIPT >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | |
| 36 | - | # Build and install yay as the user | 23 | + | set -e |
| 37 | - | arch-chroot /mnt su - "$USERNAME" -c "cd /tmp/yay-bin && makepkg -si --noconfirm" >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 || true | 24 | + | set -u |
| 38 | - | 25 | + | set -o pipefail | |
| 39 | - | # Clean up | 26 | + | cd /tmp |
| 40 | - | arch-chroot /mnt rm -rf /tmp/yay-bin >> "$ARCHUP_INSTALL_LOG_FILE" 2>&1 | 27 | + | su ${USERNAME} -c "git clone https://aur.archlinux.org/yay-bin.git && cd yay-bin && makepkg -s --noconfirm" |
| 28 | + | cd yay-bin | |||
| 29 | + | pacman -U --noconfirm yay-bin-*.pkg.tar.zst | |||
| 30 | + | cd /tmp | |||
| 31 | + | rm -rf yay-bin | |||
| 32 | + | CHROOT_SCRIPT | |||
| 33 | + | then | |||
| 34 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay installation failed" | |||
| 35 | + | echo "ERROR: yay installation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 36 | + | export ARCHUP_AUR="failed" | |||
| 37 | + | return 1 | |||
| 38 | + | fi | |||
| 41 | 39 | ||||
| 42 | # Verify installation | 40 | # Verify installation | ||
| 43 | - | if arch-chroot /mnt su - "$USERNAME" -c "yay --version" >/dev/null 2>&1; then | 41 | + | if arch-chroot /mnt su - "${USERNAME}" -c "yay --version" >/dev/null 2>&1; then |
| 44 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "[OK] yay installed successfully" | 42 | gum style --foreground 2 --padding "1 0 1 $PADDING_LEFT" "[OK] yay installed successfully" | ||
| 45 | - | echo "AUR: enabled (yay installed for user: $USERNAME)" >> "$ARCHUP_INSTALL_LOG_FILE" | 43 | + | echo "AUR: enabled (yay installed for user: ${USERNAME})" >> "$ARCHUP_INSTALL_LOG_FILE" |
| 46 | else | 44 | else | ||
| 47 | - | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay installation failed" | 45 | + | gum style --foreground 1 --padding "1 0 1 $PADDING_LEFT" "[ERROR] yay verification failed" |
| 48 | - | echo "ERROR: yay installation failed" >> "$ARCHUP_INSTALL_LOG_FILE" | 46 | + | echo "ERROR: yay verification failed" >> "$ARCHUP_INSTALL_LOG_FILE" |
| 49 | export ARCHUP_AUR="failed" | 47 | export ARCHUP_AUR="failed" | ||
| 50 | return 1 | 48 | return 1 | ||
| 51 | fi | 49 | fi | ||