Skip to content

Commit 9a476b9

Browse files
committed
feat(factories): mark the steps of a build with "==>"
cuos-release/tool.sh puts a build's technical output in output/NAME.build.log and passes lines carrying this marker through to the terminal. All the factories have to do is say where they are; the separating happens over there, which is why set -ex and both Dockerfiles stay as they are. Nothing else changes: the trace of the echo itself does not match the anchored marker on the other side, and a factory run directly just gets a prefix on six of its lines. prepare_iso.sh is left alone - it runs at docker build time, so its output only ever reaches the CI job that publishes the image. Not run: no factory image was built from this. The step lines were checked against tool.sh with a stub mirroring these scripts. Signed-off-by: Simon Walz <contact@simonwalz.de>
1 parent 250718a commit 9a476b9

3 files changed

Lines changed: 38 additions & 7 deletions

File tree

‎image-factory/create_image.sh‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ raise() {
66
exit 1
77
}
88

9+
# One line per step of the build, marked for whoever is running this factory.
10+
# cuos-release/tool.sh passes lines carrying this marker through to the terminal
11+
# and puts everything else in output/NAME.build.log; run directly, the marker is
12+
# just a prefix. Keep it in step with log_is_step_line() over there.
13+
step() {
14+
echo "==> $*"
15+
}
16+
917
cleanup() {
1018
# Versuche, gemountete Partitionen zu unmounten
1119
umount -R /mnt/os 2>/dev/null || true
@@ -108,13 +116,15 @@ if [[ "${OS_ARCH}" == "lxc" ]]; then
108116
IMAGE="${IMAGE/img/tar.gz}"
109117
SLOT="A"
110118

119+
step "Fetching the system image ${OS_IMAGE}"
111120
docker image pull "${OS_IMAGE}" || raise "Faild to fetch image"
112121
IMAGE_DIGEST="$(docker inspect --format='{{index .RepoDigests 0}}' "${OS_IMAGE}" 2>/dev/null | cut -d '@' -f 2)"
113122
if [[ -n "${OS_DIGEST}" && "${OS_DIGEST}" != "${IMAGE_DIGEST}" ]]; then
114123
echo "Image digest mismatch: ${OS_DIGEST} != ${IMAGE_DIGEST}"
115124
exit 1
116125
fi
117126

127+
step "Initialising the system"
118128
CONTAINER_NAME="cuos-lxc-$$"
119129
docker run -it -d \
120130
--pull=never \
@@ -126,13 +136,14 @@ if [[ "${OS_ARCH}" == "lxc" ]]; then
126136
docker cp "${CONFIG_PATH}" "${CONTAINER_NAME}:/system_init.json" \
127137
|| raise "Failed to copy system.json"
128138

139+
step "Exporting the root filesystem"
129140
if ! docker export "${CONTAINER_NAME}" | gzip >"${IMAGE}"; then
130141
raise "Failed to export the container"
131142
fi
132143
docker rm -f "${CONTAINER_NAME}" \
133144
|| raise "Failed to remove the container"
134145

135-
echo "Image created at ${IMAGE/\//}"
146+
step "${IMAGE/\//} written"
136147
exit 0
137148
fi
138149

@@ -146,10 +157,11 @@ fi
146157
SIZE_MB="$(jq --arg size_mb "${SIZE_MB}" -r '.image_size_mb // $size_mb' "${CONFIG_PATH}")"
147158

148159
# Create empty image
149-
echo "Create empty image:"
160+
step "Creating an empty image of ${SIZE_MB} MB"
150161
dd if=/dev/zero of="${IMAGE}" bs=1M count="${SIZE_MB}"
151162
sync
152163

164+
step "Partitioning for '${TARGET}'"
153165
if [[ "${TARGET}" == "rpi" ]]; then
154166
parted "${IMAGE}" --script \
155167
mklabel msdos \
@@ -280,6 +292,7 @@ TARGET_ROOT_PARTITION="/dev/mapper/$(basename "${LOOPDEV}")p${TARGET_ROOT_PARTIT
280292
export TARGET_ROOT_PARTITION
281293

282294
# Format partitions
295+
step "Creating the filesystems"
283296
mkfs.vfat -n boot "${TARGET_BOOT_PARTITION}" \
284297
|| raise "Failed to format boot partition: ${TARGET_BOOT_PARTITION}"
285298
mkfs.btrfs -L system "${TARGET_ROOT_PARTITION}" \
@@ -297,6 +310,7 @@ mkdir -p /mnt/root/@data/log
297310
umount /mnt/root
298311

299312

313+
step "Installing the system from ${OS_IMAGE}"
300314
export INSTALLIMAGE=true
301315
/usr/local/updater/updater.sh \
302316
"${SLOT}" \
@@ -315,7 +329,7 @@ if [[ "${EXITCODE}" != "0" ]]; then
315329
raise "Failed to run updater script"
316330
fi
317331

318-
echo "Image created at ${IMAGE/\//}"
332+
step "${IMAGE/\//} written"
319333

320334

321335
# File formats:

‎installer-factory/create_iso.sh‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33

44
set -ex
55

6+
# One line per step of the build, marked for whoever is running this factory.
7+
# cuos-release/tool.sh passes lines carrying this marker through to the terminal
8+
# and puts everything else in output/NAME.build.log; run directly, the marker is
9+
# just a prefix. Keep it in step with log_is_step_line() over there.
10+
step() {
11+
echo "==> $*"
12+
}
13+
614
VOLID="CUOS"
715
WORKDIR="/build"
816
ISO_DIR="${WORKDIR}/iso"
@@ -30,6 +38,7 @@ export CONFIG_PATH="${OUTPUT_DIR}/${IMAGE_NAME}.json"
3038

3139
# compress image using zstd (multi-threaded, level 9) and copy to the ISO dir
3240
# choose level 9 as a balance between compression ratio and build time; adjust as desired
41+
step "Compressing the system image"
3342
zstd -T0 -9 -c "${IMAGE}" > "${ISO_DIR}/image.img.zst"
3443

3544
PRODUCT_NAME="CuOS"
@@ -50,12 +59,12 @@ if [[ -f "${CONFIG_PATH}" ]]; then
5059
fi
5160
fi
5261

62+
step "Building the bootable ISO"
5363
grub-mkrescue \
5464
-o "${INSTALLER}" \
5565
-V "${VOLID}" \
5666
-iso-level 3 \
5767
-full-iso9660-filenames \
5868
"${ISO_DIR}" || exit 1
5969

60-
echo "ISO creation complete."
61-
echo "Installer written to ${INSTALLER/\//}"
70+
step "${INSTALLER/\//} written"

‎installer-factory/patch_iso.sh‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313

1414
set -ex
1515

16+
# One line per step of the build, marked for whoever is running this factory.
17+
# cuos-release/tool.sh passes lines carrying this marker through to the terminal
18+
# and puts everything else in output/NAME.build.log; run directly, the marker is
19+
# just a prefix. Keep it in step with log_is_step_line() over there.
20+
step() {
21+
echo "==> $*"
22+
}
23+
1624
OUTPUT_DIR="/output"
1725

1826
if [[ ! -d "${OUTPUT_DIR}" ]]; then
@@ -47,6 +55,7 @@ fi
4755

4856
#xorriso -indev /output/CuOS-IaC-cuos-test.iso -ls /
4957

58+
step "Replacing the configuration in the ISO"
5059
xorriso \
5160
-indev "${BASE_INSTALLER}" \
5261
-outdev "${INSTALLER}" \
@@ -55,5 +64,4 @@ xorriso \
5564
-compliance no_emul_toc \
5665
-padding included
5766

58-
echo "ISO patching complete."
59-
echo "Installer written to ${INSTALLER/\//}"
67+
step "${INSTALLER/\//} written"

0 commit comments

Comments
 (0)