Fix return value of generator on non-ostree systems
authorColin Walters <walters@verbum.org>
Wed, 28 Jun 2023 15:45:15 +0000 (11:45 -0400)
committerColin Walters <walters@verbum.org>
Wed, 28 Jun 2023 15:45:15 +0000 (11:45 -0400)
Commit aa72caffb540114a0e8635ab2990b9c8b0b8f9db
regressed the `ostree-system-generator` on non-ostree systems.
If there's no `ostree=` karg, we need to just exit 0.

Closes: https://github.com/ostreedev/ostree/issues/2909
Fixes: aa72caffb540114a0e8635ab2990b9c8b0b8f9db
src/switchroot/ostree-mount-util.h
src/switchroot/ostree-prepare-root.c
src/switchroot/ostree-system-generator.c

index cc3a7742b8958b401abc630750bf5cc25aade32d..7c7c6ce18a4fd9f1cd252f5269b6b537e85a1a65 100644 (file)
@@ -153,7 +153,7 @@ get_ostree_target (void)
   autofree char *ostree_cmdline = read_proc_cmdline_key ("ostree");
 
   if (!ostree_cmdline)
-    errx (EXIT_FAILURE, "No ostree= cmdline");
+    return NULL;
 
   if (strcmp (ostree_cmdline, "aboot") == 0)
     return get_aboot_root_slot ();
index be772a3f0182bc324a8bb03506e833cc7010d136..d41bdfb2744775239fe0418d73098e25adab96ba 100644 (file)
@@ -157,6 +157,8 @@ resolve_deploy_path (const char *root_mountpoint)
   struct stat stbuf;
   char *deploy_path;
   autofree char *ostree_target = get_ostree_target ();
+  if (!ostree_target)
+    errx (EXIT_FAILURE, "No ostree= cmdline");
 
   if (snprintf (destpath, sizeof (destpath), "%s/%s", root_mountpoint, ostree_target) < 0)
     err (EXIT_FAILURE, "failed to assemble ostree target path");
index 6dabba6dc3816108a8e054f54ccd791edebdf474..ecae432a1e7f9a77e2adf9b22614ff6f3d1423e7 100644 (file)
@@ -64,6 +64,8 @@ main (int argc, char *argv[])
    * is PID 1 (and so hasn't created /run/ostree-booted).
    */
   autofree char *ostree_target = get_ostree_target ();
+  if (!ostree_target)
+    exit (EXIT_SUCCESS);
 
   /* See comments in ostree-prepare-root.c for this.
    *