From aa1c6d9e194314ce9002e32d9927fc5f4d4a3432 Mon Sep 17 00:00:00 2001 From: Samir Akarioh Date: Thu, 29 Sep 2022 10:51:46 +0200 Subject: [PATCH] feat: Add metadata on ubuntu-oci image Add a file build.info on etc/cloud with the serial information Signed-off-by: Samir Akarioh (cherry picked from commit 105acdebc783291f740294b5c317f3e6d2da9de4) --- live-build/auto/build | 7 ++++++- live-build/functions | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/live-build/auto/build b/live-build/auto/build index ed93ec1c..e43165ee 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -458,7 +458,12 @@ EOF fi if [ "$PROJECT" = "ubuntu-oci" ]; then - configure_oci chroot + if [ -n "$BUILDSTAMP" ]; then + configure_oci chroot "$BUILDSTAMP" + else + echo "The \$BUILDSTAMP variable is empty" + exit 1 + fi fi configure_network_manager diff --git a/live-build/functions b/live-build/functions index 675fd819..8ee1731c 100644 --- a/live-build/functions +++ b/live-build/functions @@ -896,6 +896,12 @@ configure_oci() { # at https://github.com/tianon/docker-brew-ubuntu-core/blob/master/update.sh local chroot=$1 + local serial=$2 + + if [ ! -d "${chroot}" ]; then + echo "The chroot does not exist" + exit 1 + fi echo "==== Configuring OCI ====" @@ -904,6 +910,15 @@ configure_oci() { echo 'exit 101' >> ${chroot}/usr/sbin/policy-rc.d Chroot ${chroot} "chmod +x /usr/sbin/policy-rc.d" + + # Inject a build stamp into the image + + mkdir -p ${chroot}/etc/cloud + cat > ${chroot}/etc/cloud/build.info << EOF +serial: $serial +EOF + + # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L54-L56 Chroot ${chroot} "dpkg-divert --local --rename --add /sbin/initctl" cp -a ${chroot}/usr/sbin/policy-rc.d ${chroot}/sbin/initctl