From e125ba303a400a59dd8ca5a93affb872fac56b00 Mon Sep 17 00:00:00 2001 From: Fabiano FidĂȘncio Date: Mar 23 2020 16:57:38 +0000 Subject: Rename 0002-rootfs-... to 0003-rootfs-... It's only a cosmetic change to match the patch number in the spec file. Signed-off-by: Fabiano FidĂȘncio --- diff --git a/kata-osbuilder.spec b/kata-osbuilder.spec index e9da93e..1ca8746 100644 --- a/kata-osbuilder.spec +++ b/kata-osbuilder.spec @@ -58,7 +58,7 @@ 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 # 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 +Patch03: osbuilder-0003-rootfs-Don-t-overwrite-init-if-it-already-exists.patch # Force mount_dir to be created in $TMPDIR # https://github.com/kata-containers/osbuilder/pull/436 Patch04: osbuilder-0004-image_builder-Force-mount_dir-to-be-created-in-TMPDI.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 deleted file mode 100644 index d66b6a6..0000000 --- a/osbuilder-0002-rootfs-Don-t-overwrite-init-if-it-already-exists.patch +++ /dev/null @@ -1,50 +0,0 @@ -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 | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh -index 5a5655e..f8714ab 100755 ---- a/rootfs-builder/rootfs.sh -+++ b/rootfs-builder/rootfs.sh -@@ -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 -- # 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 -+ # we were passed a pre-populated rootfs directory -+ ln -sf ./usr/lib/systemd/systemd ./init -+ ln -sf ../../init ./lib/systemd/systemd -+ ln -sf ../init ./sbin/init -+ fi -+ # 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 diff --git a/osbuilder-0003-rootfs-Don-t-overwrite-init-if-it-already-exists.patch b/osbuilder-0003-rootfs-Don-t-overwrite-init-if-it-already-exists.patch new file mode 100644 index 0000000..d66b6a6 --- /dev/null +++ b/osbuilder-0003-rootfs-Don-t-overwrite-init-if-it-already-exists.patch @@ -0,0 +1,50 @@ +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 | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/rootfs-builder/rootfs.sh b/rootfs-builder/rootfs.sh +index 5a5655e..f8714ab 100755 +--- a/rootfs-builder/rootfs.sh ++++ b/rootfs-builder/rootfs.sh +@@ -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 +- # 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 ++ # we were passed a pre-populated rootfs directory ++ ln -sf ./usr/lib/systemd/systemd ./init ++ ln -sf ../../init ./lib/systemd/systemd ++ ln -sf ../init ./sbin/init ++ fi ++ # 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