shellcheck / shellcheck (push) Failing after 19s
Adapted from Omarchy (github.com/omacom/omarchy) for Arch with GNOME: - A pacman hook stops a full upgrade run without update (pacman -Syu, yay -Syu), which would skip the snapshot and update's checks. update and install.sh set COREDESKTOP_ALLOW_PACMAN=1, which the hook finds on pacman or any process above it; you can set it too. - When the Arch upgrade stops on files no package owns, update lists them and asks to move them to /var/lib/coredesktop/replaced and try again, putting back what the retry didn't replace. When packages conflict, it runs pacman again so you can choose. - update and install keep the computer from sleeping until they finish. - system/hardware.sh (install, and a migration): the Wi-Fi country from the time zone, thermald and intel-lpmd on Intel laptops, and Wi-Fi 6 on Intel BE200/BE211 cards, whose driver gets Wi-Fi 7 wrong. - configure security-key and configure fingerprint: touch a FIDO2 key or a finger instead of typing your password for sudo and polkit, falling back to the password. Each shows only when the hardware is there. The fingerprint skips to the password with the lid shut. - webapp: put a website in the app grid as its own app window. - Taildrop: Files' Scripts > Send with Tailscale, and a user service that saves files sent here to Downloads, started when configure tailscale joins. - A NetworkManager dispatcher script pauses a Tailscale exit node while you sign in to a captive portal, and resumes it once online. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
107 lines
3.8 KiB
Bash
107 lines
3.8 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..."
|
|
mkdir -p "$(dirname "$PACMAN_UPDATE_LOG")"
|
|
: > "$PACMAN_UPDATE_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
|
|
|
|
if initramfs_build_failed; then
|
|
echo -e "\e[31mRebuilding the initramfs failed. Don't reboot until it's fixed - see the output above or $PACMAN_UPDATE_LOG.\e[0m"
|
|
STATUS=1
|
|
fi
|
|
|
|
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
|
|
|
|
exit $STATUS
|