Skip to content

Commit

Permalink
build: Add /.coreos-aleph-version.json to target
Browse files Browse the repository at this point in the history
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.

Closes: coreos/fedora-coreos-tracker#170
  • Loading branch information
cgwalters committed Sep 23, 2019
1 parent eb056d7 commit 2701e91
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ if [ -z "${use_anaconda}" ]; then
runvm -drive "if=virtio,id=target,format=${image_format},file=${path}.tmp" -- \
/usr/lib/coreos-assembler/create_disk.sh \
--disk /dev/vda \
--buildid "${build}" \
--imgid "${img}" \
--grub-script /usr/lib/coreos-assembler/grub.cfg \
--kargs "\"${kargs}\"" \
--osname "${name}" \
Expand Down
31 changes: 31 additions & 0 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Fedora CoreOS style disk image from an OS Tree.
Options:
--disk: disk device to use
--buildid: buildid
--imgid: imageid
--grub-script: grub script to install
--help: show this helper
--kargs: kernel CLI args
Expand All @@ -37,6 +39,8 @@ do
flag="${1}"; shift;
case "${flag}" in
--disk) disk="${1}"; shift;;
--buildid) buildid="${1}"; shift;;
--imgid) imgid="${1}"; shift;;
--grub-script) grub_script="${1}"; shift;;
--help) usage; exit;;
--kargs) extrakargs="${extrakargs} ${1}"; shift;;
Expand All @@ -53,6 +57,8 @@ done
export PATH=$PATH:/sbin:/usr/sbin
arch="$(uname -m)"
disk="${disk:?--disk must be defined}"
buildid="${buildid:?--buildid must be defined}"
imgid="${imgid:?--imgid must be defined}"
ostree="${ostree:?--ostree-repo must be defined}"
ref="${ref:?--ostree-ref must be defined}"
remote_name="${remote_name:?--ostree-remote must be defined}"
Expand Down Expand Up @@ -119,6 +125,31 @@ 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; useful for cross-checking.
# ostree-commit: Similar to `ref`; 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
Expand Down

0 comments on commit 2701e91

Please sign in to comment.