ostree export: Add --prefix option

This lets you set a prefix for the resulting archive patsh.
Especially useful in combination with --subpath, for instance
--subpath=subdir --prefix=subdir to extract just subdir.

Closes: #265
Approved by: cgwalters
This commit is contained in:
Alexander Larsson authored and Colin Walters (automation) committed 2016-04-19 12:28:06 +00:00
1 parent 5079f70ec0
commit 5595664e47
4 files changed
+35 -3

No files matched your search

+6
View File
@@ -480,6 +480,12 @@ file_to_archive_entry_common (GFile *root,
g_autoptr(GVariant) xattrs = NULL;
time_t ts = (time_t) opts->timestamp_secs;
if (opts->path_prefix && opts->path_prefix[0])
{
g_autofree char *old_pathstr = pathstr;
pathstr = g_strconcat (opts->path_prefix, old_pathstr, NULL);
}
if (pathstr == NULL || !pathstr[0])
{
g_free (pathstr);
+4 -1
View File
@@ -610,7 +610,10 @@ typedef struct {
guint64 timestamp_secs;
guint unused_uint[8];
gpointer unused_ptrs[8];
char *path_prefix;
gpointer unused_ptrs[7];
} OstreeRepoExportArchiveOptions;
_OSTREE_PUBLIC
+4
View File
@@ -33,11 +33,13 @@
static char *opt_output_path;
static char *opt_subpath;
static char *opt_prefix;
static gboolean opt_no_xattrs;
static GOptionEntry options[] = {
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Skip output of extended attributes", NULL },
{ "subpath", 0, 0, G_OPTION_ARG_STRING, &opt_subpath, "Checkout sub-directory PATH", "PATH" },
{ "prefix", 0, 0, G_OPTION_ARG_STRING, &opt_prefix, "Add PATH as prefix to archive pathnames", "PATH" },
{ "output", 'o', 0, G_OPTION_ARG_STRING, &opt_output_path, "Output to PATH ", "PATH" },
{ NULL }
};
@@ -132,6 +134,8 @@ ostree_builtin_export (int argc, char **argv, GCancellable *cancellable, GError
else
subtree = g_object_ref (root);
opts.path_prefix = opt_prefix;
if (!ostree_repo_export_tree_to_archive (repo, &opts, (OstreeRepoFile*)subtree, a,
cancellable, error))
goto out;