-
Notifications
You must be signed in to change notification settings - Fork 310
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
status: Introduce tool to quickly check if we are booted as default #3134
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,13 +30,21 @@ | |
|
||
static gboolean opt_verify; | ||
static gboolean opt_skip_signatures; | ||
|
||
static GOptionEntry options[] | ||
= { { "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify, "Print the commit verification status", | ||
NULL }, | ||
{ "skip-signatures", 'S', 0, G_OPTION_ARG_NONE, &opt_skip_signatures, | ||
"Print the commit verification status", NULL }, | ||
{ NULL } }; | ||
static gboolean opt_query_booted; | ||
|
||
static GOptionEntry options[] = { | ||
{ "verify", 'V', 0, G_OPTION_ARG_NONE, &opt_verify, "Print the commit verification status", | ||
NULL }, | ||
{ "skip-signatures", 'S', 0, G_OPTION_ARG_NONE, &opt_skip_signatures, "Skip signatures in output", | ||
NULL }, | ||
{ "query-booted", 'Q', 0, G_OPTION_ARG_NONE, &opt_query_booted, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pure bikeshed, but I think this would be better named e.g. |
||
"Output the string \"default\" if the default deployment is the booted one, \"not-default\" if " | ||
"we are booted in a non-default deployment (e.g. the user interactively chose a different " | ||
"entry in the bootloader menu, or the bootloader rolled back automatically, etc.). If we are " | ||
"not in a booted OSTree system, an error is returned.", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: this is duplicating the manpage. These docstrings are usually more brief. Maybe e.g.
? |
||
NULL }, | ||
{ NULL } | ||
}; | ||
static gboolean | ||
deployment_print_status (OstreeSysroot *sysroot, OstreeRepo *repo, OstreeDeployment *deployment, | ||
gboolean is_booted, gboolean is_pending, gboolean is_rollback, | ||
|
@@ -200,7 +208,15 @@ ot_admin_builtin_status (int argc, char **argv, OstreeCommandInvocation *invocat | |
if (booted_deployment) | ||
ostree_sysroot_query_deployments_for (sysroot, NULL, &pending_deployment, &rollback_deployment); | ||
|
||
if (deployments->len == 0) | ||
if (opt_query_booted) | ||
{ | ||
if (deployments->len == 0) | ||
return glnx_throw (error, "Not in a booted OSTree system"); | ||
|
||
const gboolean is_default_booted = deployments->pdata[0] == booted_deployment; | ||
g_print ("%s\n", is_default_booted ? "default" : "not-default"); | ||
ericcurtin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
else if (deployments->len == 0) | ||
{ | ||
g_print ("No deployments.\n"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the syntax correct here?