Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app: Add a global -q/--quiet flag #4384

Merged
merged 1 commit into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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