Skip to content

Commit ccbe9ca

Browse files
committed
fix(installer-factory): Use the given path of the base ISO
The path was resolved against /output via basename, so a base ISO anywhere else failed with "Installer ISO not found". tool.sh now mounts it read-only at a path of its own. Also refuse a base ISO that resolves to the output file: xorriso would read and write one file, which is reachable because the output name is derived from the configuration. Signed-off-by: Simon Walz <contact@simonwalz.de>
1 parent f728a5b commit ccbe9ca

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎installer-factory/patch_iso.sh‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,31 @@ if [[ ! -d "${OUTPUT_DIR}" ]]; then
2020
exit 1
2121
fi
2222

23-
BASE_INSTALLER="${OUTPUT_DIR}/$(basename "$1")"
24-
if [[ -z "${BASE_INSTALLER}" || ! -f "${BASE_INSTALLER}" ]]; then
25-
echo "Error: Installer ISO not found." >&2
23+
# The base ISO is mounted into the container at a path of its own - tool.sh
24+
# mounts it read-only at /base.iso - so the given path is used as-is.
25+
BASE_INSTALLER="$1"
26+
if [[ -z "${BASE_INSTALLER}" ]]; then
27+
echo "Error: No base installer ISO given." >&2
28+
exit 1
29+
fi
30+
if [[ ! -f "${BASE_INSTALLER}" ]]; then
31+
echo "Error: Installer ISO not found: ${BASE_INSTALLER}" >&2
2632
exit 1
2733
fi
2834

2935
IMAGE_NAME="${IMAGE_NAME:-"installer"}"
3036
INSTALLER="${OUTPUT_DIR}/${IMAGE_NAME}.iso"
3137
CONFIG_PATH="${OUTPUT_DIR}/${IMAGE_NAME}.json"
3238

39+
# xorriso reads -indev and writes -outdev. If they resolve to the same file the
40+
# result is undefined. The output name is derived from the configuration, so
41+
# deriving from an ISO built with that same configuration lands on its own path.
42+
if [[ "$(realpath "${BASE_INSTALLER}")" == "$(realpath -m "${INSTALLER}")" ]]; then
43+
echo "Error: base installer and output are the same file: ${INSTALLER}" >&2
44+
echo " This writes a new ISO; it does not modify the base one." >&2
45+
exit 1
46+
fi
47+
3348
#xorriso -indev /output/CuOS-IaC-cuos-test.iso -ls /
3449

3550
xorriso \

0 commit comments

Comments
 (0)