#!/bin/bash
# bos-update — update all of BOS in one go.
#
# BOS packages come from two channels, so a full update touches both:
#   1. pacman   — Arch base/desktop + the [breadway] repo (breadlock + AUR
#                 republishes: calamares, zen-browser-bin, bibata, yay-bin,
#                 powerlevel10k). [breadway] does NOT provide bos-settings
#                 or other bakery desktop apps. Every transaction is
#                 snapshotted by snap-pac; recover via the GRUB "snapshots"
#                 submenu (grub-btrfs), not `snapper rollback`.
#   2. bakery   — the bread ecosystem apps in ~/.local/bin (whatever `bakery list`
#                 reports as installed — bakery, bread, breadbar, breadbox,
#                 breadcrumbs, breadpad, breadman, bread-theme, breadpaper,
#                 breadmon, breadsearch, breadclip, breadshot, bos-settings,
#                 breadhelp, ...).
#
# Best-effort: a failure in one channel doesn't abort the other.
set -uo pipefail

bold() { printf '\033[1m%s\033[0m\n' "$1"; }

bold "==> System packages (pacman -Syu)"
if command -v pacman >/dev/null; then
    sudo pacman -Syu || echo "WARN: pacman update failed"
else
    echo "pacman not found; skipping"
fi

echo
bold "==> Bread ecosystem (bakery update --all)"
if command -v bakery >/dev/null; then
    bakery update --all || echo "WARN: bakery update failed"
else
    echo "bakery not found; skipping"
fi

echo
bold "==> BOS is up to date."
