Skip to content

Commit

Permalink
gnome: add support for update-mime-database
Browse files Browse the repository at this point in the history
Fixes #10865
  • Loading branch information
Paolo Borelli authored and xclaesse committed Sep 28, 2022
1 parent 56a6ee1 commit a58ec32
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/markdown/Gnome-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,3 +415,5 @@ It takes the following keyword arguments:
`<prefix>/<datadir>/icons/hicolor`.
- `update_desktop_database`: *Since 0.59.0* If set to `true`, update cache of
MIME types handled by desktop files in `<prefix>/<datadir>/applications`.
- `update_mime_database`: *Since 0.64.0* If set to `true`, update cache of
MIME types in `<prefix>/<datadir>/mime`.
5 changes: 5 additions & 0 deletions docs/markdown/snippets/gnome_update_mime_database.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Added `update_mime_database` to `gnome.post_install()`

Applications that install a `.xml` file containing a `mime-type` need to update
the cache upon installation. Most applications do that using a custom script,
but it can now be done by Meson directly.
10 changes: 10 additions & 0 deletions mesonbuild/modules/gnome.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class PostInstall(TypedDict):
gio_querymodules: T.List[str]
gtk_update_icon_cache: bool
update_desktop_database: bool
update_mime_database: bool

class CompileSchemas(TypedDict):

Expand Down Expand Up @@ -282,6 +283,7 @@ def __init__(self, interpreter: 'Interpreter') -> None:
self.install_gio_querymodules: T.List[str] = []
self.install_gtk_update_icon_cache = False
self.install_update_desktop_database = False
self.install_update_mime_database = False
self.devenv: T.Optional[build.EnvironmentVariables] = None
self.native_glib_version: T.Optional[str] = None
self.methods.update({
Expand Down Expand Up @@ -332,6 +334,7 @@ def _print_gdbus_warning() -> None:
KwargInfo('gio_querymodules', ContainerTypeInfo(list, str), default=[], listify=True),
KwargInfo('gtk_update_icon_cache', bool, default=False),
KwargInfo('update_desktop_database', bool, default=False, since='0.59.0'),
KwargInfo('update_mime_database', bool, default=False, since='0.64.0'),
)
@noPosargs
@FeatureNew('gnome.post_install', '0.57.0')
Expand Down Expand Up @@ -370,6 +373,13 @@ def post_install(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: '
script = state.backend.get_executable_serialisation([prog, '-q', appdir])
script.skip_if_destdir = True
rv.append(script)
if kwargs['update_mime_database'] and not self.install_update_mime_database:
self.install_update_mime_database = True
prog = state.find_program('update-mime-database')
appdir = os.path.join(datadir_abs, 'mime')
script = state.backend.get_executable_serialisation([prog, appdir])
script.skip_if_destdir = True
rv.append(script)
return ModuleReturnValue(None, rv)

@typed_pos_args('gnome.compile_resources', str, (str, mesonlib.File, build.CustomTarget, build.CustomTargetIndex, build.GeneratedList))
Expand Down

0 comments on commit a58ec32

Please sign in to comment.