From 23badcd2884ae07c657d1e63e2e52197dd12fac6 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 31 Jul 2018 16:00:55 -0400 Subject: [PATCH] compose: Write a preset file to enable ostree-remount.service I've lost count now of how many times people have hit variants of https://github.com/projectatomic/centos-release-atomic-host-devel/pull/6 Let's just bake it in. Closes: #1482 Approved by: jlebon --- src/libpriv/rpmostree-postprocess.c | 16 ++++++++++++++++ tests/compose-tests/test-basic.sh | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index 3d1af93e..4b13b225 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -992,6 +992,22 @@ rpmostree_postprocess_final (int rootfs_dfd, return glnx_prefix_error (error, "SELinux postprocess"); } + /* We keep hitting issues with the ostree-remount preset not being + * enabled; let's just do this rather than trying to propagate the + * preset everywhere. + */ + static const char preset_dir[] = "usr/lib/systemd/system-preset"; + if (!glnx_shutil_mkdir_p_at (rootfs_dfd, preset_dir, 0755, cancellable, error)) + return FALSE; + { g_autofree char *preset_path = g_build_filename (preset_dir, "40-rpm-ostree-auto.preset", NULL); + static const char remount_preset[] = "# Written by rpm-ostree compose tree\nenable ostree-remount.service\n"; + if (!glnx_file_replace_contents_at (rootfs_dfd, preset_path, (guint8*)remount_preset, + strlen (remount_preset), + GLNX_FILE_REPLACE_NODATASYNC, + cancellable, error)) + return FALSE; + } + if (!convert_var_to_tmpfiles_d (rootfs_dfd, cancellable, error)) return FALSE; diff --git a/tests/compose-tests/test-basic.sh b/tests/compose-tests/test-basic.sh index 402a59d2..45e5d56e 100755 --- a/tests/compose-tests/test-basic.sh +++ b/tests/compose-tests/test-basic.sh @@ -30,6 +30,9 @@ assert_file_has_content_literal autovar.txt 'd /var/cache 0755 root root - -' assert_file_has_content_literal autovar.txt 'd /var/log/chrony 0755 chrony chrony - -' echo "ok autovar" +ostree --repo=${repobuild} cat ${treeref} /usr/lib/systemd/system-preset/40-rpm-ostree-auto.preset > preset.txt +assert_file_has_content preset.txt '^enable ostree-remount.service$' + if ! rpm-ostree --version | grep -q rust; then echo "ok yaml (SKIP)" else