switchroot: Move late /run/ostree-booted creation to ostree-system-generator
authorAlex Kiernan <alex.kiernan@hivehome.com>
Sat, 7 Jul 2018 21:35:35 +0000 (21:35 +0000)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 9 Jul 2018 00:11:31 +0000 (00:11 +0000)
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

src/switchroot/ostree-prepare-root.c
src/switchroot/ostree-remount.c
src/switchroot/ostree-system-generator.c

index 0131d24658e97df4ab3acf1a0eeda7586fda52bd..01a8556955f4938ce85e7dd05e2c24f116c3c3ee 100644 (file)
@@ -210,8 +210,9 @@ main(int argc, char *argv[])
 
 
   /* We only stamp /run now if we're running in an initramfs, i.e. we're
-   * not pid 1.  Otherwise it's handled later via ostree-remount.service.
+   * not pid 1.  Otherwise it's handled later via ostree-system-generator.
    * https://mail.gnome.org/archives/ostree-list/2018-March/msg00012.html
+   * https://github.com/ostreedev/ostree/pull/1675
    */
   if (!running_as_pid1)
     touch_run_ostree ();
index cd09fc156ca4be821cd391e6cc178abe8dab84de..71b7b3954b2381918028fa4e158bfa30bb440d17 100644 (file)
@@ -46,13 +46,8 @@ main(int argc, char *argv[])
   struct stat stbuf;
   int i;
 
-  /* See comments in ostree-prepare-root.c for this.
-   *
-   * This service is triggered via
-   * ConditionKernelCommandLine=ostree
-   * but 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.
+  /* When systemd is in use this is normally created via the generator, but
+   * we ensure it's created here as well for redundancy.
    */
   touch_run_ostree ();
 
index 799a3104b91f2464d067831af74da2d4299dd226..78bca7c49e5be8d215098ae366dd2cc7e71804d8 100644 (file)
@@ -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))