Skip to content

Commit 27d539f

Browse files
committed
Address code review feedback
- Add *.raw.xz to .gitignore and .dockerignore - Use long-form xz options (--extreme, --stdout, --decompress) - Drop --threads=0 (already the default) - Split qcow2.xz build into separate qcow2 and xz rules with .INTERMEDIATE so make handles cleanup on failure - Improve error message when ext4 partition is not found - List all three build types in README - Add kiwi-runtime.yml with xz -0 so kiwi does not waste time on compression we discard and recompress at -9 --extreme Signed-off-by: Jan Dubois <jan.dubois@suse.com>
1 parent 4858d9b commit 27d539f

6 files changed

Lines changed: 22 additions & 11 deletions

File tree

.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
distro.tar.xz
22
distro.qcow2.xz
3+
distro.raw.xz

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/root/build/
22
*.qcow2.xz
3+
*.raw.xz
34
*.tar.xz

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g
2020
FROM registry.opensuse.org/opensuse/bci/kiwi:10 AS builder
2121
ARG type=qcow2.xz
2222
ARG NERDCTL_VERSION
23+
# The BCI kiwi image ships /etc/kiwi.yml with mapper and runtime_checks
24+
# settings required for building inside Docker. Append xz -0 so kiwi
25+
# does not waste time on compression we discard and recompress at
26+
# xz -9 --extreme in Makefile.docker. Using --config would replace the
27+
# existing file and lose the mapper setting, breaking loop devices.
2328
RUN --mount=type=cache,target=/var/cache/zypp \
24-
zypper --non-interactive install parted
29+
zypper --non-interactive install parted && \
30+
echo -e '\nxz:\n - options: '\''-0'\''' >> /etc/kiwi.yml
2531
WORKDIR /build
2632
COPY . /description
2733
COPY --from=gobuild /go/bin/* /description/root/usr/local/bin/

Makefile.docker

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,20 @@ rancher-desktop-distro.%.tar.xz: config.kiwi config.sh ${INPUTS}
3333
# xz-compressed for storage/transfer.
3434
/build/distro.raw.xz: /build/rancher-desktop-distro.$(ARCH)-0.100.0.raw
3535
./clean-rootfs.sh $<
36-
xz -9e -T0 -c $< > $@
36+
xz -9 --extreme --stdout $< > $@
3737

38-
/build/distro.qcow2.xz: /build/rancher-desktop-distro.$(ARCH)-0.100.0.raw
38+
/build/distro.qcow2: /build/rancher-desktop-distro.$(ARCH)-0.100.0.raw
3939
./clean-rootfs.sh $<
40-
qemu-img convert -c -f raw $< -O qcow2 -o compression_type=zstd,compat=1.1 $(@:.xz=)
41-
xz -9e -T0 -c $(@:.xz=) > $@
42-
rm $(@:.xz=)
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 $< > $@
4344

4445
# Recompress the tarball kiwi leaves behind. Kiwi runs xz in threaded
4546
# mode with 24 MiB blocks, which loses a meaningful chunk of ratio to
46-
# block boundaries; a single xz -9e pass is ~14% smaller.
47+
# block boundaries; a single xz -9 --extreme pass is ~14% smaller.
4748
/build/distro.tar.xz: /build/rancher-desktop-distro.$(ARCH)-0.100.0.tar.xz
48-
xz -dc $< | xz -9e -T0 > $@
49+
xz --decompress --stdout $< | xz -9 --extreme > $@
4950

51+
.INTERMEDIATE: /build/distro.qcow2
5052
.DELETE_ON_ERROR: # Avoid half-downloaded files

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ Desktop.
55

66
The distribution is built using `docker`:
77
```sh
8-
make TYPE=qcow2.xz # For Linux/darwin hosts
9-
make TYPE=tar.xz # For WSL hosts
8+
make TYPE=raw.xz # For macOS/VZ hosts (default)
9+
make TYPE=qcow2.xz # For Linux/qemu hosts
10+
make TYPE=tar.xz # For WSL hosts
1011
```
1112

1213
To cross-compile for a non-native architecture, set `GOARCH` to the target

clean-rootfs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ for p in /dev/mapper/"$(basename "$LOOP")"p*; do
2222
ROOT=$p
2323
break
2424
done
25-
test -n "$ROOT"
25+
: ${ROOT:?Failed to find ext4 partition in $RAW}
2626

2727
MNT=$(mktemp -d)
2828
mount "$ROOT" "$MNT"

0 commit comments

Comments
 (0)