From a6bca635f698285161d73f5b3bec7d0d56626382 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mar 05 2020 20:36:36 +0000 Subject: Mention upstream submitted symlink patch Signed-off-by: Cole Robinson --- diff --git a/kata-osbuilder.spec b/kata-osbuilder.spec index 0eab461..0e9d3e2 100644 --- a/kata-osbuilder.spec +++ b/kata-osbuilder.spec @@ -40,8 +40,8 @@ Source5: 15-dracut-fedora.conf # Submitted upstream: https://github.com/kata-containers/osbuilder/pull/418 Patch01: osbuilder-0001-image_builder-Remove-nsdax-binary-after-its-usage.patch Patch02: osbuilder-0002-image-builder-Add-NSDAX_BIN-for-passing-in-compiled-.patch -# Fix symlinks in the dracut_overlay to not clobber Fedora. -# Needs to be submitted upstream +# Don't clobber our pre-populated /sbin/init +# https://github.com/kata-containers/osbuilder/pull/420 Patch03: osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch diff --git a/osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch b/osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch index bd2806a..d66b6a6 100644 --- a/osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch +++ b/osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch @@ -1,25 +1,41 @@ -From 80645c689418f13d6fbe60e8c87ca16787705687 Mon Sep 17 00:00:00 2001 +From 79d298779854b6028de75804f415cb6cc5a5fd5f Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 4 Mar 2020 17:56:03 -0500 Subject: [PATCH] rootfs: Don't overwrite /init if it already exists +The prepare_overlay() code path is called when rootfs.sh is invoked +with no passed in distro string. This is used for the dracut case +from the Makefile for example. In that particular case, the starting +root directory is empty. + +It's also valid to pass a prepopulated directory to rootfs.sh, which +is essentially a request for the script to just make the necessary +kata changes. Currently though prepare_overlay() makes some changes +that could wipe out pre-arranged /sbin/init setup. + +Check first to see if /sbin/init exists in the rootfs dir, and if so, +skip the symlink changes + +Fixes: #419 + Signed-off-by: Cole Robinson --- - rootfs-builder/rootfs.sh | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) + rootfs-builder/rootfs.sh | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh -index 5a5655e..554ed67 100755 +index 5a5655e..f8714ab 100755 --- a/rootfs-builder/rootfs.sh +++ b/rootfs-builder/rootfs.sh -@@ -455,9 +455,15 @@ prepare_overlay() +@@ -455,10 +455,16 @@ prepare_overlay() { pushd "${ROOTFS_DIR}" > /dev/null mkdir -p ./etc ./lib/systemd ./sbin ./var - ln -sf ./usr/lib/systemd/systemd ./init - ln -sf ../../init ./lib/systemd/systemd - ln -sf ../init ./sbin/init -+ if [ ! -e ./init ]; then +- # Kata sytemd unit file ++ if [ ! -e ./sbin/init ]; then + # This symlink hacking is mostly to make later rootfs + # validation work correctly for the dracut case. + # We skip this if /init exists in the rootfs, meaning @@ -28,6 +44,7 @@ index 5a5655e..554ed67 100755 + ln -sf ../../init ./lib/systemd/systemd + ln -sf ../init ./sbin/init + fi - # Kata sytemd unit file ++ # Kata systemd unit file mkdir -p ./etc/systemd/system/basic.target.wants/ ln -sf /usr/lib/systemd/system/kata-containers.target ./etc/systemd/system/basic.target.wants/kata-containers.target + popd > /dev/null