summaryrefslogtreecommitdiff
path: root/src/ostree/ot-builtin-create-usb.c
diff options
context:
space:
mode:
authorMatthew Leeds <matthew.leeds@endlessm.com>2018-09-24 13:57:42 -0700
committerAtomic Bot <atomic-devel@projectatomic.io>2018-09-25 15:47:25 +0000
commit9a06c5409ec551a56fa1ad137efcd1f2d7044496 (patch)
tree759664c3ee9e0579cf4ab40d04629bd1aed7de4f /src/ostree/ot-builtin-create-usb.c
parentc141fe610b652f383a9c445169d3cc6f28f99bd1 (diff)
downloadostree-9a06c5409ec551a56fa1ad137efcd1f2d7044496.tar.gz
create-usb: Add a --commit option
Currently on Endless OS, the OSTree ref for the operating system is something like os/eos/amd64/eos3, so that's what gets passed to `ostree create-usb` when copying the OS to a USB drive (for offline updates). However, when eos-updater checks for updates it pulls the metadata for a candidate commit and in so doing updates that eos3 ref to point to the partial commit being examined as a potential update rather than the deployed commit. This causes `ostree create-usb` to fail with an error like "No such metadata object 7fb045cb2d1f1f3a81bfc157c6128ff443eb56350315b9536bdb56aee0659863.dirtree". OSTree creates deployment refs that look like "ostree/1/1/0" to maintain a pointer to the deployed commit, but create-usb can't use these because it shows up in the summary as just a ref, not a collection-ref. So this commit adds a --commit option to the create-usb command, so we can use the appropriate ref but copy the deployed commit rather than a (potentially partial) update commit. Closes: #1735 Approved by: cgwalters
Diffstat (limited to 'src/ostree/ot-builtin-create-usb.c')
-rw-r--r--src/ostree/ot-builtin-create-usb.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/ostree/ot-builtin-create-usb.c b/src/ostree/ot-builtin-create-usb.c
index 4230d7d1..849684f6 100644
--- a/src/ostree/ot-builtin-create-usb.c
+++ b/src/ostree/ot-builtin-create-usb.c
@@ -33,11 +33,13 @@
static gboolean opt_disable_fsync = FALSE;
static char *opt_destination_repo = NULL;
+static char *opt_commit = NULL;
static GOptionEntry options[] =
{
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
{ "destination-repo", 0, 0, G_OPTION_ARG_FILENAME, &opt_destination_repo, "Use custom repository directory within the mount", "DEST" },
+ { "commit", 0, 0, G_OPTION_ARG_STRING, &opt_commit, "Pull a specific commit (only works when a single ref is specified)", "COMMIT" },
{ NULL }
};
@@ -78,6 +80,12 @@ ostree_builtin_create_usb (int argc,
return FALSE;
}
+ if (opt_commit && argc > 4)
+ {
+ ot_util_usage_error (context, "The --commit option can only be used when a single COLLECTION-ID REF pair is specified", error);
+ return FALSE;
+ }
+
/* Open the USB stick, which must exist. Allow automounting and following symlinks. */
const char *mount_root_path = argv[1];
struct stat mount_root_stbuf;
@@ -154,7 +162,7 @@ ostree_builtin_create_usb (int argc,
const OstreeCollectionRef *ref = g_ptr_array_index (refs, i);
g_variant_builder_add (&refs_builder, "(sss)",
- ref->collection_id, ref->ref_name, "");
+ ref->collection_id, ref->ref_name, opt_commit ?: "");
}
{