git: e8c5d6f6b89f - stable/14 - release: Publish OCI images on "ftp" mirrors

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Wed, 13 Nov 2024 06:42:09 UTC
The branch stable/14 has been updated by cperciva:

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

commit e8c5d6f6b89f38ed7c20ad5537fc82092106d378
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2024-11-13 06:36:14 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-11-13 06:42:04 +0000

    release: Publish OCI images on "ftp" mirrors
    
    If WITH_OCIIMAGES is set, "make ftp-stage" will now publish those bits
    into a directory under /OCI-IMAGES/, similar to how we publish CI and
    VM images.
    
    MFC after:      1 minute
    
    (cherry picked from commit e95e3e6eb7ef723aa5dd08de48a9ad3fec647c7d)
---
 release/Makefile.mirrors | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/release/Makefile.mirrors b/release/Makefile.mirrors
index 1888f86d3002..8af614d9a9bb 100644
--- a/release/Makefile.mirrors
+++ b/release/Makefile.mirrors
@@ -58,6 +58,11 @@ STAGE_TARGETS+=		ci-images-stage
 CI_DIR=			${TLD}/CI-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
 .endif
 
+.if defined(WITH_OCIIMAGES) && !empty(WITH_OCIIMAGES)
+STAGE_TARGETS+=		oci-images-stage
+OCI_DIR=		${TLD}/OCI-IMAGES/${REVISION}-${BRANCH}/${TARGET_ARCH}
+.endif
+
 CLEANFILES+=		${STAGE_TARGETS}
 CHECKSUM_FILES?=	SHA512 SHA256
 SNAP_SUFFIX!=		echo ${_SNAP_SUFFIX:S,^-,,1} | tr -d ' '
@@ -333,5 +338,53 @@ ci-images-stage:
 . endfor
 .endif
 
+oci-images-stage:
+	mkdir -p ${OCI_DIR}
+.if defined(SNAPSHOT) && !empty(SNAPSHOT)
+. if exists(${OCI_DIR}/Latest)
+	rm -rf ${OCI_DIR}/Latest
+. endif
+	mkdir -p ${OCI_DIR}/Latest
+	mkdir -p ${OCI_DIR}/${BUILDDATE}
+. for _IMG in ${OCI_IMAGES}
+	cd ${RELEASEDIR}/ociimages && \
+		mv container-image-${_IMG}.txz \
+		${OSRELEASE}-container-image-${SNAP_SUFFIX}-${_IMG}.txz
+	cp ${RELEASEDIR}/ociimages/${OSRELEASE}-container-image-${SNAP_SUFFIX}-${_IMG}.txz \
+		${OCI_DIR}/${BUILDDATE}/${OSRELEASE}-container-image-${SNAP_SUFFIX}-${_IMG}.txz
+	cd ${OCI_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/${OSRELEASE}-container-image-${SNAP_SUFFIX}-${_IMG}.txz \
+		${OSRELEASE}-container-image-${_IMG}.txz
+. endfor
+	cd ${RELEASEDIR}/ociimages && rm -f CHECKSUM.*
+. for CHECKSUM in ${CHECKSUM_FILES}
+	cd ${RELEASEDIR}/ociimages && \
+		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+	cp -p ${RELEASEDIR}/ociimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+		${OCI_DIR}/${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+	cd ${OCI_DIR}/Latest && \
+		ln -s ../${BUILDDATE}/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+		CHECKSUM.${CHECKSUM}
+. endfor
+.else # not snapshot
+. if exists(${OCI_DIR}/Latest)
+	rm -rf ${OCI_DIR}/Latest
+. endif
+	mkdir -p ${OCI_DIR}/Latest
+. for _IMG in ${OCI_IMAGES}
+	cd ${RELEASEDIR}/ociimages && \
+		mv container-image-${_IMG}.txz \
+		${OSRELEASE}-container-image-${_IMG}.txz
+	cp ${RELEASEDIR}/ociimages/${OSRELEASE}-container-image-${_IMG}.txz \
+		${OCI_DIR}/Latest/${OSRELEASE}-container-image-${_IMG}.txz
+. endfor
+. for CHECKSUM in ${CHECKSUM_FILES}
+	cd ${RELEASEDIR}/ociimages && \
+		${CHECKSUM:tl} ${OSRELEASE}* > CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX}
+	cp -p ${RELEASEDIR}/ociimages/CHECKSUM.${CHECKSUM}-${SNAP_SUFFIX} \
+		${OCI_DIR}/Latest/CHECKSUM.${CHECKSUM}
+. endfor
+.endif
+
 ftp-stage:	remove-old-bits ${STAGE_TARGETS}