Skip to content

Commit

Permalink
osmet-pack: run coreos-installer in target rootfs
Browse files Browse the repository at this point in the history
Otherwise, we might get linking issues if the target system has newer
e.g. glibc. We could use `bwrap` here instead of `chroot`, but meh this
is easier and the block device itself is read-only anyway.

I was initially trying to get this code to use the qemu image directly,
but we have a bunch of issues there with our systemd services getting
confused by the metal disk containing identical boot and root
partitions (which... we should circle back to eventually).

Closes: coreos#1761
  • Loading branch information
jlebon committed Oct 6, 2020
1 parent ce41407 commit e43ea7f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/osmet-pack
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ deploydir=$(find "/sysroot/ostree/deploy/$osname/deploy" -mindepth 1 -maxdepth 1
description=$(. "${deploydir}/etc/os-release" && echo "${PRETTY_NAME}")

if [ -z "${coreinst}" ]; then
coreinst=${deploydir}/usr/bin/coreos-installer
# if we weren't given a custom coreos-installer, then we want to use the one
# from the target system itself; chroot into it to avoid linking issues
for mnt in dev proc sys run var tmp; do
mount --rbind /$mnt "${deploydir}/$mnt"
done
coreinst="chroot ${deploydir} coreos-installer"
fi

case "$speed" in
Expand All @@ -87,10 +92,12 @@ case "$speed" in
*) exit 1 ;;
esac

# We don't want double quotes because passing '' is not what we want
# We don't want double quotes (for both `coreinst` and `fast`, which may be '')
# shellcheck disable=SC2086
RUST_BACKTRACE=full "${coreinst}" osmet pack /dev/disk/by-id/virtio-osmet \
RUST_BACKTRACE=full ${coreinst} osmet pack /dev/disk/by-id/virtio-osmet \
--description "${description}" \
--checksum "${checksum}" \
${real_rootdev:+--real-rootdev ${real_rootdev}} \
--output "${osmet_dest}" $fast
--output /tmp/osmet.bin $fast

mv /tmp/osmet.bin "${osmet_dest}"

0 comments on commit e43ea7f

Please sign in to comment.