mirror of
https://github.com/openwrt/openwrt.git
synced 2026-10-13 19:48:16 +04:00
On a rebuild, the initrd and the initramfs kernel image usually have the same content as before, but xz and lzma compress them again on every build. For the OpenWrt One this takes about 6 s of the build. Add scripts/cache-run.sh. It runs a command that creates one file from another, and stores the output together with a hash of the input, the command line and the tool. If they are the same in the next run, it copies the stored output instead. The commands are deterministic, so the result is identical. On a hit the script compares the stored output with the file that is already there and copies only when the two differ. The output then keeps its timestamp, so a later step that compares timestamps does not treat it as new work. Use it for the initrd compression and for Build/lzma. bzip2 and lzop stay as they are: bzip2 writes to stdout, and lzop stores the mtime of its input. xz and gzip now keep the cpio, as the other tools do, so a cache hit leaves the same files behind as a normal run. The slot name follows the path of the output below $(KDIR), because two targets in different directories can share a basename. cache-run.sh holds a lock over the slot and swaps the stored output in with a rename, so two image recipes on one slot never read a half written pair. Signed-off-by: John Crispin <john@phrozen.org>