o-install, two-reboot c= ycle for major version jumps (e.g. 14.x =E2=86=92 15.x) using a temporary `rc.d` ser= vice that survives the first reboot - **Safe by design** =E2=80=94 full backup before touching anything, restor= e script generated automatically, SHA256 integrity verification --- ## Current limitations and known bugs I want to be transparent about what still needs work: 1. **STABLE branch detection** =E2=80=94 the menu regex for `-STABLE` targe= ts does not always match the mirror directory listing correctly 2. **State recovery after interruption** =E2=80=94 if the script is killed mid-upgrade, resuming it does not correctly re-enter the freebsd-update merge phase; it tries to call `freebsd-update install` prematurely 3. **grep -c arithmetic** =E2=80=94 a subtle shell arithmetic bug produces `[: 0 0: bad number` in some cases when counting conflict markers 4. **STABLE/CURRENT upgrade type** =E2=80=94 `is_major_upgrade()` only comp= ares major version numbers; it does not distinguish STABLE or CURRENT targets which may need different handling 5. **Terminal compatibility** =E2=80=94 Unicode box-drawing characters in m= enus do not render correctly in all FreeBSD terminal configurations; should fall back to plain ASCII --- ## What I would love feedback on This is where I genuinely need input from people who know FreeBSD internals better than I do: **1. Is using `$EDITOR` the right hook into freebsd-update?** Is there a cleaner, more supported way to intercept freebsd-update's merge phase? I am essentially abusing the EDITOR variable =E2=80=94 it works, but= it feels fragile. Is there an official API or hook mechanism I am missing? **2. The 3-way merge approach =E2=80=94 is merge(1) the right tool?** I am using `merge(1)` from the `rcs` package. Are there better alternatives in the FreeBSD base system? `diff3(1)` is available but requires more orchestration. `patch(1)` could work but loses context. Thoughts? **3. Handling STABLE and CURRENT upgrades** Upgrading to a -STABLE or -CURRENT branch is fundamentally different from a RELEASE upgrade =E2=80=94 freebsd-update behaves differently, and the bas= e.txz download path is different. Has anyone automated this reliably? **4. The two-reboot major upgrade cycle** I implemented this using a temporary `rc.d` service (`automerge_resume`) that runs `freebsd-update install` after the first reboot and then removes itself. It works, but it feels like a hack. Is there a cleaner pattern? **5. pkg alignment after major upgrades** After a major upgrade (e.g. 14.x =E2=86=92 15.x), all installed packages ne= ed to be rebuilt or reinstalled. I currently just tell the user to run `pkg upgrade -f` manually. Should this be integrated into the script? What is the safest sequence? --- ## How to get it The script is a single self-contained shell file with no external dependencies beyond `merge(1)` (from `pkg install rcs`) and optionally `expect(1)` for auto-confirm mode. Usage: ```sh # Show interactive target menu (queries mirror live) sh freebsd-automerge.sh # Filter menu to branch 14 sh freebsd-automerge.sh 14 # Direct upgrade, no menu sh freebsd-automerge.sh 14.4-RELEASE # Fully automated (requires: pkg install expect) sh freebsd-automerge.sh --auto-confirm 14 ``` --- ## Credits The script was conceived and directed by **ZioMario** (forums.freebsd.org user: ZioMario), developed with the assistance of **Claude** (Anthropic AI)= . The idea, architecture decisions, testing, and debugging were all driven by ZioMario =E2=80=94 Claude was used as an implementation tool. All feedback, pull requests, and brutal criticism are welcome. --=20 Mario. --0000000000000c3342065111147d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable