When mkinitcpio fails during an update or install, run it once more. If that fails too, say why (a full /boot, a hook or module that isn't installed) and don't offer a reboot. The install now logs its upgrade and checks the build before finish-install offers one, and nvidia.sh's rebuild no longer stops the install. A failed build is carried into the next update's log, so it's rebuilt and checked until it builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
104 lines
3.7 KiB
Bash
104 lines
3.7 KiB
Bash
#!/bin/bash
|
|
|
|
COREDESKTOP="$HOME/.local/share/coredesktop"
|
|
|
|
source "$COREDESKTOP/utils.sh"
|
|
source "$COREDESKTOP/packages.conf"
|
|
source "$COREDESKTOP/remove-packages.conf"
|
|
|
|
STATUS=0
|
|
|
|
echo "Removing unwanted packages..."
|
|
remove_packages "${REMOVE_PACMAN[@]}"
|
|
remove_flatpaks "${REMOVE_FLATPAKS[@]}"
|
|
|
|
# Machines installed before Federated Calendar need the repo before the -Sy
|
|
# below and install_packages, so this can't wait for a migration
|
|
echo "Checking the Federated Computer package repo..."
|
|
ensure_federated_repo || STATUS=1
|
|
|
|
# A stale mirror hides new packages instead of failing, so pick fresh ones
|
|
# before syncing. mirrors.sh also sets up reflector on machines without it.
|
|
if age="$(mirror_age_hours)" && (( age >= MIRROR_STALE_HOURS )); then
|
|
echo "Your package mirror ($(first_mirror)) last synced with Arch $age hours ago."
|
|
bash "$COREDESKTOP/system/mirrors.sh"
|
|
fi
|
|
|
|
# A machine that hasn't updated in a while can have a keyring too old to verify
|
|
# the new packages. Update it first; the -Su below completes this -Sy.
|
|
echo "Updating Arch keyring..."
|
|
sudo pacman -Sy --needed --noconfirm archlinux-keyring || STATUS=1
|
|
|
|
# script(1) keeps pacman's progress bars while logging its output for the
|
|
# initramfs check
|
|
echo "Updating Arch..."
|
|
new_pacman_log
|
|
|
|
# Run pacman -Su with the options given, adding its output to the log
|
|
upgrade() {
|
|
sudo script -qaefc "pacman -Su $*" "$PACMAN_UPDATE_LOG"
|
|
}
|
|
|
|
# Ask a question on the terminal, if there is one; the default is yes
|
|
ask_yes() {
|
|
local answer
|
|
{ : < /dev/tty; } 2> /dev/null || return 1
|
|
read -rp "$1 [Y/n] " answer < /dev/tty || return 1
|
|
[[ "$answer" != [nN]* ]]
|
|
}
|
|
|
|
# Two things stop an upgrade that a second try gets past. Either way, pacman
|
|
# changed nothing the first time.
|
|
retry_upgrade() {
|
|
local files=()
|
|
|
|
# A package that replaces or conflicts with an installed one: pacman asks
|
|
# whether to remove that one, and --noconfirm answers no. Which to keep is
|
|
# yours to decide (pacman says which above), so ask again without it.
|
|
if grep -q 'unresolvable package conflicts detected' "$PACMAN_UPDATE_LOG"; then
|
|
if ! { : < /dev/tty; } 2> /dev/null; then
|
|
echo "Packages conflict, and pacman needs you to choose. Run update in a terminal."
|
|
return 1
|
|
fi
|
|
echo -e "\e[33mPackages conflict, and pacman needs you to choose. Asking again:\e[0m"
|
|
upgrade
|
|
return
|
|
fi
|
|
|
|
# Files no package owns where a package now installs its own (left by pip,
|
|
# make install or an earlier installer): pacman won't install over them. Move
|
|
# them aside and try again, and put back any it didn't replace.
|
|
mapfile -t files < <(unowned_conflicts "$PACMAN_UPDATE_LOG")
|
|
(( ${#files[@]} > 0 )) || return 1
|
|
echo -e "\e[33mThe upgrade stopped because these files are in the way. No package owns them,\e[0m"
|
|
echo -e "\e[33mand a package now installs its own:\e[0m"
|
|
printf ' %s\n' "${files[@]}"
|
|
if ! ask_yes "Move them to $REPLACED_DIR and upgrade again?"; then
|
|
echo "Left them. Move or delete them, then run update again."
|
|
return 1
|
|
fi
|
|
move_aside "${files[@]}" || { put_back "${files[@]}"; return 1; }
|
|
if upgrade --noconfirm; then
|
|
echo "Upgraded. What was there before is in $REPLACED_DIR, if you need any of it."
|
|
return 0
|
|
fi
|
|
echo "Putting back what the upgrade didn't replace:"
|
|
put_back "${files[@]}"
|
|
return 1
|
|
}
|
|
|
|
upgrade --noconfirm || retry_upgrade || STATUS=1
|
|
|
|
echo "Checking for new packages..."
|
|
install_packages "${SYSTEM_UTILS[@]}" || STATUS=1
|
|
install_packages "${DEV_TOOLS[@]}" || STATUS=1
|
|
install_packages "${MAINTENANCE[@]}" || STATUS=1
|
|
install_packages "${DESKTOP[@]}" || STATUS=1
|
|
install_packages "${MEDIA[@]}" || STATUS=1
|
|
install_packages "${FONTS[@]}" || STATUS=1
|
|
|
|
# After the packages above, in case the build needed one of them
|
|
check_initramfs || STATUS=1
|
|
|
|
exit $STATUS
|