[neon/neon/livecd-rootfs/Neon/release] live-build: feat: Add metadata on ubuntu-oci image
Samir Akarioh
null at kde.org
Thu Jan 5 14:39:47 GMT 2023
Git commit 06dff46b6bd1395c30ef6c8023f300c0566dfc02 by Samir Akarioh.
Committed on 22/11/2022 at 11:20.
Pushed by jriddell into branch 'Neon/release'.
feat: Add metadata on ubuntu-oci image
Add a file build.info on etc/cloud
with the serial information
Signed-off-by: Samir Akarioh <samir.akarioh at canonical.com>
(cherry picked from commit 105acdebc783291f740294b5c317f3e6d2da9de4)
M +6 -1 live-build/auto/build
M +15 -0 live-build/functions
https://invent.kde.org/neon/neon/livecd-rootfs/commit/06dff46b6bd1395c30ef6c8023f300c0566dfc02
diff --git a/live-build/auto/build b/live-build/auto/build
index 1b6ee503..0af3bde5 100755
--- a/live-build/auto/build
+++ b/live-build/auto/build
@@ -462,7 +462,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 79cca5ef..f80f1a39 100644
--- a/live-build/functions
+++ b/live-build/functions
@@ -922,6 +922,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 ===="
@@ -930,6 +936,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
More information about the Neon-commits
mailing list