numerous updates
This commit is contained in:
@@ -73,6 +73,40 @@ enable_services() {
|
||||
done
|
||||
}
|
||||
|
||||
# Run each script in migrations/ that hasn't run on this machine yet, oldest
|
||||
# first. A migration is recorded as done only when it succeeds, and the first
|
||||
# failure stops the run so a later migration never runs ahead of an earlier one.
|
||||
run_migrations() {
|
||||
local dir="${COREDESKTOP:-$HOME/.local/share/coredesktop}/migrations"
|
||||
local state="$HOME/.local/state/coredesktop/migrations"
|
||||
local file name
|
||||
|
||||
mkdir -p "$state"
|
||||
for file in "$dir"/*.sh; do
|
||||
[ -f "$file" ] || continue
|
||||
name="$(basename "$file")"
|
||||
[ -f "$state/$name" ] && continue
|
||||
|
||||
echo "Running migration $name..."
|
||||
if ! bash "$file"; then
|
||||
echo "Migration $name failed; it will run again on the next update."
|
||||
return 1
|
||||
fi
|
||||
touch "$state/$name"
|
||||
done
|
||||
}
|
||||
|
||||
# Output of the last update's pacman -Su, written by updates.d/10-pacman.sh
|
||||
PACMAN_UPDATE_LOG="$HOME/.local/state/coredesktop/pacman-update.log"
|
||||
|
||||
# True if the last update rebuilt the initramfs and mkinitcpio reported a
|
||||
# failure. Rebooting then can leave the machine unbootable.
|
||||
initramfs_build_failed() {
|
||||
[ -f "$PACMAN_UPDATE_LOG" ] || return 1
|
||||
grep -q "Updating linux initcpios" "$PACMAN_UPDATE_LOG" || return 1
|
||||
grep -q "==> ERROR" "$PACMAN_UPDATE_LOG" || ! grep -q "Image generation successful" "$PACMAN_UPDATE_LOG"
|
||||
}
|
||||
|
||||
# Install a script atomically (copy to a temp file, then rename over the target)
|
||||
# so a copy of it that is running right now keeps reading the old file
|
||||
install_script() {
|
||||
|
||||
Reference in New Issue
Block a user