git: 5c213bf01a5d - main - cloudware: allow disk format to be a list

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sun, 14 Apr 2024 23:45:58 UTC
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=5c213bf01a5dca7c4030efd2ad9c9f84852e7b32

commit 5c213bf01a5dca7c4030efd2ad9c9f84852e7b32
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2024-04-14 17:44:07 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-04-14 23:45:40 +0000

    cloudware: allow disk format to be a list
    
    Make basic-cloudinit available both in qcow2 and raw formats
    
    MFC After:      3 days
    Co-Authored-By: bapt
    Sponsored by:   OVHCloud (original patch from bapt)
    Differential Revision:  https://reviews.freebsd.org/D44747
---
 release/Makefile.vm | 48 ++++++++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/release/Makefile.vm b/release/Makefile.vm
index de73749f1985..83e3077b5bd4 100644
--- a/release/Makefile.vm
+++ b/release/Makefile.vm
@@ -30,7 +30,7 @@ AZURE_DESC=	Microsoft Azure platform image
 BASIC-CI_FORMAT=	raw
 BASIC-CI_FSLIST?=	ufs
 BASIC-CI_DESC=		Image for CI
-BASIC-CLOUDINIT_FORMAT=	raw
+BASIC-CLOUDINIT_FORMAT=	raw qcow2
 BASIC-CLOUDINIT_FSLIST?=	ufs zfs
 BASIC-CLOUDINIT_DESC?=	Images for VM with cloudinit disk config support
 EC2_FORMAT=	raw
@@ -103,32 +103,44 @@ QEMUTGT?=
 ${_CW:tu}CONF?=	${.CURDIR}/tools/${_CW:tl}.conf
 .  endif
 .  for _FS in ${${_CW:tu}_FSLIST}
-CLOUDTARGETS+=	cw-${_CW:tl}-${_FS}
-CLEANDIRS+=	cw-${_CW:tl}-${_FS}
-CLEANFILES+=	${_CW:tl}.${_FS}.img \
-		${_CW:tl}.${_FS}.${${_CW:tu}_FORMAT} \
-		${_CW:tl}.${_FS}.${${_CW:tu}_FORMAT}.raw
-${_CW:tu}${_FS:tu}IMAGE=	${_CW:tl}.${_FS}.${${_CW:tu}_FORMAT}
-
-cw-${_CW:tl}-${_FS}: ${QEMUTGT}
+.   for _FMT in ${${_CW:tu}_FORMAT}
+CLOUDTARGETS+=	cw-${_CW:tl}-${_FS}-${_FMT}
+CLEANDIRS+=	cw-${_CW:tl}-${_FS}-${_FMT}
+CLEANFILES+=	${_CW:tl}.${_FS}.${_FMT}.img \
+		${_CW:tl}.${_FS}.${_FMT} \
+		${_CW:tl}.${_FS}.${_FMT}.raw
+${_CW:tu}${_FS:tu}${_FMT:tu}IMAGE=	${_CW:tl}.${_FS}.${_FMT}
+
+cw-${_CW:tl}-${_FS}-${_FMT}: ${QEMUTGT}
 	mkdir -p ${.OBJDIR}/${.TARGET}
 	env TARGET=${TARGET} TARGET_ARCH=${TARGET_ARCH} SWAPSIZE=${SWAPSIZE} \
 		QEMUSTATIC=${QEMUSTATIC} \
 		${.CURDIR}/scripts/mk-vmimage.sh \
 		-C ${.CURDIR}/tools/vmimage.subr -d ${.OBJDIR}/${.TARGET} -F ${_FS} \
-		-i ${.OBJDIR}/${_CW:tl}.${_FS}.img -s ${VMSIZE} -f ${${_CW:tu}_FORMAT} \
-		-S ${WORLDDIR} -o ${.OBJDIR}/${${_CW:tu}${_FS:tu}IMAGE} -c ${${_CW:tu}CONF}
+		-i ${.OBJDIR}/${_CW:tl}.${_FS}.${_FMT}.img -s ${VMSIZE} -f ${_FMT} \
+		-S ${WORLDDIR} -o ${.OBJDIR}/${${_CW:tu}${_FS:tu}${_FMT:tu}IMAGE} -c ${${_CW:tu}CONF}
 	touch ${.TARGET}
+.   endfor
 .  endfor
 
-# Hardlinks from "foo.bar" to "foo-${VMFS}.bar".  These can go away once all
-# of the cloudware code knows how to handle multiple filesystem images (or
+# Hardlinks from "foo.${FMT}" to "foo-${VMFS}.${FMT}".  These can go away once
+# all of the cloudware code knows how to handle multiple filesystem images (or
 # at least knows the name of the UFS image).
-CLOUDTARGETS+=	cw-${_CW:tl}
-CLEANFILES+=	${_CW:tl}.${${_CW:tu}_FORMAT}
-${_CW:tu}IMAGE=	${_CW:tl}.${${_CW:tu}_FORMAT}
-cw-${_CW:tl}: cw-${_CW:tl}-${VMFS}
-	ln -f ${${_CW:tu}${VMFS:tu}IMAGE} ${${_CW:tu}IMAGE}
+.  for _FMT in ${${_CW:tu}_FORMAT}
+CLOUDTARGETS+=	cw-${_CW:tl}-${_FMT}
+CLEANFILES+=	${_CW:tl}.${_FMT}
+${_CW:tu}${_FMT:tu}IMAGE=	${_CW:tl}.${_FMT}
+cw-${_CW:tl}-${_FMT}: cw-${_CW:tl}-${VMFS}-${_FMT}
+	ln -f ${${_CW:tu}${VMFS:tu}${_FMT:tu}IMAGE} ${${_CW:tu}${_FMT:tu}IMAGE}
+.  endfor
+
+# Targets without a disk format listed are the first disk format on the list
+.  for _FS in ${${_CW:tu}_FSLIST}
+${_CW:tu}${_FS:tu}IMAGE=	${_CW:tl}.${_FS}.${${_CW:tu}_FORMAT:[1]}
+cw-${_CW:tl}-${_FS}: cw-${_CW:tl}-${_FS}-${${_CW:tu}_FORMAT:[1]}
+.  endfor
+${_CW:tu}IMAGE=	${_CW:tl}.${${_CW:tu}_FORMAT:[1]}
+cw-${_CW:tl}:	cw-${_CW:tl}-${${_CW:tu}_FORMAT:[1]}
 . endfor
 .endif