Skip to content

Commit

Permalink
app: Add a global -q/--quiet flag
Browse files Browse the repository at this point in the history
This replaces the need for `StandardOutput=null` in the automatic
upgrade unit, and can also be used for custom upgrade units, such
as that proposed in
coreos/fedora-coreos-docs#540
  • Loading branch information
cgwalters authored and lukewarmtemp committed Jun 7, 2023
1 parent 88064df commit b3aa1d3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
10 changes: 10 additions & 0 deletions src/app/libmain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ static RpmOstreeCommand commands[] = {
};

static gboolean opt_version;
static gboolean opt_quiet;
static gboolean opt_force_peer;
static char *opt_sysroot;
static gchar **opt_install;
static gchar **opt_uninstall;

static GOptionEntry global_entries[] = { { "version", 0, 0, G_OPTION_ARG_NONE, &opt_version,
"Print version information and exit", NULL },
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &opt_quiet,
"Avoid printing most informational messages", NULL },
{ NULL } };

static GOptionEntry daemon_entries[]
Expand Down Expand Up @@ -211,6 +214,13 @@ client_throw_non_ostree_host_error (GError **error)

} /* namespace */

// Returns TRUE if the global quiet flag was specified
bool
rpmostree_global_quiet (void)
{
return opt_quiet;
}

gboolean
rpmostree_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries,
int *argc, char ***argv, RpmOstreeCommandInvocation *invocation,
Expand Down
2 changes: 2 additions & 0 deletions src/app/rpmostree-builtins.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ BUILTINPROTO (initramfs_etc);

#undef BUILTINPROTO

bool rpmostree_global_quiet (void);

gboolean rpmostree_option_context_parse (GOptionContext *context, const GOptionEntry *main_entries,
int *argc, char ***argv,
RpmOstreeCommandInvocation *invocation,
Expand Down
42 changes: 24 additions & 18 deletions src/app/rpmostree-clientlib.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,30 @@ on_transaction_progress (GDBusProxy *proxy, gchar *sender_name, gchar *signal_na

g_debug ("txn progress %s", signal_name);

if (g_strcmp0 (signal_name, "Finished") == 0)
{
if (tp->error == NULL)
{
g_autofree char *error_message = NULL;
gboolean success = FALSE;

g_variant_get (parameters, "(bs)", &success, &error_message);

if (!success)
{
tp->error = g_dbus_error_new_for_dbus_error (
"org.projectatomic.rpmostreed.Error.Failed", error_message);
}
}

transaction_progress_end (tp);
return;
}

// Everything else below here is just printing progress, which we suppress in quiet mode
if (rpmostree_global_quiet ())
return;

if (g_strcmp0 (signal_name, "SignatureProgress") == 0)
{
/* We used to print the signature here, but doing so interferes with the
Expand Down Expand Up @@ -390,24 +414,6 @@ on_transaction_progress (GDBusProxy *proxy, gchar *sender_name, gchar *signal_na
else
rpmostreecxx::console_progress_set_message (line.c_str ());
}
else if (g_strcmp0 (signal_name, "Finished") == 0)
{
if (tp->error == NULL)
{
g_autofree char *error_message = NULL;
gboolean success = FALSE;

g_variant_get (parameters, "(bs)", &success, &error_message);

if (!success)
{
tp->error = g_dbus_error_new_for_dbus_error (
"org.projectatomic.rpmostreed.Error.Failed", error_message);
}
}

transaction_progress_end (tp);
}
}

static void
Expand Down
3 changes: 1 addition & 2 deletions src/daemon/rpm-ostreed-automatic.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@ ConditionPathExists=/run/ostree-booted

[Service]
Type=simple
ExecStart=rpm-ostree upgrade --trigger-automatic-update-policy
StandardOutput=null
ExecStart=rpm-ostree upgrade --quiet --trigger-automatic-update-policy

0 comments on commit b3aa1d3

Please sign in to comment.