[ostree] admin switch: Support switching remotes as well
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] admin switch: Support switching remotes as well
- Date: Mon, 12 May 2014 21:33:40 +0000 (UTC)
commit 24e1bf2552ca46177512877cd77f5fb28ba623b4
Author: Colin Walters <walters verbum org>
Date: Mon May 12 16:57:46 2014 -0400
admin switch: Support switching remotes as well
Say I have an installation from CDROM; the remote name may be
"installmedia" or something like that. We want to allow also
switching remotes.
src/ostree/ot-admin-builtin-switch.c | 16 ++++++++++------
tests/test-admin-deploy-switch.sh | 10 +++++++++-
2 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/src/ostree/ot-admin-builtin-switch.c b/src/ostree/ot-admin-builtin-switch.c
index 292532f..ad02b90 100644
--- a/src/ostree/ot-admin-builtin-switch.c
+++ b/src/ostree/ot-admin-builtin-switch.c
@@ -44,11 +44,13 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
{
gboolean ret = FALSE;
GOptionContext *context;
- const char *new_ref = NULL;
+ const char *new_provided_refspec = NULL;
gs_unref_object OstreeRepo *repo = NULL;
gs_free char *origin_refspec = NULL;
gs_free char *origin_remote = NULL;
gs_free char *origin_ref = NULL;
+ gs_free char *new_remote = NULL;
+ gs_free char *new_ref = NULL;
gs_free char *new_refspec = NULL;
gs_free char *new_revision = NULL;
gs_unref_object GFile *deployment_path = NULL;
@@ -75,7 +77,9 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
goto out;
}
- new_ref = argv[1];
+ new_provided_refspec = argv[1];
+ if (!ostree_parse_refspec (new_provided_refspec, &new_remote, &new_ref, error))
+ goto out;
if (!ostree_sysroot_load (sysroot, cancellable, error))
goto out;
@@ -90,11 +94,11 @@ ot_admin_builtin_switch (int argc, char **argv, OstreeSysroot *sysroot, GCancell
if (!ostree_parse_refspec (origin_refspec, &origin_remote, &origin_ref, error))
goto out;
-
- if (origin_remote)
- new_refspec = g_strconcat (origin_remote, ":", new_ref, NULL);
+
+ if (!new_remote)
+ new_refspec = g_strconcat (origin_remote, ":", new_provided_refspec, NULL);
else
- new_refspec = g_strdup (new_ref);
+ new_refspec = g_strdup (new_provided_refspec);
if (strcmp (origin_refspec, new_refspec) == 0)
{
diff --git a/tests/test-admin-deploy-switch.sh b/tests/test-admin-deploy-switch.sh
index 815ca69..f791348 100644
--- a/tests/test-admin-deploy-switch.sh
+++ b/tests/test-admin-deploy-switch.sh
@@ -27,7 +27,7 @@ setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
-echo "1..2"
+echo "1..3"
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo
ostree --repo=sysroot/ostree/repo pull testos testos/buildmaster/x86_64-runtime
@@ -42,3 +42,11 @@ ostree admin --sysroot=sysroot switch --os=testos testos/buildmaster/x86_64-deve
assert_file_has_content sysroot/ostree/deploy/testos/current/usr/include/foo.h 'header'
echo "ok switch"
+
+ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false anothertestos file://$(pwd)/testos-repo
+ostree admin --sysroot=sysroot switch --os=testos anothertestos:testos/buildmaster/x86_64-devel
+# Ok this is lame, need a better shell command to extract config, or switch to gjs
+ostree admin --sysroot=sysroot status > status.txt
+assert_file_has_content status.txt anothertestos
+
+echo "ok switch remotes"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]