forked from Mirrors/flatpak-builder
remote-add: Use the new system-helper for initial metadata update
This removes some duplicated code, and also follows the new redirect-url property on initial add. This also means we're requiring gpg signatures to be correct on remote-add, so fix up the teststingping/wmclass
parent
af7195e6ae
commit
c35bce077f
|
@ -276,47 +276,6 @@ load_options (const char *filename,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
|
||||||
update_remote_with_extra_metadata (FlatpakDir* dir,
|
|
||||||
const char *remote,
|
|
||||||
GBytes *gpg_data,
|
|
||||||
GCancellable *cancellable,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_autofree char *title = NULL;
|
|
||||||
g_autofree char *default_branch = NULL;
|
|
||||||
g_autoptr(GKeyFile) config = NULL;
|
|
||||||
gboolean changed = FALSE;
|
|
||||||
|
|
||||||
if (opt_title == NULL)
|
|
||||||
{
|
|
||||||
title = flatpak_dir_fetch_remote_title (dir,
|
|
||||||
remote,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (title)
|
|
||||||
opt_title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_default_branch == NULL)
|
|
||||||
{
|
|
||||||
default_branch = flatpak_dir_fetch_remote_default_branch (dir,
|
|
||||||
remote,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
if (default_branch)
|
|
||||||
opt_default_branch = default_branch;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (title != NULL || default_branch != NULL)
|
|
||||||
{
|
|
||||||
config = get_config_from_opts (dir, remote, &changed);
|
|
||||||
return flatpak_dir_modify_remote (dir, remote, config, gpg_data, cancellable, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
flatpak_builtin_add_remote (int argc, char **argv,
|
flatpak_builtin_add_remote (int argc, char **argv,
|
||||||
GCancellable *cancellable, GError **error)
|
GCancellable *cancellable, GError **error)
|
||||||
|
@ -403,7 +362,7 @@ flatpak_builtin_add_remote (int argc, char **argv,
|
||||||
|
|
||||||
/* We can't retrieve the extra metadata until the remote has been added locally, since
|
/* We can't retrieve the extra metadata until the remote has been added locally, since
|
||||||
ostree_repo_remote_fetch_summary() works with the repository's name, not its URL. */
|
ostree_repo_remote_fetch_summary() works with the repository's name, not its URL. */
|
||||||
return update_remote_with_extra_metadata (dir, remote_name, gpg_data, cancellable, error);
|
return flatpak_dir_update_remote_configuration (dir, remote_name, cancellable, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
|
|
@ -37,11 +37,15 @@ GPGPUBKEY="${FL_GPG_HOMEDIR2}/pubring.gpg" GPGARGS="${FL_GPGARGS2}" setup_repo t
|
||||||
|
|
||||||
#remote with missing GPG key
|
#remote with missing GPG key
|
||||||
port=$(cat httpd-port-main)
|
port=$(cat httpd-port-main)
|
||||||
flatpak remote-add ${U} test-missing-gpg-repo "http://127.0.0.1:${port}/test"
|
if flatpak remote-add ${U} test-missing-gpg-repo "http://127.0.0.1:${port}/test"; then
|
||||||
|
assert_not_reached "Should fail metadata-update due to missing gpg key"
|
||||||
|
fi
|
||||||
|
|
||||||
#remote with wrong GPG key
|
#remote with wrong GPG key
|
||||||
port=$(cat httpd-port-main)
|
port=$(cat httpd-port-main)
|
||||||
flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR2}/pubring.gpg test-wrong-gpg-repo "http://127.0.0.1:${port}/test"
|
if flatpak remote-add ${U} --gpg-import=${FL_GPG_HOMEDIR2}/pubring.gpg test-wrong-gpg-repo "http://127.0.0.1:${port}/test"; then
|
||||||
|
assert_not_reached "Should fail metadata-update due to wrong gpg key"
|
||||||
|
fi
|
||||||
|
|
||||||
install_repo test-no-gpg
|
install_repo test-no-gpg
|
||||||
echo "ok install without gpg key"
|
echo "ok install without gpg key"
|
||||||
|
|
Loading…
Reference in New Issue