[PATCH v5 06/13] CI: extract building domU/dom0 out of qemu-alpine-x86_64.sh

Marek Marczykowski-Górecki <[email protected]>
Newsgroups org.xenproject.lists.xen-devel
Message-ID <ddb2b1dbebaa662c15957587ac2aeb74007464b3.1785941707.git-series.marmarek@invisiblethingslab.com>
Add qemu-alpine-lib.sh with utility functions that build dom0/domU out
of container binaries.
This will be used in further tests that re-use similar structure.

Signed-off-by: Marek Marczykowski-Górecki <[email protected]>
---
New in v5
---
 automation/scripts/qemu-alpine-lib.sh    | 62 +++++++++++++++++++++++++-
 automation/scripts/qemu-alpine-x86_64.sh | 59 +-----------------------
 2 files changed, 66 insertions(+), 55 deletions(-)
 create mode 100755 automation/scripts/qemu-alpine-lib.sh

diff --git a/automation/scripts/qemu-alpine-lib.sh b/automation/scripts/qemu-alpine-lib.sh
new file mode 100755
index 000000000000..29fdff4f562a
--- /dev/null
+++ b/automation/scripts/qemu-alpine-lib.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+build_domU() {
+    # DomU Busybox
+    mkdir -p initrd
+    mkdir -p initrd/bin
+    mkdir -p initrd/sbin
+    mkdir -p initrd/etc
+    mkdir -p initrd/dev
+    mkdir -p initrd/proc
+    mkdir -p initrd/sys
+    mkdir -p initrd/lib
+    mkdir -p initrd/var
+    mkdir -p initrd/mnt
+    cp /bin/busybox initrd/bin/busybox
+    initrd/bin/busybox --install initrd/bin
+    echo "#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -t devtmpfs devtmpfs /dev
+/bin/sh" > initrd/init
+    chmod +x initrd/init
+    # DomU rootfs
+    cd initrd
+    find . | cpio -R 0:0 -H newc -o | gzip > ../domU-rootfs.cpio.gz
+    cd ..
+}
+
+build_dom0() {
+    # Dom0 rootfs
+    cp rootfs.cpio.gz dom0-rootfs.cpio.gz
+    cat xen-tools.cpio.gz >> dom0-rootfs.cpio.gz
+
+    # test-local configuration
+    mkdir -p rootfs
+    cd rootfs
+    mkdir -p root etc/local.d
+    mv ../domU-rootfs.cpio.gz ./root
+    cp ../bzImage ./root
+    echo "name=\"domU\"
+    memory=512
+    vcpus=1
+    kernel=\"/root/bzImage\"
+    ramdisk=\"/root/domU-rootfs.cpio.gz\"
+    extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
+    " > root/domU.cfg
+    echo "#!/bin/bash
+
+    set -x
+
+    bash /etc/init.d/xencommons start
+
+    xl list
+
+    xl -vvv create -c /root/domU.cfg
+
+    " > etc/local.d/xen.start
+    chmod +x etc/local.d/xen.start
+    find . | cpio -R 0:0 -H newc -o | gzip >> ../dom0-rootfs.cpio.gz
+    cd ..
+}
diff --git a/automation/scripts/qemu-alpine-x86_64.sh b/automation/scripts/qemu-alpine-x86_64.sh
index 0c60b2503858..e1b5060f4490 100755
--- a/automation/scripts/qemu-alpine-x86_64.sh
+++ b/automation/scripts/qemu-alpine-x86_64.sh
@@ -2,64 +2,13 @@
 
 set -ex -o pipefail
 
-# DomU Busybox
-cd binaries
-mkdir -p initrd
-mkdir -p initrd/bin
-mkdir -p initrd/sbin
-mkdir -p initrd/etc
-mkdir -p initrd/dev
-mkdir -p initrd/proc
-mkdir -p initrd/sys
-mkdir -p initrd/lib
-mkdir -p initrd/var
-mkdir -p initrd/mnt
-cp /bin/busybox initrd/bin/busybox
-initrd/bin/busybox --install initrd/bin
-echo "#!/bin/sh
+. "$(dirname "$0")"/qemu-alpine-lib.sh
 
-mount -t proc proc /proc
-mount -t sysfs sysfs /sys
-mount -t devtmpfs devtmpfs /dev
-/bin/sh" > initrd/init
-chmod +x initrd/init
-# DomU rootfs
-cd initrd
-find . | cpio -R 0:0 -H newc -o | gzip > ../domU-rootfs.cpio.gz
+cd binaries
+build_domU
+build_dom0
 cd ..
 
-# Dom0 rootfs
-cp rootfs.cpio.gz dom0-rootfs.cpio.gz
-cat xen-tools.cpio.gz >> dom0-rootfs.cpio.gz
-
-# test-local configuration
-mkdir -p rootfs
-cd rootfs
-mkdir -p root etc/local.d
-mv ../domU-rootfs.cpio.gz ./root
-cp ../bzImage ./root
-echo "name=\"domU\"
-memory=512
-vcpus=1
-kernel=\"/root/bzImage\"
-ramdisk=\"/root/domU-rootfs.cpio.gz\"
-extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
-" > root/domU.cfg
-echo "#!/bin/bash
-
-set -x
-
-bash /etc/init.d/xencommons start
-
-xl list
-
-xl -vvv create -c /root/domU.cfg
-
-" > etc/local.d/xen.start
-chmod +x etc/local.d/xen.start
-find . | cpio -R 0:0 -H newc -o | gzip >> ../dom0-rootfs.cpio.gz
-cd ../..
-
 cat >> binaries/pxelinux.0 << EOF
 #!ipxe
 
-- 
git-series 0.9.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.