Post-process a mix firmware .fw so it ships the correct
user-merged initramfs/UBI rather than the system-only versions
baked in at system build time.
Designed to be chained after firmware via a mix alias:
defp aliases do
[
firmware: ["firmware", "openwrt_one.firmware_post"]
]
endWith the alias in place:
mix firmwareproduces a.fwwhosedata/openwrt-one-initramfs.itbanddata/openwrt-one-nand.ubiare derived from the .fw's own combined squashfs — i.e. they contain/srv/erlang.mix burnworks directly: fwup writes the spliced UBI to the recovery USB stick, so the first boot after the USB dance finds the Erlang release.mix uploadcan extractdata/openwrt-one-initramfs.itbstraight out of the.fw(no on-the-fly rebuild needed).
Without the alias, mix firmware ships the stale system-only
resources and the device boots with erlinit: No release found in /srv/erlang.
What it does
- Calls
scripts/wrap-firmware.shfrom the system, which extracts the .fw's squashfs, unsquashes it, repacks as cpio.gz, and runsmkimage+ubinizeto produce a fresh.itband.ubi. - Replaces
data/openwrt-one-initramfs.itbanddata/openwrt-one-nand.ubiinside the .fw zip with those fresh artifacts. - Rewrites the matching
lengthandblake2b-256entries inmeta.confso fwup's integrity check still passes. - Preserves the original zip entry ordering (fwup expects
resources to appear in the order their
on-resourceclauses are declared).
Requirements
b2sum(GNU coreutils ≥ 8.26) —apt install coreutilson Linux,brew install coreutilson macOS (binary isgb2sum).- Everything
scripts/wrap-firmware.shneeds:unzip,unsquashfs,cpio,gzip,mkimage,dtc,ubinize.