Skip to content

Commit

Permalink
Merge pull request #2119 from mwleeds/implement-deploy-collection-id
Browse files Browse the repository at this point in the history
Replace xa.collection-id with ostree.deploy-collection-id
  • Loading branch information
pwithnall committed Sep 21, 2018
2 parents d129175 + 48ceed7 commit 56b23fe
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
11 changes: 8 additions & 3 deletions app/flatpak-builtins-repo.c
Expand Up @@ -41,7 +41,7 @@ print_info (GVariant *meta)
const char *collection_id;
const char *default_branch;
const char *redirect_url;
const char *redirect_collection_id;
const char *deploy_collection_id;
g_autoptr(GVariant) gpg_keys = NULL;

if (g_variant_lookup (meta, "xa.title", "&s", &title))
Expand All @@ -56,8 +56,13 @@ print_info (GVariant *meta)
if (g_variant_lookup (meta, "xa.redirect-url", "&s", &redirect_url))
g_print (_("Redirect URL: %s\n"), redirect_url);

if (g_variant_lookup (meta, "xa.collection-id", "&s", &redirect_collection_id))
g_print (_("Redirect collection ID: %s\n"), redirect_collection_id);
/* FIXME: Remove this check when we depend on ostree 2018.9 */
#ifndef OSTREE_META_KEY_DEPLOY_COLLECTION_ID
#define OSTREE_META_KEY_DEPLOY_COLLECTION_ID "ostree.deploy-collection-id"
#endif

if (g_variant_lookup (meta, OSTREE_META_KEY_DEPLOY_COLLECTION_ID, "&s", &deploy_collection_id))
g_print (_("Deploy collection ID: %s\n"), deploy_collection_id);

if ((gpg_keys = g_variant_lookup_value (meta, "xa.gpg-keys", G_VARIANT_TYPE_BYTESTRING)) != NULL)
{
Expand Down
9 changes: 7 additions & 2 deletions common/flatpak-dir.c
Expand Up @@ -11502,6 +11502,11 @@ flatpak_dir_update_remote_configuration_for_state (FlatpakDir *self,
GCancellable *cancellable,
GError **error)
{
/* FIXME: Remove this check when we depend on ostree 2018.9 */
#ifndef OSTREE_META_KEY_DEPLOY_COLLECTION_ID
#define OSTREE_META_KEY_DEPLOY_COLLECTION_ID "ostree.deploy-collection-id"
#endif

/* We only support those configuration parameters that can
be set in the server when building the repo (see the
flatpak_repo_set_* () family of functions) */
Expand All @@ -11510,7 +11515,7 @@ flatpak_dir_update_remote_configuration_for_state (FlatpakDir *self,
"xa.default-branch",
"xa.gpg-keys",
"xa.redirect-url",
"xa.collection-id",
OSTREE_META_KEY_DEPLOY_COLLECTION_ID,
NULL
};

Expand Down Expand Up @@ -11553,7 +11558,7 @@ flatpak_dir_update_remote_configuration_for_state (FlatpakDir *self,
{
if (strcmp (key, "xa.redirect-url") == 0)
g_ptr_array_add (updated_params, g_strdup ("url"));
else if (strcmp (key, "xa.collection-id") == 0)
else if (strcmp (key, OSTREE_META_KEY_DEPLOY_COLLECTION_ID) == 0)
g_ptr_array_add (updated_params, g_strdup ("collection-id"));
else
g_ptr_array_add (updated_params, g_strdup (key));
Expand Down
18 changes: 12 additions & 6 deletions common/flatpak-utils.c
Expand Up @@ -2941,11 +2941,12 @@ populate_commit_data_cache (GVariant *metadata,
* but kept for backwards compatibility).
*
* Note that there are two keys for the collection ID: collection-id, and
* xa.collection-id. If a client does not currently have a collection ID configured
* for this remote, it will *only* update its configuration from xa.collection-id.
* This allows phased deployment of collection-based repositories. Clients will
* only update their configuration from an unset to a set collection ID once
* (otherwise the security properties of collection IDs are broken). */
* ostree.deploy-collection-id. If a client does not currently have a
* collection ID configured for this remote, it will *only* update its
* configuration from ostree.deploy-collection-id. This allows phased
* deployment of collection-based repositories. Clients will only update their
* configuration from an unset to a set collection ID once (otherwise the
* security properties of collection IDs are broken). */
gboolean
flatpak_repo_update (OstreeRepo *repo,
const char **gpg_key_ids,
Expand Down Expand Up @@ -3002,8 +3003,13 @@ flatpak_repo_update (OstreeRepo *repo,
g_variant_builder_add (&builder, "{sv}", "xa.default-branch",
g_variant_new_string (default_branch));

/* FIXME: Remove this check when we depend on ostree 2018.9 */
#ifndef OSTREE_META_KEY_DEPLOY_COLLECTION_ID
#define OSTREE_META_KEY_DEPLOY_COLLECTION_ID "ostree.deploy-collection-id"
#endif

if (deploy_collection_id && collection_id != NULL)
g_variant_builder_add (&builder, "{sv}", "xa.collection-id",
g_variant_builder_add (&builder, "{sv}", OSTREE_META_KEY_DEPLOY_COLLECTION_ID,
g_variant_new_string (collection_id));
else if (deploy_collection_id)
g_debug ("Ignoring deploy-collection-id=true because no collection ID is set.");
Expand Down
4 changes: 2 additions & 2 deletions tests/test-update-remote-configuration.sh
Expand Up @@ -86,10 +86,10 @@ echo "ok 2 update repo config to deploy collection ID"
#for ref in app/org.test.App/x86_64/master app/org.test.Hello/x86_64/master appstream/x86_64 ostree-metadata runtime/org.test.Platform/x86_64/master; do
# ostree --repo=repos/test refs --collections --create=org.test.Collection:$ref $ref
#done
ostree --repo=repos/test summary --update --add-metadata="xa.collection-id='net.malicious.NewCollection'"
ostree --repo=repos/test summary --update --add-metadata="ostree.deploy-collection-id='net.malicious.NewCollection'"
${FLATPAK} ${U} update org.test.App master

assert_file_has_content ${FL_DIR}/repo/config '^collection-id=org.test.Collection$'
assert_not_file_has_content ${FL_DIR}/repo/config '^collection-id=net.malicious.NewCollection$'

echo "ok 3 update repo config to with different collection ID"
echo "ok 3 update repo config with different collection ID"

0 comments on commit 56b23fe

Please sign in to comment.