diff --git a/data/flatpak-manifest.schema.json b/data/flatpak-manifest.schema.json index 9f921985..cbb522a6 100644 --- a/data/flatpak-manifest.schema.json +++ b/data/flatpak-manifest.schema.json @@ -1451,10 +1451,22 @@ "description": "Any appdata (metainfo) file with this name will be renamed to a name based on id during the cleanup phase.", "type": "string" }, + "rename-mime-file": { + "description": "Any mimetypes file with this name will me renamed to a name based on id during the cleanup phase.", + "type": "string" + }, "rename-icon": { "description": "Any icon with this name will be renamed to a name based on id during the cleanup phase. Note that this is the icon name, not the full filenames, so it should not include a filename extension.", "type": "string" }, + "rename-mime-icons": { + "type": "array", + "description": "Any mime icons with any of these names will be renamed to a name prefixed with id during the cleanup phase. Note that this is the icon name, not the full filenames, so it should not include a filename extension.", + "items": { + "description": "Icon name to rename.", + "type": "string" + } + }, "appdata-license": { "description": "Replace the appdata (metainfo) project_license field with this string. This is useful as the upstream license is typically only about the application itself, whereas the bundled app can contain other licenses too.", "type": "string" diff --git a/doc/flatpak-manifest.xml b/doc/flatpak-manifest.xml index a84ca9fe..4ce2523e 100644 --- a/doc/flatpak-manifest.xml +++ b/doc/flatpak-manifest.xml @@ -261,10 +261,18 @@ (string) Any appdata (metainfo) file with this name will be renamed to a name based on id during the cleanup phase. + + (string) + Any mimetypes file with this name will me renamed to a name based on id during the cleanup phase. (since 1.4.0) + (string) Any icon with this name will be renamed to a name based on id during the cleanup phase. Note that this is the icon name, not the full filenames, so it should not include a filename extension. + + (array of string) + Any mime icons with any of these names will be renamed to a name prefixed with id during the cleanup phase. Note that this is the icon name, not the full filenames, so it should not include a filename extension. (since 1.4.0) + (string) Replace the appdata (metainfo) diff --git a/src/builder-manifest.c b/src/builder-manifest.c index 3cbbdff2..8a4f99cf 100644 --- a/src/builder-manifest.c +++ b/src/builder-manifest.c @@ -90,8 +90,10 @@ struct BuilderManifest char **tags; char *rename_desktop_file; char *rename_appdata_file; + char *rename_mime_file; char *appdata_license; char *rename_icon; + char **rename_mime_icons; gboolean copy_icon; char *desktop_file_name_prefix; char *desktop_file_name_suffix; @@ -160,8 +162,10 @@ enum { PROP_TAGS, PROP_RENAME_DESKTOP_FILE, PROP_RENAME_APPDATA_FILE, + PROP_RENAME_MIME_FILE, PROP_APPDATA_LICENSE, PROP_RENAME_ICON, + PROP_RENAME_MIME_ICONS, PROP_COPY_ICON, PROP_DESKTOP_FILE_NAME_PREFIX, PROP_DESKTOP_FILE_NAME_SUFFIX, @@ -212,8 +216,10 @@ builder_manifest_finalize (GObject *object) g_strfreev (self->tags); g_free (self->rename_desktop_file); g_free (self->rename_appdata_file); + g_free (self->rename_mime_file); g_free (self->appdata_license); g_free (self->rename_icon); + g_free (self->rename_mime_icons); g_free (self->desktop_file_name_prefix); g_free (self->desktop_file_name_suffix); @@ -450,6 +456,10 @@ builder_manifest_get_property (GObject *object, g_value_set_string (value, self->rename_appdata_file); break; + case PROP_RENAME_MIME_FILE: + g_value_set_string (value, self->rename_mime_file); + break; + case PROP_APPDATA_LICENSE: g_value_set_string (value, self->appdata_license); break; @@ -458,6 +468,10 @@ builder_manifest_get_property (GObject *object, g_value_set_string (value, self->rename_icon); break; + case PROP_RENAME_MIME_ICONS: + g_value_set_boxed (value, self->rename_mime_icons); + break; + case PROP_DESKTOP_FILE_NAME_PREFIX: g_value_set_string (value, self->desktop_file_name_prefix); break; @@ -711,6 +725,11 @@ builder_manifest_set_property (GObject *object, self->rename_appdata_file = g_value_dup_string (value); break; + case PROP_RENAME_MIME_FILE: + g_free (self->rename_mime_file); + self->rename_mime_file = g_value_dup_string (value); + break; + case PROP_APPDATA_LICENSE: g_free (self->appdata_license); self->appdata_license = g_value_dup_string (value); @@ -721,6 +740,12 @@ builder_manifest_set_property (GObject *object, self->rename_icon = g_value_dup_string (value); break; + case PROP_RENAME_MIME_ICONS: + tmp = self->rename_mime_icons; + self->rename_mime_icons = g_strdupv (g_value_get_boxed (value)); + g_strfreev (tmp); + break; + case PROP_DESKTOP_FILE_NAME_PREFIX: g_free (self->desktop_file_name_prefix); self->desktop_file_name_prefix = g_value_dup_string (value); @@ -1040,6 +1065,13 @@ builder_manifest_class_init (BuilderManifestClass *klass) "", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_RENAME_MIME_FILE, + g_param_spec_string ("rename-mime-file", + "", + "", + NULL, + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_APPDATA_LICENSE, g_param_spec_string ("appdata-license", @@ -1054,6 +1086,13 @@ builder_manifest_class_init (BuilderManifestClass *klass) "", NULL, G_PARAM_READWRITE)); + g_object_class_install_property (object_class, + PROP_RENAME_MIME_ICONS, + g_param_spec_boxed ("rename-mime-icons", + "", + "", + G_TYPE_STRV, + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_COPY_ICON, g_param_spec_boolean ("copy-icon", @@ -1865,8 +1904,10 @@ builder_manifest_checksum_for_cleanup (BuilderManifest *self, builder_cache_checksum_strv (cache, self->cleanup_commands); builder_cache_checksum_str (cache, self->rename_desktop_file); builder_cache_checksum_str (cache, self->rename_appdata_file); + builder_cache_checksum_str (cache, self->rename_mime_file); builder_cache_checksum_str (cache, self->appdata_license); builder_cache_checksum_str (cache, self->rename_icon); + builder_cache_checksum_strv (cache, self->rename_mime_icons); builder_cache_checksum_boolean (cache, self->copy_icon); builder_cache_checksum_str (cache, self->desktop_file_name_prefix); builder_cache_checksum_str (cache, self->desktop_file_name_suffix); @@ -2169,7 +2210,13 @@ command (GFile *app_dir, return builder_maybe_host_spawnv (NULL, NULL, 0, error, (const char * const *)args->pdata, NULL); } -typedef gboolean (*ForeachFileFunc) (BuilderManifest *self, +typedef struct { + const char *rename_icon; + gboolean copy_icon; + const char *id; +} ForeachFile; + +typedef gboolean (*ForeachFileFunc) (ForeachFile *self, int source_parent_fd, const char *source_name, const char *full_dir, @@ -2180,7 +2227,7 @@ typedef gboolean (*ForeachFileFunc) (BuilderManifest *self, GError **error); static gboolean -foreach_file_helper (BuilderManifest *self, +foreach_file_helper (ForeachFile *self, ForeachFileFunc func, int source_parent_fd, const char *source_name, @@ -2242,7 +2289,7 @@ foreach_file_helper (BuilderManifest *self, } static gboolean -foreach_file (BuilderManifest *self, +foreach_file (ForeachFile *self, ForeachFileFunc func, gboolean *found, GFile *root, @@ -2257,15 +2304,16 @@ foreach_file (BuilderManifest *self, } static gboolean -rename_icon_cb (BuilderManifest *self, - int source_parent_fd, - const char *source_name, - const char *full_dir, - const char *rel_dir, - struct stat *stbuf, - gboolean *found, - int depth, - GError **error) +_rename_icon (ForeachFile *self, + int source_parent_fd, + const char *source_name, + const char *full_dir, + const char *rel_dir, + gboolean prefix, + struct stat *stbuf, + gboolean *found, + int depth, + GError **error) { if (g_str_has_prefix (source_name, self->rename_icon)) { @@ -2275,8 +2323,12 @@ rename_icon_cb (BuilderManifest *self, g_str_has_prefix (source_name + strlen (self->rename_icon), "-symbolic."))) { const char *extension = source_name + strlen (self->rename_icon); - g_autofree char *new_name = g_strconcat (self->id, extension, NULL); + g_autofree char *new_name; int res; + if (!prefix) + new_name = g_strconcat (self->id, extension, NULL); + else + new_name = g_strconcat (self->id, ".", source_name, NULL); *found = TRUE; @@ -2307,6 +2359,40 @@ rename_icon_cb (BuilderManifest *self, return TRUE; } +static gboolean +rename_icon_cb (ForeachFile *self, + int source_parent_fd, + const char *source_name, + const char *full_dir, + const char *rel_dir, + struct stat *stbuf, + gboolean *found, + int depth, + GError **error) +{ + return _rename_icon (self, + source_parent_fd, source_name, + full_dir, rel_dir, FALSE, + stbuf, found, depth, error); +} + +static gboolean +rename_mime_icon_cb (ForeachFile *self, + int source_parent_fd, + const char *source_name, + const char *full_dir, + const char *rel_dir, + struct stat *stbuf, + gboolean *found, + int depth, + GError **error) +{ + return _rename_icon (self, + source_parent_fd, source_name, + full_dir, rel_dir, TRUE, + stbuf, found, depth, error); +} + static int cmpstringp (const void *p1, const void *p2) { @@ -2459,6 +2545,147 @@ builder_manifest_find_appdata_file (BuilderManifest *self, return NULL; } +/* Perform `rename-mime-file` */ +static gboolean +_cleanup_rename_mime_file (BuilderManifest *self, GFile *app_root, + GError **error) +{ + g_autoptr(GFile) applications_dir = g_file_resolve_relative_path (app_root, "share/mime/packages"); + g_autoptr(GFile) src = g_file_get_child (applications_dir, self->rename_mime_file); + g_autofree char *mime_basename = g_strdup_printf ("%s.xml", self->id); + g_autoptr(GFile) dest = g_file_get_child (applications_dir, mime_basename); + + g_print ("Renaming %s to %s\n", self->rename_mime_file, mime_basename); + if (!g_file_move (src, dest, 0, NULL, NULL, NULL, error)) + return FALSE; + + return TRUE; +} + +static gboolean +_rename_mime_icon (BuilderManifest *self, const char *rename_icon, + GFile *icons_dir, + GError **error) +{ + gboolean found_icon = FALSE; + + ForeachFile renamer; + renamer.rename_icon = rename_icon; + renamer.copy_icon = self->copy_icon; + renamer.id = self->id; + if (!foreach_file (&renamer, rename_mime_icon_cb, &found_icon, icons_dir, error)) + return FALSE; + + if (!found_icon) + { + g_autofree char *icon_path = g_file_get_path (icons_dir); + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "icon %s not found below %s", + rename_icon, icon_path); + return FALSE; + } + + return TRUE; +} + +/* Rename the icons inside the mime_file. + * + * The problem is that they may not be in the file as there is an + * automatic mapping of mimetypes with icon name, so we have to add + * them to he mime file in that case. + */ +static gboolean +_cleanup_mime_file_rename_icons (char **rename_mime_icons, + GFile *mime_file, + const char *id, GError **error) +{ + FlatpakXml *n_root; + g_autoptr(FlatpakXml) xml_root = NULL; + g_autoptr(GInputStream) in = NULL; + g_autoptr(GString) new_contents = NULL; + + in = (GInputStream *) g_file_read (mime_file, NULL, error); + if (!in) + return FALSE; + xml_root = flatpak_xml_parse (in, FALSE, NULL, error); + if (!xml_root) + return FALSE; + + n_root = flatpak_xml_find (xml_root, "mime-info", NULL); + + for (char **current = rename_mime_icons; *current; current++) + { + FlatpakXml *n_type = NULL; + while ((n_type = flatpak_xml_find_next (n_root, "mime-type", n_type, NULL))) + { + FlatpakXml *n_icon = flatpak_xml_find (n_type, "icon", NULL); + if (!n_icon) + n_icon = flatpak_xml_find (n_type, "generic-icon", NULL); + if (n_icon) + { + const gchar *icon_name = flatpak_xml_attribute (n_icon, "name"); + if (g_strcmp0 (*current, icon_name) == 0) + { + g_autofree gchar *renamed_icon = g_strdup_printf ("%s.%s", id, icon_name); + flatpak_xml_set_attribute (n_icon, "name", renamed_icon); + } + } + else + { + g_autofree char* mimetype = g_strdup(flatpak_xml_attribute (n_type, "type")); + /* Convert the mime type to an icon name. */ + for (char *p = mimetype; *p; p++) + if (*p == '/') + *p = '-'; + + if (g_strcmp0(mimetype, *current) == 0) + { + g_autofree gchar *renamed_icon = g_strdup_printf ("%s.%s", id, *current); + const gchar *attrs[] = { "name", NULL }; + const gchar *vals[] = { renamed_icon, NULL }; + n_icon = flatpak_xml_new_with_attributes ("icon", attrs, vals); + flatpak_xml_add (n_type, g_steal_pointer (&n_icon)); + } + } + } + } + + new_contents = g_string_new (""); + flatpak_xml_to_string (xml_root, new_contents); + if (!g_file_set_contents (flatpak_file_get_path_cached (mime_file), + new_contents->str, + new_contents->len, + error)) + return FALSE; + + return TRUE; +} + +/* Perform `rename-mime-icons` */ +static gboolean +_cleanup_rename_mime_icons (BuilderManifest *self, GFile *app_root, + GError **error) +{ + g_autoptr(GFile) icons_dir = g_file_resolve_relative_path (app_root, "share/icons"); + g_autoptr(GFile) mime_dir; + g_autofree char *mime_basename; + g_autoptr(GFile) mime_file; + + for (char **current = self->rename_mime_icons; *current; current++) + if (!_rename_mime_icon (self, *current, icons_dir, error)) + return FALSE; + + mime_dir = g_file_resolve_relative_path (app_root, "share/mime/packages"); + mime_basename = g_strdup_printf ("%s.xml", self->id); + mime_file = g_file_get_child (mime_dir, mime_basename); + + if (!_cleanup_mime_file_rename_icons (self->rename_mime_icons, mime_file, + self->id, error)) + return FALSE; + + return TRUE; +} + gboolean builder_manifest_cleanup (BuilderManifest *self, BuilderCache *cache, @@ -2625,12 +2852,19 @@ builder_manifest_cleanup (BuilderManifest *self, } } + if (self->rename_mime_file != NULL) + if (!_cleanup_rename_mime_file (self, app_root, error)) + return FALSE; + if (self->rename_icon) { gboolean found_icon = FALSE; g_autoptr(GFile) icons_dir = g_file_resolve_relative_path (app_root, "share/icons"); - - if (!foreach_file (self, rename_icon_cb, &found_icon, icons_dir, error)) + ForeachFile renamer; + renamer.rename_icon = self->rename_icon; + renamer.copy_icon = self->copy_icon; + renamer.id = self->id; + if (!foreach_file (&renamer, rename_icon_cb, &found_icon, icons_dir, error)) return FALSE; if (!found_icon) @@ -2643,6 +2877,10 @@ builder_manifest_cleanup (BuilderManifest *self, } } + if (self->rename_mime_icons) + if (!_cleanup_rename_mime_icons (self, app_root, error)) + return FALSE; + if (self->rename_icon || self->desktop_file_name_prefix || self->desktop_file_name_suffix || diff --git a/src/builder-utils.c b/src/builder-utils.c index 556f16ba..add57789 100644 --- a/src/builder-utils.c +++ b/src/builder-utils.c @@ -1408,6 +1408,20 @@ flatpak_xml_new (const gchar *element_name) return node; } +FlatpakXml * +flatpak_xml_new_with_attributes (const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values) +{ + FlatpakXml *node = g_new0 (FlatpakXml, 1); + + node->element_name = g_strdup (element_name); + node->attribute_names = g_strdupv ((char **) attribute_names); + node->attribute_values = g_strdupv ((char **) attribute_values); + + return node; +} + FlatpakXml * flatpak_xml_new_text (const gchar *text) { @@ -1440,9 +1454,9 @@ xml_start_element (GMarkupParseContext *context, XmlData *data = user_data; FlatpakXml *node; - node = flatpak_xml_new (element_name); - node->attribute_names = g_strdupv ((char **) attribute_names); - node->attribute_values = g_strdupv ((char **) attribute_values); + node = flatpak_xml_new_with_attributes (element_name, + attribute_names, + attribute_values); flatpak_xml_add (data->current, node); data->current = node; @@ -1514,6 +1528,31 @@ flatpak_xml_free (FlatpakXml *node) g_free (node); } +const gchar * +flatpak_xml_attribute (FlatpakXml *node, const gchar* name) +{ + if (node->attribute_names) + for (int i = 0; node->attribute_names[i] != NULL; i++) + if (g_strcmp0(node->attribute_names[i], name) == 0) + return node->attribute_values[i]; + + return NULL; +} + +gboolean +flatpak_xml_set_attribute (FlatpakXml *node, const gchar* name, const gchar* value) +{ + if (node->attribute_names) + for (int i = 0; node->attribute_names[i] != NULL; i++) + if (g_strcmp0(node->attribute_names[i], name) == 0) + { + g_free (node->attribute_values[i]); + node->attribute_values[i] = g_strdup (value); + return TRUE; + } + + return FALSE; +} void flatpak_xml_to_string (FlatpakXml *node, GString *res) @@ -1534,9 +1573,11 @@ flatpak_xml_to_string (FlatpakXml *node, GString *res) { for (i = 0; node->attribute_names[i] != NULL; i++) { - g_string_append_printf (res, " %s=\"%s\"", - node->attribute_names[i], - node->attribute_values[i]); + g_autofree char* attr = + g_markup_printf_escaped (" %s=\"%s\"", + node->attribute_names[i], + node->attribute_values[i]); + g_string_append (res, attr); } } if (node->first_child == NULL) @@ -1593,12 +1634,29 @@ FlatpakXml * flatpak_xml_find (FlatpakXml *node, const char *type, FlatpakXml **prev_child_out) +{ + return flatpak_xml_find_next (node, type, NULL, prev_child_out); +} + +FlatpakXml * +flatpak_xml_find_next (FlatpakXml *node, + const char *type, + FlatpakXml *sibling, + FlatpakXml **prev_child_out) { FlatpakXml *child = NULL; FlatpakXml *prev_child = NULL; - child = node->first_child; - prev_child = NULL; + if (!sibling) + { + child = node->first_child; + prev_child = NULL; + } + else + { + child = sibling->next_sibling; + prev_child = sibling; + } while (child != NULL) { FlatpakXml *next = child->next_sibling; diff --git a/src/builder-utils.h b/src/builder-utils.h index 615d06d7..0b24b272 100644 --- a/src/builder-utils.h +++ b/src/builder-utils.h @@ -169,6 +169,9 @@ struct FlatpakXml }; FlatpakXml *flatpak_xml_new (const gchar *element_name); +FlatpakXml *flatpak_xml_new_with_attributes (const gchar *element_name, + const gchar **attribute_names, + const gchar **attribute_values); FlatpakXml *flatpak_xml_new_text (const gchar *text); void flatpak_xml_add (FlatpakXml *parent, FlatpakXml *node); @@ -177,13 +180,26 @@ FlatpakXml *flatpak_xml_parse (GInputStream *in, gboolean compressed, GCancellable *cancellable, GError **error); +const gchar *flatpak_xml_attribute (FlatpakXml *node, + const gchar *name); +gboolean flatpak_xml_set_attribute (FlatpakXml *node, + const gchar *name, + const gchar *value); void flatpak_xml_to_string (FlatpakXml *node, GString *res); FlatpakXml *flatpak_xml_unlink (FlatpakXml *node, FlatpakXml *prev_sibling); +/** Find the first child of `type`. */ FlatpakXml *flatpak_xml_find (FlatpakXml *node, const char *type, FlatpakXml **prev_child_out); +/** Find the next child from sibling. If `sibling` is NULL, it's + * equivalant to calling `flatpak_xml_find()`. + */ +FlatpakXml *flatpak_xml_find_next (FlatpakXml *node, + const char *type, + FlatpakXml *sibling, + FlatpakXml **prev_child_out); GBytes * flatpak_read_stream (GInputStream *in, gboolean null_terminate, diff --git a/tests/Hello.desktop b/tests/Hello.desktop new file mode 100644 index 00000000..46fbd76f --- /dev/null +++ b/tests/Hello.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=Hello +Exec=hello2.sh +Icon=Hello +MimeType=x-test/Hello; diff --git a/tests/Hello.xml b/tests/Hello.xml new file mode 100644 index 00000000..c1e2be1f --- /dev/null +++ b/tests/Hello.xml @@ -0,0 +1,17 @@ + + + + Hello Document + + + + + + + + + Goodbye Document + + + + diff --git a/tests/Makefile.am.inc b/tests/Makefile.am.inc index 00ea4a8d..d9602222 100644 --- a/tests/Makefile.am.inc +++ b/tests/Makefile.am.inc @@ -21,6 +21,9 @@ dist_installed_test_data = \ tests/libtest.sh \ tests/org.test.Hello.png \ tests/org.test.Hello.desktop \ + tests/Hello.desktop \ + tests/org.test.Hello.xml \ + tests/Hello.xml \ tests/source1.json \ tests/source2.json \ tests/test.json \ diff --git a/tests/meson.build b/tests/meson.build index b82a64ea..6ec405d1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -89,6 +89,9 @@ if get_option('installed_tests') 'org.test.Deprecated.SHA1.file.yaml', 'org.test.Hello.png', 'org.test.Hello.desktop', + 'Hello.desktop', + 'org.test.Hello.xml', + 'Hello.xml', 'org.test.Python.json', 'org.test.Python2.json', 'session.conf.in', diff --git a/tests/org.test.Hello.desktop b/tests/org.test.Hello.desktop index 7a2a6046..21fddcd6 100644 --- a/tests/org.test.Hello.desktop +++ b/tests/org.test.Hello.desktop @@ -3,5 +3,5 @@ Version=1.0 Type=Application Name=Hello Exec=hello2.sh -Icon=org.test.Hello +Icon=org.test.Hello2 MimeType=x-test/Hello; diff --git a/tests/org.test.Hello.xml b/tests/org.test.Hello.xml new file mode 100644 index 00000000..8d96de43 --- /dev/null +++ b/tests/org.test.Hello.xml @@ -0,0 +1,18 @@ + + + + Hello Document + + + + + + + + + + Goodbye Document + + + + diff --git a/tests/test-builder.sh b/tests/test-builder.sh index 2c9199f8..31075814 100755 --- a/tests/test-builder.sh +++ b/tests/test-builder.sh @@ -41,7 +41,10 @@ cp $(dirname $0)/test.json . cp $(dirname $0)/test.yaml . cp $(dirname $0)/test-runtime.json . cp $(dirname $0)/0001-Add-test-logo.patch . +cp $(dirname $0)/Hello.desktop . +cp $(dirname $0)/Hello.xml . cp $(dirname $0)/org.test.Hello.desktop . +cp $(dirname $0)/org.test.Hello.xml . mkdir include1 cp $(dirname $0)/module1.json include1/ cp $(dirname $0)/module1.yaml include1/ @@ -70,8 +73,13 @@ for MANIFEST in test.json test.yaml test-rename.json ; do assert_has_file appdir/files/cleaned_up > out assert_has_file appdir/files/share/icons/hicolor/64x64/apps/org.test.Hello2.png + assert_has_file appdir/files/share/icons/hicolor/64x64/mimetypes/org.test.Hello2.application-x-hello.png + assert_has_file appdir/files/share/icons/hicolor/64x64/mimetypes/org.test.Hello2.application-x-goodbye.png assert_has_file appdir/files/share/applications/org.test.Hello2.desktop + assert_has_file appdir/files/share/mime/packages/org.test.Hello2.xml + xmllint appdir/files/share/mime/packages/org.test.Hello2.xml >&2 + assert_file_has_content appdir/files/out '^foo$' assert_file_has_content appdir/files/out2 '^foo2$' diff --git a/tests/test-rename.json b/tests/test-rename.json index af39465d..a8ee82d6 100644 --- a/tests/test-rename.json +++ b/tests/test-rename.json @@ -10,6 +10,11 @@ ], "rename-icon": "Hello", "rename-desktop-file": "Hello.desktop", + "rename-mime-file": "Hello.xml", + "rename-mime-icons": [ + "application-x-hello", + "application-x-goodbye" + ], "build-options" : { "cflags": "-O2 -g", "cxxflags": "-O2 -g", @@ -31,9 +36,14 @@ "post-install": [ "touch /app/bin/file.cleanup", "mkdir -p /app/share/icons/hicolor/64x64/apps/", + "mkdir -p /app/share/icons/hicolor/64x64/mimetypes/", "cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/Hello.png", + "cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/application-x-hello.png", + "cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/application-x-goodbye.png", "mkdir -p /app/share/applications", - "cp org.test.Hello.desktop /app/share/applications/Hello.desktop" + "cp Hello.desktop /app/share/applications/", + "mkdir -p /app/share/mime/packages", + "cp Hello.xml /app/share/mime/packages/" ], "make-args": ["BAR=2" ], "make-install-args": ["BAR=3" ], @@ -51,7 +61,11 @@ }, { "type": "file", - "path": "org.test.Hello.desktop" + "path": "Hello.desktop" + }, + { + "type": "file", + "path": "Hello.xml" }, { "type": "script", diff --git a/tests/test.json b/tests/test.json index def26f47..c58ae9ca 100644 --- a/tests/test.json +++ b/tests/test.json @@ -29,9 +29,14 @@ "post-install": [ "touch /app/bin/file.cleanup", "mkdir -p /app/share/icons/hicolor/64x64/apps/", + "mkdir -p /app/share/icons/hicolor/64x64/mimetypes/", "cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/$FLATPAK_ID.png", + "cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/$FLATPAK_ID.application-x-hello.png", + "cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/$FLATPAK_ID.application-x-goodbye.png", "mkdir -p /app/share/applications", - "cp org.test.Hello.desktop /app/share/applications/$FLATPAK_ID.desktop" + "cp org.test.Hello.desktop /app/share/applications/$FLATPAK_ID.desktop", + "mkdir -p /app/share/mime/packages", + "cp org.test.Hello.xml /app/share/mime/packages/$FLATPAK_ID.xml" ], "make-args": ["BAR=2" ], "make-install-args": ["BAR=3" ], @@ -56,6 +61,10 @@ "type": "file", "path": "org.test.Hello.desktop" }, + { + "type": "file", + "path": "org.test.Hello.xml" + }, { "type": "shell", "commands": [ diff --git a/tests/test.yaml b/tests/test.yaml index 2c447de7..65fb6c48 100644 --- a/tests/test.yaml +++ b/tests/test.yaml @@ -23,9 +23,14 @@ modules: post-install: - touch /app/bin/file.cleanup - mkdir -p /app/share/icons/hicolor/64x64/apps/ + - mkdir -p /app/share/icons/hicolor/64x64/mimetypes/ - cp org.test.Hello.png /app/share/icons/hicolor/64x64/apps/$FLATPAK_ID.png + - cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/$FLATPAK_ID.application-x-hello.png + - cp org.test.Hello.png /app/share/icons/hicolor/64x64/mimetypes/$FLATPAK_ID.application-x-goodbye.png - mkdir -p /app/share/applications - cp org.test.Hello.desktop /app/share/applications/$FLATPAK_ID.desktop + - mkdir -p /app/share/mime/packages + - cp org.test.Hello.xml /app/share/mime/packages/$FLATPAK_ID.xml make-args: [BAR=2] make-install-args: [BAR=3] build-commands: ['echo foo > /app/out'] @@ -41,6 +46,8 @@ modules: commands: ['echo "Hello world2, from a sandbox"'] - type: file path: org.test.Hello.desktop + - type: file + path: org.test.Hello.xml - type: shell commands: - mkdir /app/cleanup/