mirror of
https://github.com/ostreedev/ostree.git
synced 2024-12-22 17:35:55 +03:00
upgrade: Add --override-commit=CHECKSUM option
Adds an entry to the origin file to force the OstreeSysrootUpgrader to pull and deploy the given checksum. [origin] override-commit=CHECKSUM If the option is not given, any such entry is explicitly removed from the origin file to ensure we upgrade to the latest available commit.
This commit is contained in:
parent
39b732ffaa
commit
2210a79bfa
@ -88,6 +88,14 @@ Boston, MA 02111-1307, USA.
|
||||
Permit deployment of chronologically older trees.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--override-commit</option>="CHECKSUM"</term>
|
||||
|
||||
<listitem><para>
|
||||
Deploy CHECKSUM instead of the latest tree.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@ -35,11 +35,13 @@
|
||||
static gboolean opt_reboot;
|
||||
static gboolean opt_allow_downgrade;
|
||||
static char *opt_osname;
|
||||
static char *opt_override_commit;
|
||||
|
||||
static GOptionEntry options[] = {
|
||||
{ "os", 0, 0, G_OPTION_ARG_STRING, &opt_osname, "Use a different operating system root than the current one", "OSNAME" },
|
||||
{ "reboot", 'r', 0, G_OPTION_ARG_NONE, &opt_reboot, "Reboot after a successful upgrade", NULL },
|
||||
{ "allow-downgrade", 0, 0, G_OPTION_ARG_NONE, &opt_allow_downgrade, "Permit deployment of chronologically older trees", NULL },
|
||||
{ "override-commit", 0, 0, G_OPTION_ARG_STRING, &opt_override_commit, "Deploy CHECKSUM instead of the latest tree", "CHECKSUM" },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
@ -52,6 +54,7 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr
|
||||
glnx_unref_object OstreeSysrootUpgrader *upgrader = NULL;
|
||||
g_autoptr(GFile) deployment_path = NULL;
|
||||
g_autoptr(GFile) deployment_origin_path = NULL;
|
||||
g_autoptr(GKeyFile) origin = NULL;
|
||||
GSConsole *console = NULL;
|
||||
gboolean in_status_line = FALSE;
|
||||
glnx_unref_object OstreeAsyncProgress *progress = NULL;
|
||||
@ -73,6 +76,35 @@ ot_admin_builtin_upgrade (int argc, char **argv, GCancellable *cancellable, GErr
|
||||
if (!upgrader)
|
||||
goto out;
|
||||
|
||||
origin = ostree_sysroot_upgrader_dup_origin (upgrader);
|
||||
if (origin != NULL)
|
||||
{
|
||||
gboolean origin_changed = FALSE;
|
||||
|
||||
if (opt_override_commit != NULL)
|
||||
{
|
||||
/* Override the commit to pull and deploy. */
|
||||
g_key_file_set_string (origin, "origin",
|
||||
"override-commit",
|
||||
opt_override_commit);
|
||||
origin_changed = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Strip any override-commit from the origin file so
|
||||
* we always upgrade to the latest available commit. */
|
||||
origin_changed = g_key_file_remove_key (origin, "origin",
|
||||
"override-commit", NULL);
|
||||
}
|
||||
|
||||
if (origin_changed)
|
||||
{
|
||||
/* XXX GCancellable parameter is not used. */
|
||||
if (!ostree_sysroot_upgrader_set_origin (upgrader, origin, NULL, error))
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
console = gs_console_get ();
|
||||
if (console)
|
||||
{
|
||||
|
@ -203,3 +203,18 @@ assert_file_has_content sysroot/boot/loader/entries/ostree-testos-0.conf 'consol
|
||||
validate_bootloader
|
||||
|
||||
echo "ok upgrade with multiple kernel args"
|
||||
|
||||
# Test upgrade with and without --override-commit
|
||||
# See https://github.com/GNOME/ostree/pull/147
|
||||
${CMD_PREFIX} ostree pull --repo=sysroot/ostree/repo --commit-metadata-only --depth=-1 testos:testos/buildmaster/x86_64-runtime
|
||||
head_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buildmaster/x86_64-runtime)
|
||||
prev_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buildmaster/x86_64-runtime^^^^)
|
||||
assert_not_streq ${head_rev} ${prev_rev}
|
||||
${CMD_PREFIX} ostree admin upgrade --os=testos --override-commit=${prev_rev} --allow-downgrade
|
||||
curr_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buildmaster/x86_64-runtime)
|
||||
assert_streq ${curr_rev} ${prev_rev}
|
||||
${CMD_PREFIX} ostree admin upgrade --os=testos
|
||||
curr_rev=$(${CMD_PREFIX} ostree rev-parse --repo=sysroot/ostree/repo testos/buildmaster/x86_64-runtime)
|
||||
assert_streq ${curr_rev} ${head_rev}
|
||||
|
||||
echo "ok upgrade with and without override-commit"
|
||||
|
Loading…
Reference in New Issue
Block a user