diff options
Diffstat (limited to 'src/ostree/ot-admin-builtin-deploy.c')
-rw-r--r-- | src/ostree/ot-admin-builtin-deploy.c | 114 |
1 files changed, 65 insertions, 49 deletions
diff --git a/src/ostree/ot-admin-builtin-deploy.c b/src/ostree/ot-admin-builtin-deploy.c index 28a5d9e8..00204ffd 100644 --- a/src/ostree/ot-admin-builtin-deploy.c +++ b/src/ostree/ot-admin-builtin-deploy.c @@ -23,10 +23,10 @@ #include "ostree-sysroot-private.h" -#include "ot-main.h" +#include "ostree.h" #include "ot-admin-builtins.h" #include "ot-admin-functions.h" -#include "ostree.h" +#include "ot-main.h" #include "otutil.h" #include <glib/gi18n.h> @@ -49,35 +49,51 @@ static gboolean opt_kernel_arg_none; static char **opt_overlay_initrds; static GOptionEntry options[] = { - { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" }, - { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file", "FILENAME" }, - { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL}, - { "no-merge", 0, 0, G_OPTION_ARG_NONE, &opt_no_merge, "Do not apply configuration (/etc and kernel arguments) from booted deployment", NULL}, + { "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, + "Use a different operating system root than the current one", "OSNAME" }, + { "origin-file", 0, 0, G_OPTION_ARG_FILENAME, &opt_origin_path, "Specify origin file", + "FILENAME" }, + { "no-prune", 0, 0, G_OPTION_ARG_NONE, &opt_no_prune, "Don't prune the repo when done", NULL }, + { "no-merge", 0, 0, G_OPTION_ARG_NONE, &opt_no_merge, + "Do not apply configuration (/etc and kernel arguments) from booted deployment", NULL }, { "retain", 0, 0, G_OPTION_ARG_NONE, &opt_retain, "Do not delete previous deployments", NULL }, { "stage", 0, 0, G_OPTION_ARG_NONE, &opt_stage, "Complete deployment at OS shutdown", NULL }, - { "lock-finalization", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_lock_finalization, "Prevent automatic deployment finalization on shutdown", NULL }, - { "retain-pending", 0, 0, G_OPTION_ARG_NONE, &opt_retain_pending, "Do not delete pending deployments", NULL }, - { "retain-rollback", 0, 0, G_OPTION_ARG_NONE, &opt_retain_rollback, "Do not delete rollback deployments", NULL }, - { "not-as-default", 0, 0, G_OPTION_ARG_NONE, &opt_not_as_default, "Append rather than prepend new deployment", NULL }, - { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline, "Import current /proc/cmdline", NULL }, - { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv, "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same name", "NAME=VALUE" }, - { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append, "Append kernel argument; useful with e.g. console= that can be used multiple times", "NAME=VALUE" }, - { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments", NULL }, - { "karg-delete", 0, 0, G_OPTION_ARG_STRING, &opt_kernel_argv_delete, "Delete kernel argument if exists", "NAME=VALUE" }, - { "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds, "Overlay iniramfs file", "FILE" }, + { "lock-finalization", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &opt_lock_finalization, + "Prevent automatic deployment finalization on shutdown", NULL }, + { "retain-pending", 0, 0, G_OPTION_ARG_NONE, &opt_retain_pending, + "Do not delete pending deployments", NULL }, + { "retain-rollback", 0, 0, G_OPTION_ARG_NONE, &opt_retain_rollback, + "Do not delete rollback deployments", NULL }, + { "not-as-default", 0, 0, G_OPTION_ARG_NONE, &opt_not_as_default, + "Append rather than prepend new deployment", NULL }, + { "karg-proc-cmdline", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_proc_cmdline, + "Import current /proc/cmdline", NULL }, + { "karg", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv, + "Set kernel argument, like root=/dev/sda1; this overrides any earlier argument with the same " + "name", + "NAME=VALUE" }, + { "karg-append", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_kernel_argv_append, + "Append kernel argument; useful with e.g. console= that can be used multiple times", + "NAME=VALUE" }, + { "karg-none", 0, 0, G_OPTION_ARG_NONE, &opt_kernel_arg_none, "Do not import kernel arguments", + NULL }, + { "karg-delete", 0, 0, G_OPTION_ARG_STRING, &opt_kernel_argv_delete, + "Delete kernel argument if exists", "NAME=VALUE" }, + { "overlay-initrd", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_overlay_initrds, + "Overlay iniramfs file", "FILE" }, { NULL } }; gboolean -ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation, GCancellable *cancellable, GError **error) +ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocation, + GCancellable *cancellable, GError **error) { - g_autoptr(GOptionContext) context = - g_option_context_new ("REFSPEC"); + g_autoptr (GOptionContext) context = g_option_context_new ("REFSPEC"); - g_autoptr(OstreeSysroot) sysroot = NULL; + g_autoptr (OstreeSysroot) sysroot = NULL; if (!ostree_admin_option_context_parse (context, options, &argc, &argv, - OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, - invocation, &sysroot, cancellable, error)) + OSTREE_ADMIN_BUILTIN_FLAG_SUPERUSER, invocation, &sysroot, + cancellable, error)) return FALSE; if (argc < 2) @@ -88,7 +104,8 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat if (opt_kernel_proc_cmdline && opt_kernel_arg_none) { - ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none", error); + ot_util_usage_error (context, "Can't specify both --karg-proc-cmdline and --karg-none", + error); return FALSE; } @@ -111,11 +128,10 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat /* Find the currently booted deployment, if any; we will ensure it * is present in the new deployment list. */ - if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname, - cancellable, error)) + if (!ot_admin_require_booted_deployment_or_osname (sysroot, opt_osname, cancellable, error)) return glnx_prefix_error (error, "Looking for booted deployment"); - g_autoptr(GKeyFile) origin = NULL; + g_autoptr (GKeyFile) origin = NULL; if (opt_origin_path) { origin = g_key_file_new (); @@ -132,8 +148,8 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat if (!ostree_repo_resolve_rev (repo, refspec, FALSE, &revision, error)) return FALSE; - g_autoptr(OstreeDeployment) merge_deployment = - opt_no_merge ? NULL : ostree_sysroot_get_merge_deployment (sysroot, opt_osname); + g_autoptr (OstreeDeployment) merge_deployment + = opt_no_merge ? NULL : ostree_sysroot_get_merge_deployment (sysroot, opt_osname); /* Here we perform cleanup of any leftover data from previous * partial failures. This avoids having to call @@ -148,7 +164,7 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat /* Initial set of kernel arguments; the default is to use the merge * deployment, unless --karg-none or --karg-proc-cmdline are specified. */ - g_autoptr(OstreeKernelArgs) kargs = NULL; + g_autoptr (OstreeKernelArgs) kargs = NULL; if (opt_kernel_arg_none) { kargs = ostree_kernel_args_new (); @@ -159,10 +175,12 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat if (!ostree_kernel_args_append_proc_cmdline (kargs, cancellable, error)) return FALSE; } - else if (merge_deployment && (opt_kernel_argv || opt_kernel_argv_append || opt_kernel_argv_delete)) + else if (merge_deployment + && (opt_kernel_argv || opt_kernel_argv_append || opt_kernel_argv_delete)) { OstreeBootconfigParser *bootconfig = ostree_deployment_get_bootconfig (merge_deployment); - g_auto(GStrv) previous_args = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1); + g_auto (GStrv) previous_args + = g_strsplit (ostree_bootconfig_parser_get (bootconfig, "options"), " ", -1); kargs = ostree_kernel_args_new (); ostree_kernel_args_append_argv (kargs, previous_args); } @@ -191,7 +209,7 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat return FALSE; } - g_autoptr(GPtrArray) overlay_initrd_chksums = NULL; + g_autoptr (GPtrArray) overlay_initrd_chksums = NULL; for (char **it = opt_overlay_initrds; it && *it; it++) { const char *path = *it; @@ -212,14 +230,14 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat if (overlay_initrd_chksums) g_ptr_array_add (overlay_initrd_chksums, NULL); - g_auto(GStrv) kargs_strv = kargs ? ostree_kernel_args_to_strv (kargs) : NULL; + g_auto (GStrv) kargs_strv = kargs ? ostree_kernel_args_to_strv (kargs) : NULL; OstreeSysrootDeployTreeOpts opts = { .override_kernel_argv = kargs_strv, - .overlay_initrds = overlay_initrd_chksums ? (char**)overlay_initrd_chksums->pdata : NULL, + .overlay_initrds = overlay_initrd_chksums ? (char **)overlay_initrd_chksums->pdata : NULL, }; - g_autoptr(OstreeDeployment) new_deployment = NULL; + g_autoptr (OstreeDeployment) new_deployment = NULL; if (opt_stage) { if (opt_retain_pending || opt_retain_rollback) @@ -243,16 +261,15 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat /* use old API if we can to exercise it in CI */ if (!overlay_initrd_chksums) { - if (!ostree_sysroot_stage_tree (sysroot, opt_osname, revision, origin, - merge_deployment, kargs_strv, &new_deployment, - cancellable, error)) + if (!ostree_sysroot_stage_tree (sysroot, opt_osname, revision, origin, merge_deployment, + kargs_strv, &new_deployment, cancellable, error)) return FALSE; } else { - if (!ostree_sysroot_stage_tree_with_options (sysroot, opt_osname, revision, - origin, merge_deployment, &opts, - &new_deployment, cancellable, error)) + if (!ostree_sysroot_stage_tree_with_options (sysroot, opt_osname, revision, origin, + merge_deployment, &opts, &new_deployment, + cancellable, error)) return FALSE; } g_assert (new_deployment); @@ -262,22 +279,21 @@ ot_admin_builtin_deploy (int argc, char **argv, OstreeCommandInvocation *invocat /* use old API if we can to exercise it in CI */ if (!overlay_initrd_chksums) { - if (!ostree_sysroot_deploy_tree (sysroot, opt_osname, revision, origin, - merge_deployment, kargs_strv, &new_deployment, - cancellable, error)) + if (!ostree_sysroot_deploy_tree (sysroot, opt_osname, revision, origin, merge_deployment, + kargs_strv, &new_deployment, cancellable, error)) return FALSE; } else { - if (!ostree_sysroot_deploy_tree_with_options (sysroot, opt_osname, revision, - origin, merge_deployment, &opts, - &new_deployment, cancellable, - error)) + if (!ostree_sysroot_deploy_tree_with_options (sysroot, opt_osname, revision, origin, + merge_deployment, &opts, &new_deployment, + cancellable, error)) return FALSE; } g_assert (new_deployment); - OstreeSysrootSimpleWriteDeploymentFlags flags = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN; + OstreeSysrootSimpleWriteDeploymentFlags flags + = OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_NO_CLEAN; if (opt_retain) flags |= OSTREE_SYSROOT_SIMPLE_WRITE_DEPLOYMENT_FLAGS_RETAIN; else |