From fc873d7a27e0077417b0963ae2553d0c5e7a0540 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 15:29:36 +0200 Subject: oci: T9269: compress container image with XZ Can be compresed with up to 75% ratio. --- scripts/iso-to-oci | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index f79c02a0..b2077d2c 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -57,7 +57,7 @@ unsquashfs -follow -dest "${UNSQUASHFS}/" "${ROOTFS}/live/filesystem.squashfs" > VERSION="$(jq --raw-output .version "${ROOTFS}/version.json")" # older ISOs predate ARM64 support and carry no architecture in version.json ARCH="$(jq --raw-output '.architecture // "amd64"' "${ROOTFS}/version.json")" -OCI_IMAGE="vyos-${VERSION}-oci-${ARCH}.tar" +OCI_IMAGE="vyos-${VERSION}-oci-${ARCH}.tar.xz" # fix locales for correct system configuration loading sed -i 's/^LANG=.*$/LANG=C.UTF-8/' "${UNSQUASHFS}/etc/default/locale" @@ -84,7 +84,7 @@ ln -s /opt/vyatta/etc/config "${UNSQUASHFS}/config" # create docker image echo "I: generate OCI container image ${OCI_IMAGE}" -tar -C "${UNSQUASHFS}" -c . -f "${OCI_IMAGE}" +XZ_OPT="-T0" tar --directory "${UNSQUASHFS}" --create . --xz --file "${OCI_IMAGE}" echo "I: to import the previously generated OCI image to your local images run:" echo "" -- cgit v1.2.3 From be6933e4f787b0ecef4564a6346a1252139226b3 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 15:30:44 +0200 Subject: oci: T9269: seed the VyOS pre-login banner --- scripts/iso-to-oci | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index b2077d2c..b2e54b92 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -62,6 +62,14 @@ OCI_IMAGE="vyos-${VERSION}-oci-${ARCH}.tar.xz" # fix locales for correct system configuration loading sed -i 's/^LANG=.*$/LANG=C.UTF-8/' "${UNSQUASHFS}/etc/default/locale" +# seed the VyOS pre-login banner - /etc/issue is owned by the base-files +# package and only replaced once system_login_banner.py runs on the first +# commit, but getty(8) is up long before that and would greet the user with +# "Debian GNU/Linux 12". Keep in sync with default_config_data in +# system_login_banner.py +printf 'Welcome to VyOS - \\n \\l\n\n' > "${UNSQUASHFS}/etc/issue" +: > "${UNSQUASHFS}/etc/issue.net" + # optional step: Decrease docker image size by deleting not necessary files for container rm -rf "${UNSQUASHFS}/boot" rm -rf "${UNSQUASHFS}/lib/firmware/" -- cgit v1.2.3 From 8f372f6d6811bbe4df35b4ec81a68ea8f3813a87 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 15:31:26 +0200 Subject: oci: T9269: add proper " escaping for printing image import command --- scripts/iso-to-oci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index b2e54b92..6c3f58c9 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -96,7 +96,7 @@ XZ_OPT="-T0" tar --directory "${UNSQUASHFS}" --create . --xz --file "${OCI_IMAGE echo "I: to import the previously generated OCI image to your local images run:" echo "" -echo " docker import --platform=linux/$ARCH $OCI_IMAGE vyos:$VERSION --change 'CMD ["/sbin/init"]'" +echo " docker import --platform=linux/$ARCH $OCI_IMAGE vyos/vyos:$VERSION --change 'CMD [\"/sbin/init\"]'" echo "" cleanup -- cgit v1.2.3 From 50055b79b1c75837549de02e05c4b9877e4c4262 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 15:35:51 +0200 Subject: oci: T9269: use list of dependent tools Instead of duplicating the code testing if a binary is present required for the script, use a list and loop instead. --- scripts/iso-to-oci | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index 6c3f58c9..bc132681 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -20,23 +20,22 @@ fi # ensure clean working directory cleanup -if ! command -v xorriso >/dev/null 2>&1; then - echo "E: missing dependency: xorriso" - echo " Install xorriso (recommended) or run inside the vyos-build container." - exit 2 -fi - -if ! command -v unsquashfs >/dev/null 2>&1; then - echo "E: missing dependency: unsquashfs" - echo " Install squashfs-tools or run inside the vyos-build container." - exit 2 -fi - -if ! command -v jq >/dev/null 2>&1; then - echo "E: missing dependency: jq" - echo " Install jq or run inside the vyos-build container." - exit 2 -fi +# required commands and the Debian package providing them +declare -A REQUIRED_COMMANDS=( + [xorriso]="xorriso" + [unsquashfs]="squashfs-tools" + [jq]="jq" + [tar]="tar" + [xz]="xz-utils" +) + +for cmd in "${!REQUIRED_COMMANDS[@]}"; do + if ! command -v "${cmd}" >/dev/null 2>&1; then + echo "E: missing dependency: ${cmd}" + echo " Install ${REQUIRED_COMMANDS[$cmd]} or run inside the vyos-build container." + exit 2 + fi +done WORKDIR="$(mktemp -d -t iso-to-oci.XXXXXXXXXX)" trap cleanup EXIT -- cgit v1.2.3 From dcb271a63c49beac90f81ea5bbc19feefc0b6f91 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 1 Sep 2026 14:45:22 +0000 Subject: oci: T9269: fix /config symlink creation /config already exists as an empty directory in the squashfs, so "ln -s /opt/vyatta/etc/config /config" did not create the intended symlink - it placed one at /config/config and left /config a dead directory. Verified in a running container built from the previous OCI image: readlink /config -> (empty) ls -ld /config -> drwxr-xr-x 2 root root 4096 /config readlink /config/config-> /opt/vyatta/etc/config Remove the directory first, refusing to continue if it ever carries content, so the breakage cannot silently reappear. --- scripts/iso-to-oci | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci index bc132681..86dd8687 100755 --- a/scripts/iso-to-oci +++ b/scripts/iso-to-oci @@ -86,7 +86,10 @@ rm -rf "${UNSQUASHFS}/opt/vyatta/share/vyatta-cfg/templates/system/option/root-p rm -rf "${UNSQUASHFS}/opt/vyatta/share/vyatta-cfg/templates/system/option/reboot-on-panic" rm -rf "${UNSQUASHFS}/opt/vyatta/share/vyatta-cfg/templates/system/option/performance" -# create a symbolic link to the configuration +# create a symbolic link to the configuration - /config already exists as an +# empty directory in the squashfs, so it must go first. A plain "ln -s" would +# happily create /config/config instead and leave /config a dead directory. +rmdir "${UNSQUASHFS}/config" || { echo "E: /config is not an empty directory"; exit 1; } ln -s /opt/vyatta/etc/config "${UNSQUASHFS}/config" # create docker image -- cgit v1.2.3