Skip to content

Commit 5590da4

Browse files
committed
build_image_util: Store path list for recreating tmpfiles rules
The removal of files in the overlay present in the lowerdir creates whiteout entries that mask the lowerdir entries. For those files that have a tmpfile rule for creation, a reboot would cause the file to be created in the upperdir, meaning this file is not updated from the lowerdir when it changes. In addition we have filtered out some tmpfile rules that caused upcopies (symlinks and directories) which meant that removing the /etc/resolv.conf symlink didn't bring it back after reboot. To make files from the lowerdir show up if they have a tmpfile rule that normally would recreate them we keep a list of whiteout entries that we clean up on boot. This also prevents freezing files because systemd-tmpfiles does not need to recreate them in the upperdir.
1 parent 319c950 commit 5590da4

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

build_library/build_image_util.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,16 @@ EOF
737737
done
738738
sudo "${root_fs_dir}"/usr/sbin/flatcar-tmpfiles "${root_fs_dir}"
739739
# Now that we used the tmpfiles for creating /etc we delete them because
740-
# the L, d, and C entries cause upcopies. Also filter out rules with ! or - but no other modifiers
740+
# the L, d, D, and C entries cause upcopies. Also filter out rules with ! or - but no other modifiers
741741
# like + or = which explicitly recreate files.
742-
sudo sed -i '/^[CLd]-*!*-*[ \t]*\/etc\//d' "${root_fs_dir}"/usr/lib/tmpfiles.d/*
742+
# But before filtering, first store rules that would recreate missing files
743+
# to /usr/share/flatcar/etc-no-whiteouts so that we can ensure that
744+
# no overlayfs whiteouts exist for these files (example: /etc/resolv.conf).
745+
# These rules are combined with the + modifier in addition.
746+
# Other rules like w, e, x, do not create files that don't exist.
747+
# Note: '-' must come first in the modifier pattern.
748+
grep -Ph '^[fcCdDLvqQpb][-=~^!+]*[ \t]*/etc' "${root_fs_dir}"/usr/lib/tmpfiles.d/* | grep -oP '/etc[^ \t]*' | sudo_clobber "${root_fs_dir}"/usr/share/flatcar/etc-no-whiteouts
749+
sudo sed -i '/^[CdDL][-=~^!]*[ \t]*\/etc\//d' "${root_fs_dir}"/usr/lib/tmpfiles.d/*
743750

744751
# SELinux: Label the root filesystem for using 'file_contexts'.
745752
# The labeling has to be done before moving /etc to /usr/share/flatcar/etc to prevent wrong labels for these files and as
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Deleted files in `/etc` that have a tmpfiles rule that normally would recreate them will now show up again through the `/etc` lowerdir ([Flatcar#1265](https://github.com/flatcar/Flatcar/issues/1265), [bootengine#79](https://github.com/flatcar/bootengine/pull/79))

sdk_container/src/third_party/coreos-overlay/sys-kernel/bootengine/bootengine-9999.ebuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ CROS_WORKON_REPO="https://github.com"
1010
if [[ "${PV}" == 9999 ]]; then
1111
KEYWORDS="~amd64 ~arm ~arm64 ~x86"
1212
else
13-
CROS_WORKON_COMMIT="10cea163fa12a5686e367041bc9254b30461f261" # flatcar-master
13+
CROS_WORKON_COMMIT="31d24b87717e6ee3b2970af5926a481d6bbff933" # flatcar-master
1414
KEYWORDS="amd64 arm arm64 x86"
1515
fi
1616

0 commit comments

Comments
 (0)