diff options
author | Alex Kiernan <alex.kiernan@hivehome.com> | 2018-07-07 21:35:35 +0000 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-09 00:11:31 +0000 |
commit | 11eb0bd227ffa1a3300e4dbde3da288a7d9d41ae (patch) | |
tree | 9f43280324a9db3db956e8c9173665022b8a5ff6 /src/switchroot/ostree-system-generator.c | |
parent | d6327f9dd9c4c787a5df46b339c1b0e045ec8134 (diff) | |
download | ostree-11eb0bd227ffa1a3300e4dbde3da288a7d9d41ae.tar.gz |
switchroot: Move late /run/ostree-booted creation to ostree-system-generator
When ostree-prepare-root is pid 1, ostree-prepare-boot defers creation of
/run/ostree-booted, which happens in ostree-remount, but that's too late
if we need ostree-system-generator to bind /var. Add the creation of the
/run/ostree-booted marker to ostree-system-generator based on the
existence of the ostree= kernel command line argument (which matches the
condition that ostree-remount uses).
Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
Closes: #1675
Approved by: cgwalters
Diffstat (limited to 'src/switchroot/ostree-system-generator.c')
-rw-r--r-- | src/switchroot/ostree-system-generator.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/switchroot/ostree-system-generator.c b/src/switchroot/ostree-system-generator.c index 799a3104..78bca7c4 100644 --- a/src/switchroot/ostree-system-generator.c +++ b/src/switchroot/ostree-system-generator.c @@ -41,14 +41,6 @@ static const char *arg_dest_late = "/tmp"; int main(int argc, char *argv[]) { - /* Important: if this isn't an ostree-booted system, do nothing; people could - * have the package installed as a dependency for flatpak or whatever. - */ - { struct stat stbuf; - if (fstatat (AT_FDCWD, "/run/ostree-booted", &stbuf, 0) < 0) - exit (EXIT_SUCCESS); - } - /* We conflict with the magic ostree-mount-deployment-var file for ostree-prepare-root */ { struct stat stbuf; if (fstatat (AT_FDCWD, INITRAMFS_MOUNT_VAR, &stbuf, 0) == 0) @@ -67,9 +59,22 @@ main(int argc, char *argv[]) if (argc > 3) arg_dest_late = argv[3]; + /* If we're installed on a system which isn't using OSTree for boot (e.g. + * package installed as a dependency for flatpak or whatever), silently + * exit so that we don't error, but at the same time work where switchroot + * is PID 1 (and so hasn't created /run/ostree-booted). + */ char *ostree_cmdline = read_proc_cmdline_ostree (); if (!ostree_cmdline) - errx (EXIT_FAILURE, "Failed to find ostree= kernel argument"); + exit (EXIT_SUCCESS); + + /* See comments in ostree-prepare-root.c for this. + * + * It's a lot easier for various bits of userspace to check for + * a file versus parsing the kernel cmdline. So let's ensure + * the stamp file is created here too. + */ + touch_run_ostree (); { g_autoptr(GError) local_error = NULL; if (!ostree_cmd__private__()->ostree_system_generator (ostree_cmdline, arg_dest, NULL, arg_dest_late, &local_error)) |