diff --git a/src/cmd-buildextend-metal b/src/cmd-buildextend-metal index 3e5ad56d62..bad6e55464 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 "${build}" "${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..98a148ffcf 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 10 ]; then + echo 'create_disk ' exit 1 fi @@ -20,6 +20,8 @@ export PATH=$PATH:/sbin:/usr/sbin arch="$(uname -m)" disk="$1" && shift +buildid="$1" && shift +imgid="$1" && shift ostree="$1" && shift ref="$1" && shift remote_name="$1" && shift @@ -87,6 +89,32 @@ 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. +# +# build: The coreos-assembler build ID; today we support +# having the same ostree commit in different image builds. +# ref: The ostree ref used; the FCOS process does promotion +# and so this can change without changing the commit. +# ostree-commit: In theory, one can derive this from looking +# at the coreos-assembler builds, but it's very +# convenient to have here as a strong cross-reference. +# imgid: The full image name, the same as will end up in the +# `images` dict in `meta.json`. +ostree_commit=$(ostree --repo="${ostree}" rev-parse "${ref}") +cat > rootfs/.coreos-aleph-version.json << EOF +{ + "build": "${buildid}", + "ref": "${ref}", + "ostree-commit": "${ostree_commit}", + "imgid": "${imgid}" +} +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