mirror of
https://github.com/ostreedev/ostree.git
synced 2025-01-25 10:04:14 +03:00
pull: Support --mirror option
There's several use cases for calling into ostree itself to do mirroring, instead of using bare rsync. For example, it's a bit more efficient as it doesn't require syncing the objects/ directory. https://bugzilla.gnome.org/show_bug.cgi?id=728351
This commit is contained in:
parent
4ac27caefd
commit
6a5e66b152
@ -1262,8 +1262,8 @@ ostree_repo_pull (OstreeRepo *self,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ostree_repo_transaction_set_ref (pull_data->repo, pull_data->remote_name, ref, checksum);
|
gboolean is_mirror = (pull_data->flags & OSTREE_REPO_PULL_FLAGS_MIRROR) > 0;
|
||||||
|
ostree_repo_transaction_set_ref (pull_data->repo, is_mirror ? NULL : pull_data->remote_name, ref, checksum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,9 +510,11 @@ gboolean ostree_repo_prune (OstreeRepo *self,
|
|||||||
/**
|
/**
|
||||||
* OstreeRepoPullFlags:
|
* OstreeRepoPullFlags:
|
||||||
* @OSTREE_REPO_PULL_FLAGS_NONE: No special options for pull
|
* @OSTREE_REPO_PULL_FLAGS_NONE: No special options for pull
|
||||||
|
* @OSTREE_REPO_PULL_FLAGS_MIRROR: Write out refs suitable for mirrors
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSTREE_REPO_PULL_FLAGS_NONE
|
OSTREE_REPO_PULL_FLAGS_NONE,
|
||||||
|
OSTREE_REPO_PULL_FLAGS_MIRROR
|
||||||
} OstreeRepoPullFlags;
|
} OstreeRepoPullFlags;
|
||||||
|
|
||||||
gboolean ostree_repo_pull (OstreeRepo *self,
|
gboolean ostree_repo_pull (OstreeRepo *self,
|
||||||
|
@ -28,9 +28,11 @@
|
|||||||
#include "otutil.h"
|
#include "otutil.h"
|
||||||
|
|
||||||
static gboolean opt_disable_fsync;
|
static gboolean opt_disable_fsync;
|
||||||
|
static gboolean opt_mirror;
|
||||||
|
|
||||||
static GOptionEntry options[] = {
|
static GOptionEntry options[] = {
|
||||||
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
|
{ "disable-fsync", 0, 0, G_OPTION_ARG_NONE, &opt_disable_fsync, "Do not invoke fsync()", NULL },
|
||||||
|
{ "mirror", 0, 0, G_OPTION_ARG_NONE, &opt_mirror, "Write refs suitable for a mirror", NULL },
|
||||||
{ NULL }
|
{ NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -60,6 +62,9 @@ ostree_builtin_pull (int argc, char **argv, OstreeRepo *repo, GCancellable *canc
|
|||||||
if (opt_disable_fsync)
|
if (opt_disable_fsync)
|
||||||
ostree_repo_set_disable_fsync (repo, TRUE);
|
ostree_repo_set_disable_fsync (repo, TRUE);
|
||||||
|
|
||||||
|
if (opt_mirror)
|
||||||
|
pullflags |= OSTREE_REPO_PULL_FLAGS_MIRROR;
|
||||||
|
|
||||||
if (strchr (argv[1], ':') == NULL)
|
if (strchr (argv[1], ':') == NULL)
|
||||||
{
|
{
|
||||||
remote = g_strdup (argv[1]);
|
remote = g_strdup (argv[1]);
|
||||||
|
@ -36,6 +36,15 @@ assert_file_has_content firstfile '^first$'
|
|||||||
assert_file_has_content baz/cow '^moo$'
|
assert_file_has_content baz/cow '^moo$'
|
||||||
echo "ok pull contents"
|
echo "ok pull contents"
|
||||||
|
|
||||||
|
cd ${test_tmpdir}
|
||||||
|
mkdir mirrorrepo
|
||||||
|
ostree --repo=mirrorrepo init --mode=archive-z2
|
||||||
|
${CMD_PREFIX} ostree --repo=mirrorrepo remote add --set=gpg-verify=false origin $(cat httpd-address)/ostree/gnomerepo
|
||||||
|
${CMD_PREFIX} ostree --repo=mirrorrepo pull --mirror origin main
|
||||||
|
${CMD_PREFIX} ostree --repo=mirrorrepo fsck
|
||||||
|
$OSTREE show main >/dev/null
|
||||||
|
echo "ok pull mirror"
|
||||||
|
|
||||||
cd ${test_tmpdir}
|
cd ${test_tmpdir}
|
||||||
ostree --repo=ostree-srv/gnomerepo commit -b main -s "Metadata string" --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=main
|
ostree --repo=ostree-srv/gnomerepo commit -b main -s "Metadata string" --add-detached-metadata-string=SIGNATURE=HANCOCK --tree=ref=main
|
||||||
${CMD_PREFIX} ostree --repo=repo pull origin main
|
${CMD_PREFIX} ostree --repo=repo pull origin main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user