summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-12-17 08:59:29 +0100
committerGitHub <noreply@github.com>2023-12-17 08:59:29 +0100
commitc457790d3423219c5a889b686af965589074aca6 (patch)
treed83b283f073daec56dd754e4118cacb062e99e72 /scripts
parentf5085df6fc1a1d516afa8f882ab7fcd7d8dee481 (diff)
parent553fe4fb0116d3d4a867f07ca3bdef65f6c6dbc0 (diff)
downloadvyos-build-c457790d3423219c5a889b686af965589074aca6.tar.gz
vyos-build-c457790d3423219c5a889b686af965589074aca6.zip
Merge pull request #463 from vyos/mergify/bp/sagitta/pr-462
T2640: update VyOS in docker image to current version (backport #462)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/check-qemu-install2
-rwxr-xr-xscripts/iso-to-oci63
2 files changed, 64 insertions, 1 deletions
diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install
index 9ad0c2e9..aa729c6d 100755
--- a/scripts/check-qemu-install
+++ b/scripts/check-qemu-install
@@ -271,7 +271,7 @@ gen_disk(args.disk)
if args.qemu_cmd:
tmp = get_qemu_cmd('TESTVM', kvm, args.uefi, args.disk, diskname_raid, args.iso)
- print(tmp)
+ os.system(tmp)
exit(0)
test_timeout = 3 *3600 # 3 hours (in seconds)
diff --git a/scripts/iso-to-oci b/scripts/iso-to-oci
new file mode 100755
index 00000000..c9396290
--- /dev/null
+++ b/scripts/iso-to-oci
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+function cleanup() {
+ if [[ -d $ROOTFS ]]; then
+ rm -rf $ROOTFS
+ fi
+ if [[ -d $UNSQUASHFS ]]; then
+ rm -rf $UNSQUASHFS
+ fi
+}
+
+if [[ $(/usr/bin/id -u) -ne 0 ]]; then
+ echo "Not running as root"
+ exit
+fi
+
+if [ "$#" -ne 1 ]; then
+ echo "Illegal number of parameters"
+fi
+
+ISO=$1
+ROOTFS=rootfs
+UNSQUASHFS=unsquashfs
+
+# ensure clean working directory
+cleanup
+
+mkdir $ROOTFS $UNSQUASHFS
+echo "I: mount ISO $ISO"
+mount -t iso9660 -o loop $ISO $ROOTFS/ >/dev/null 2>&1
+
+# create directory, unpack squashfs filesystem, get ISO version
+# and unmount ISO
+echo "I: extracting squashfs content"
+unsquashfs -follow -dest $UNSQUASHFS/ $ROOTFS/live/filesystem.squashfs >/dev/null 2>&1
+VERSION=$(jq --raw-output .version $ROOTFS/version.json)
+umount $ROOTFS/
+
+# fix locales for correct system configuration loading
+sed -i 's/^LANG=.*$/LANG=C.UTF-8/' $UNSQUASHFS/etc/default/locale
+
+# optional step: Decrease docker image size by deleting not necessary files for container
+rm -rf $UNSQUASHFS/boot/*.img
+rm -rf $UNSQUASHFS/boot/*vyos*
+rm -rf $UNSQUASHFS/boot/vmlinuz
+rm -rf $UNSQUASHFS/lib/firmware/
+rm -rf $UNSQUASHFS/usr/lib/x86_64-linux-gnu/libwireshark.so*
+rm -rf $UNSQUASHFS/lib/modules/*amd64-vyos
+rm -rf $UNSQUASHFS/root/.gnupg
+
+# create a symbolic link to the configuration
+ln -s /opt/vyatta/etc/config $UNSQUASHFS/config
+
+# create docker image
+echo "I: generate OCI container image vyos-$VERSION.tar"
+tar -C unsquashfs -c . -f vyos-$VERSION.tar
+
+echo "I: to import the previously generated OCI image to your local images run:"
+echo ""
+echo " docker import vyos-$VERSION.tar vyos:$VERSION --change 'CMD ["/sbin/init"]'"
+echo ""
+
+cleanup