summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2020-08-11 00:00:17 +0100
committerAlexander Larsson <alexander.larsson@gmail.com>2020-08-27 17:48:50 +0200
commit09424423b93e9ea263a9e3f2de1579814b941054 (patch)
treecf1d6fbfbf3841ce01431539a455bf41962ce177
parent02094b4f39e0bcb2d2e4c82926154c584759d0e1 (diff)
downloadflatpak-09424423b93e9ea263a9e3f2de1579814b941054.tar.gz
context: Normalize home/path to ~/path, and ~ to home
Historically we didn't accept them, but there's no real reason why not. They're normalized to the form in which earlier Flatpak releases would want to see them. Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r--common/flatpak-context.c16
-rw-r--r--doc/flatpak-metadata.xml17
-rw-r--r--tests/test-exports.c6
3 files changed, 39 insertions, 0 deletions
diff --git a/common/flatpak-context.c b/common/flatpak-context.c
index 124fa107..cafdd3d1 100644
--- a/common/flatpak-context.c
+++ b/common/flatpak-context.c
@@ -826,6 +826,22 @@ flatpak_context_parse_filesystem (const char *filesystem_and_mode,
return TRUE;
}
+ if (strcmp (filesystem, "~") == 0)
+ {
+ if (filesystem_out != NULL)
+ *filesystem_out = g_strdup ("home");
+
+ return TRUE;
+ }
+
+ if (g_str_has_prefix (filesystem, "home/"))
+ {
+ if (filesystem_out != NULL)
+ *filesystem_out = g_strconcat ("~/", filesystem + 5, NULL);
+
+ return TRUE;
+ }
+
g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
_("Unknown filesystem location %s, valid locations are: host, host-os, host-etc, home, xdg-*[/…], ~/dir, /dir"), filesystem);
return FALSE;
diff --git a/doc/flatpak-metadata.xml b/doc/flatpak-metadata.xml
index 791a91df..0325689f 100644
--- a/doc/flatpak-metadata.xml
+++ b/doc/flatpak-metadata.xml
@@ -210,6 +210,14 @@
Available since 0.3.
</para></listitem></varlistentry>
+ <varlistentry><term><option>home/<replaceable>path</replaceable></option></term><listitem><para>
+ Alias for <filename>~/path</filename>
+ Available since 1.10.
+ For better compatibility with older
+ Flatpak versions, prefer to write this
+ as <filename>~/path</filename>.
+ </para></listitem></varlistentry>
+
<varlistentry><term><option>host</option></term>
<listitem><para>
The entire host file system, except for
@@ -382,6 +390,15 @@
directory. Available since 0.3.
</para></listitem></varlistentry>
+ <varlistentry><term><option>~</option></term>
+ <listitem><para>
+ The same as <option>home</option>.
+ Available since 1.10.
+ For better compatibility with older
+ Flatpak versions, prefer to write this
+ as <option>home</option>.
+ </para></listitem></varlistentry>
+
<varlistentry><term>
One of the above followed by
<option>:ro</option>
diff --git a/tests/test-exports.c b/tests/test-exports.c
index 38bd7f17..f27b7a21 100644
--- a/tests/test-exports.c
+++ b/tests/test-exports.c
@@ -328,6 +328,12 @@ static const Filesystem filesystems[] =
{ "xdg-config/././///.///././.", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "xdg-config" },
{ "xdg-config/////", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "xdg-config" },
{ "xdg-run/dbus", FLATPAK_FILESYSTEM_MODE_READ_WRITE },
+ { "~", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
+ { "~/.", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
+ { "~/", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
+ { "~///././//", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
+ { "home/", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" },
+ { "home/Projects", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "~/Projects" },
};
static void