From 45692d4300a8bf68894438b98db231a40d4faac3 Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Tue, 12 Mar 2024 13:55:46 +0530 Subject: [PATCH 1/2] Add build_name metadata to build.info file for OCI and Base images Presence of this field helps in determining if the image is an unminimized image, which then can be leveraged in the unminimize script to easily determine the image type. --- live-build/auto/build | 11 +++++++++-- live-build/functions | 7 ------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index 9911708f..6704327e 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -430,9 +430,16 @@ serial: $BUILDSTAMP EOF fi - if [ "$PROJECT" = "ubuntu-oci" ]; then + if [ "${PROJECT}" = ubuntu-base ] || [ "${PROJECT}" = "ubuntu-oci" ]; then if [ -n "$BUILDSTAMP" ]; then - configure_oci chroot "$BUILDSTAMP" + mkdir -p chroot/etc/cloud + cat > chroot/etc/cloud/build.info << EOF +build_name: $PROJECT:${SUBPROJECT:} +serial: $BUILDSTAMP +EOF + if [ "${PROJECT}" = "ubuntu-oci" ]; then + configure_oci chroot "$BUILDSTAMP" + fi else echo "The \$BUILDSTAMP variable is empty" exit 1 diff --git a/live-build/functions b/live-build/functions index 695344eb..99c4708e 100644 --- a/live-build/functions +++ b/live-build/functions @@ -970,13 +970,6 @@ configure_oci() { 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 From 3bc9857bc75d34daedbe5ccc616e319c2ad71bda Mon Sep 17 00:00:00 2001 From: Utkarsh Gupta Date: Tue, 12 Mar 2024 20:48:47 +0530 Subject: [PATCH 2/2] Drop the second parameter passed to configure_oci This has become moot now that the code block has been moved out from live-build/functions to live-build/auto/build so passing the argument is not needed anymore. --- live-build/auto/build | 2 +- live-build/functions | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/live-build/auto/build b/live-build/auto/build index 6704327e..ec7ca52a 100755 --- a/live-build/auto/build +++ b/live-build/auto/build @@ -438,7 +438,7 @@ build_name: $PROJECT:${SUBPROJECT:} serial: $BUILDSTAMP EOF if [ "${PROJECT}" = "ubuntu-oci" ]; then - configure_oci chroot "$BUILDSTAMP" + configure_oci chroot fi else echo "The \$BUILDSTAMP variable is empty" diff --git a/live-build/functions b/live-build/functions index 99c4708e..266cc70c 100644 --- a/live-build/functions +++ b/live-build/functions @@ -955,7 +955,6 @@ 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"