From: Jan Kiszka <[email protected]>

We are starting to pile up images, and the user will rarely like to
build them all or select one via the unhandle KAS_TARGET variable. Add
an interactive selection mode to build-images.sh which presents all
available images and asks the user to select one or more.

The image list is maintained in an additional file which allows to add
some descriptions. File format is simple: <MACHINE><TABS><DESCRIPTION>.

Signed-off-by: Jan Kiszka <[email protected]>
---
 build-images.sh | 43 +++++++++++++++++++++++++++++++++++++++++++
 images.list     |  3 +++
 2 files changed, 46 insertions(+)
 create mode 100644 images.list

diff --git a/build-images.sh b/build-images.sh
index 957efb1..6a1430c 100755
--- a/build-images.sh
+++ b/build-images.sh
@@ -47,6 +47,49 @@ while [ $# -gt 0 ]; do
        esac
 done
 
+if [ -z "${KAS_TARGET}" ]; then
+       echo "Available images demo images:"
+       IFS="   "
+       MACHINES=
+       NUM_MACHINES=0
+       while read MACHINE DESCRIPTION; do
+               MACHINES="${MACHINES} ${MACHINE}"
+               NUM_MACHINES=$((NUM_MACHINES + 1))
+               echo " ${NUM_MACHINES}: ${DESCRIPTION}"
+       done < images.list
+       echo " 0: all (may take hours...)"
+       echo ""
+
+       echo -n "Select images to build (space-separated index list): "
+       read SELECTION
+       [ -z "${SELECTION}" ] && exit 0
+
+       IFS=" "
+       KAS_TARGET=
+       for IDX in ${SELECTION}; do
+               if [ ${IDX} -eq 0 ] 2>/dev/null; then
+                       KAS_TARGET=
+                       for MACHINE in ${MACHINES}; do
+                               KAS_TARGET="${KAS_TARGET} 
multiconfig:${MACHINE}-jailhouse:demo-image"
+                       done
+                       break
+               fi
+
+               N=1
+               for MACHINE in ${MACHINES}; do
+                       if [ ${N} -eq ${IDX} ] 2>/dev/null; then
+                               KAS_TARGET="${KAS_TARGET} 
multiconfig:${MACHINE}-jailhouse:demo-image"
+                               break
+                       fi
+                       N=$((N + 1))
+               done
+               if [ ${N} -gt ${NUM_MACHINES} ]; then
+                       echo "Invalid index: ${IDX}"
+                       exit 1
+               fi
+       done
+fi
+
 mkdir -p out
 docker run -v $(pwd):/jailhouse-images:ro -v $(pwd)/out:/out:rw \
           -e USER_ID=$(id -u) -e SHELL=${SHELL} \
diff --git a/images.list b/images.list
new file mode 100644
index 0000000..ee2c44c
--- /dev/null
+++ b/images.list
@@ -0,0 +1,3 @@
+qemuamd64      QEMU/KVM Intel-x86 virtual target
+qemuarm64      QEMU ARM64 virtual target
+orangepi-zero  Orange Pi Zero (256 MB edition)
-- 
2.16.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to