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.
This commit is contained in:
Utkarsh Gupta 2024-03-12 13:55:46 +05:30
parent a580abfcff
commit 45692d4300
2 changed files with 9 additions and 9 deletions

View File

@ -430,9 +430,16 @@ serial: $BUILDSTAMP
EOF EOF
fi fi
if [ "$PROJECT" = "ubuntu-oci" ]; then if [ "${PROJECT}" = ubuntu-base ] || [ "${PROJECT}" = "ubuntu-oci" ]; then
if [ -n "$BUILDSTAMP" ]; 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 else
echo "The \$BUILDSTAMP variable is empty" echo "The \$BUILDSTAMP variable is empty"
exit 1 exit 1

View File

@ -970,13 +970,6 @@ configure_oci() {
Chroot ${chroot} "chmod +x /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 # https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L54-L56
Chroot ${chroot} "dpkg-divert --local --rename --add /sbin/initctl" Chroot ${chroot} "dpkg-divert --local --rename --add /sbin/initctl"
cp -a ${chroot}/usr/sbin/policy-rc.d ${chroot}/sbin/initctl cp -a ${chroot}/usr/sbin/policy-rc.d ${chroot}/sbin/initctl