install: Support local paths/uris

If the remote is a local path (absolute or relative starting with ./)
then we convert this to a file: uri, which are now supported to
install directly from a local repo.

This is very useful when testing locally built apps.

Closes: #1244
Approved by: alexlarsson
This commit is contained in:
Alexander Larsson 2017-12-12 11:12:09 +01:00 committed by Atomic Bot
parent 6e17756db6
commit 659b02011a
2 changed files with 15 additions and 1 deletions

View File

@ -463,6 +463,7 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
g_autoptr(GPtrArray) dirs = NULL;
FlatpakDir *dir;
const char *remote;
g_autofree char *remote_url = NULL;
char **prefs = NULL;
int i, n_prefs;
g_autofree char *target_branch = NULL;
@ -497,7 +498,15 @@ flatpak_builtin_install (int argc, char **argv, GCancellable *cancellable, GErro
if (argc < 3)
return usage_error (context, _("REMOTE and REF must be specified"), error);
remote = argv[1];
if (g_path_is_absolute (argv[1]) ||
g_str_has_prefix (argv[1], "./"))
{
g_autoptr(GFile) remote_file = g_file_new_for_commandline_arg (argv[1]);
remote_url = g_file_get_uri (remote_file);
remote = remote_url;
}
else
remote = argv[1];
prefs = &argv[2];
n_prefs = argc - 2;

View File

@ -74,6 +74,11 @@
the specified <arg choice="plain">REMOTE</arg>, but you can limit this by using the --app or
--runtime option, or by supplying the initial element in the REF.
</para>
<para>
If <arg choice="plain">REMOTE</arg> is a uri or a path (absolute or relative starting with ./)
to a local repository, then that repository will be used as the source, and a temporary remote
will be created for the lifetime of the <arg choice="plain">REF</arg>.
</para>
<para>
The alternative form of the command (<arg>--from</arg> or
<arg>--bundle</arg> allows you to