22
33include root/build/versions.env
44
5- TYPE ?= qcow2
5+ TYPE ?= raw.xz
66ARCH ?= $(shell uname -m)
77
88/build/distro.${TYPE}:
@@ -12,18 +12,41 @@ GO_ARCH := $(GO_ARCH:aarch64=arm64)
1212
1313INPUTS += root/build/nerdctl-$(NERDCTL_VERSION).tgz
1414
15- rancher-desktop-distro.%.qcow2 : config.kiwi config.sh ${INPUTS}
15+ rancher-desktop-distro.%.raw : config.kiwi config.sh ${INPUTS}
1616 kiwi --debug --profile=lima system build \
1717 --description /description --target-dir /build
1818
1919rancher-desktop-distro.%.tar.xz: config.kiwi config.sh ${INPUTS}
2020 kiwi --debug --profile=wsl system build \
2121 --description /description --target-dir /build
2222
23- /build/distro.qcow2: /build/rancher-desktop-distro.$(ARCH)-0.100.0.qcow2
24- mv $< $@
25-
23+ # Post-kiwi cleanup, then produce the requested output format.
24+ #
25+ # clean-rootfs.sh loop-mounts the raw disk, removes grub2 build tools
26+ # and other build-time artifacts, then fstrim's the filesystem so freed
27+ # blocks become holes. It runs here rather than in pre_disk_sync.sh
28+ # because kiwi re-invokes grub2-mkconfig on the mounted disk after that
29+ # hook.
30+ #
31+ # raw.xz — for macOS/VZ: qemu and VZ both consume raw directly.
32+ # qcow2.xz — for Linux/qemu: internally zstd-compressed, then
33+ # xz-compressed for storage/transfer.
34+ /build/distro.raw.xz: /build/rancher-desktop-distro.$(ARCH)-0.100.0.raw
35+ ./clean-rootfs.sh $<
36+ xz -9 --extreme --stdout $< > $@
37+
38+ /build/distro.qcow2: /build/rancher-desktop-distro.$(ARCH)-0.100.0.raw
39+ ./clean-rootfs.sh $<
40+ qemu-img convert -c -f raw $< -O qcow2 -o compression_type=zstd,compat=1.1 $@
41+
42+ /build/distro.qcow2.xz: /build/distro.qcow2
43+ xz -9 --extreme --stdout $< > $@
44+
45+ # Recompress the tarball kiwi leaves behind. Kiwi runs xz in threaded
46+ # mode with 24 MiB blocks, which loses a meaningful chunk of ratio to
47+ # block boundaries; a single xz -9 --extreme pass is ~14% smaller.
2648/build/distro.tar.xz: /build/rancher-desktop-distro.$(ARCH)-0.100.0.tar.xz
27- mv $< $@
49+ xz --decompress --stdout $< | xz -9 --extreme > $@
2850
51+ .INTERMEDIATE: /build/distro.qcow2
2952.DELETE_ON_ERROR: # Avoid half-downloaded files
0 commit comments