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 1fe8e03 commit 4a11d96
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cmd-buildextend-metal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 20 additions & 2 deletions src/create_disk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# an issue and we can discuss configuration needs.
set -euo pipefail

if [ "$#" -ne 8 ]; then
echo 'create_disk <device> <ostree-repo> <ostree-ref> <ostree-remote> <grub-script> <os-name> <save-var-subdirs> <space separated kargs>'
if [ "$#" -ne 10 ]; then
echo 'create_disk <device> <buildid> <imageid> <ostree-repo> <ostree-ref> <ostree-remote> <grub-script> <os-name> <save-var-subdirs> <space separated kargs>'
exit 1
fi

Expand All @@ -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
Expand Down Expand Up @@ -87,6 +89,22 @@ 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}",
"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 4a11d96

Please sign in to comment.