From 4d28827db1b9c5e0ba2bead7ce425b4667810d22 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Fri, 20 Sep 2019 19:39:01 +0000 Subject: [PATCH] build: Add /.coreos-aleph-version.json to target It will be very useful in the future to be able to more rigorously know the state that a given machine *started* from. For example, small tweaks like `chattr +i /sysroot` are things that won't happen for in-place updates. The term "aleph" here means "start". If we decide to introduce a mechanism (e.g. systemd unit) that performs those changes even for old in-place installs, it could be useful to know exactly what the starting state was. Note this ends up in the *physical* storage root `/` which appears as `/sysroot` when booted. --- src/cmd-buildextend-metal | 2 +- src/create_disk.sh | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/cmd-buildextend-metal b/src/cmd-buildextend-metal index 3e5ad56d62..5193df4ed4 100755 --- a/src/cmd-buildextend-metal +++ b/src/cmd-buildextend-metal @@ -173,7 +173,7 @@ if [ -z "${use_anaconda}" ]; then ref_arg=${commit} fi - runvm -drive "if=virtio,id=target,format=${image_format},file=${path}.tmp" -- /usr/lib/coreos-assembler/create_disk.sh /dev/vda "$ostree_repo" "${ref_arg}" "${ostree_remote}" /usr/lib/coreos-assembler/grub.cfg "$name" "${save_var_subdirs}" "\"$kargs\"" + runvm -drive "if=virtio,id=target,format=${image_format},file=${path}.tmp" -- /usr/lib/coreos-assembler/create_disk.sh /dev/vda "${img}" "$ostree_repo" "${ref_arg}" "${ostree_remote}" /usr/lib/coreos-assembler/grub.cfg "$name" "${save_var_subdirs}" "\"$kargs\"" mv "${path}.tmp" "$path" echo "{}" > tmp/vm-iso-checksum.json else diff --git a/src/create_disk.sh b/src/create_disk.sh index 9270bb50f4..7592d8885e 100755 --- a/src/create_disk.sh +++ b/src/create_disk.sh @@ -10,8 +10,8 @@ # an issue and we can discuss configuration needs. set -euo pipefail -if [ "$#" -ne 8 ]; then - echo 'create_disk ' +if [ "$#" -ne 9 ]; then + echo 'create_disk ' exit 1 fi @@ -20,6 +20,7 @@ export PATH=$PATH:/sbin:/usr/sbin arch="$(uname -m)" disk="$1" && shift +buildid="$1" && shift ostree="$1" && shift ref="$1" && shift remote_name="$1" && shift @@ -87,6 +88,20 @@ do done ostree admin deploy "${deploy_ref}" --sysroot rootfs --os "$os_name" $kargsargs +# This will allow us to track the version that an install +# originally used; if we later need to understand something +# like "exactly what mkfs.xfs version was used" we can do +# that via looking at the upstream build and finding the +# build logs for it, getting the coreos-assembler version, +# and getting the `rpm -qa` from that. +ostree_commit=$(ostree --repo="${ostree}" rev-parse "${ref}") +cat > rootfs/.coreos-aleph-version.json << EOF +{ + "build": "${buildid}", + "ostree-commit": "${ostree_commit}" +} +EOF + # See the equivalent code in gf-anaconda-cleanup # /var hack: we'd like to remove all of /var, but SELinux issues prevent that. # see https://github.com/coreos/ignition-dracut/pull/79#issuecomment-488446949