Skip to content

Commit

Permalink
Merge pull request #3290 from cgwalters/include-grub-stderr
Browse files Browse the repository at this point in the history
grub2: Show output when run in systemd by default
  • Loading branch information
ericcurtin authored Sep 3, 2024
2 parents 4207d92 + cdbe93d commit fbb1cc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/libostree/ostree-bootloader-grub2.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#include "otutil.h"
#include <gio/gfiledescriptorbased.h>
#include <gio/gunixoutputstream.h>
#include <sys/mount.h>

#include <stdbool.h>
#include <string.h>
#include <sys/mount.h>

// Written by bootupd
#define BOOTUPD_CONFIG "boot/bootupd-state.json"
Expand Down Expand Up @@ -419,7 +419,15 @@ _ostree_bootloader_grub2_write_config (OstreeBootloader *bootloader, int bootver
grub_argv[2] = gs_file_get_path_cached (new_config_path);

GSpawnFlags grub_spawnflags = G_SPAWN_SEARCH_PATH;
if (!g_getenv ("OSTREE_DEBUG_GRUB2"))
const bool running_in_systemd = getenv ("INVOCATION_ID") != NULL;
const bool debug_grub2 = g_getenv ("OSTREE_DEBUG_GRUB2");
/* If we're running in systemd (as part of `ostree-finalize-staged.service`)
* then we do want to gather output from the binary so that if something fails
* we can debug it.
*
* We also have an opt-in variable to display errors.
*/
if (!(running_in_systemd || debug_grub2))
grub_spawnflags |= G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL;
cdata.root = grub2_mkconfig_chroot;
g_autofree char *bootversion_str = g_strdup_printf ("%u", (guint)bootversion);
Expand Down
3 changes: 2 additions & 1 deletion src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ _try_clone_from_payload_link (OstreeRepo *self, OstreeRepo *dest_repo, const cha
loose_path_buf, (unsigned long long)expected_len,
(unsigned long long)size);

snprintf (target_checksum, sizeof (target_checksum), "%.2s%.62s", target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN,
snprintf (target_checksum, sizeof (target_checksum), "%.2s%.62s",
target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN,
target_buf + _OSTREE_PAYLOAD_LINK_PREFIX_LEN + 3);

_ostree_loose_path (loose_path_target_buf, target_checksum, OSTREE_OBJECT_TYPE_FILE,
Expand Down

0 comments on commit fbb1cc7

Please sign in to comment.