Skip to content

Commit a58ec32

Browse files
Paolo Borellixclaesse
authored andcommitted
gnome: add support for update-mime-database
Fixes #10865
1 parent 56a6ee1 commit a58ec32

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

docs/markdown/Gnome-module.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,3 +415,5 @@ It takes the following keyword arguments:
415415
`<prefix>/<datadir>/icons/hicolor`.
416416
- `update_desktop_database`: *Since 0.59.0* If set to `true`, update cache of
417417
MIME types handled by desktop files in `<prefix>/<datadir>/applications`.
418+
- `update_mime_database`: *Since 0.64.0* If set to `true`, update cache of
419+
MIME types in `<prefix>/<datadir>/mime`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Added `update_mime_database` to `gnome.post_install()`
2+
3+
Applications that install a `.xml` file containing a `mime-type` need to update
4+
the cache upon installation. Most applications do that using a custom script,
5+
but it can now be done by Meson directly.

mesonbuild/modules/gnome.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ class PostInstall(TypedDict):
5858
gio_querymodules: T.List[str]
5959
gtk_update_icon_cache: bool
6060
update_desktop_database: bool
61+
update_mime_database: bool
6162

6263
class CompileSchemas(TypedDict):
6364

@@ -282,6 +283,7 @@ def __init__(self, interpreter: 'Interpreter') -> None:
282283
self.install_gio_querymodules: T.List[str] = []
283284
self.install_gtk_update_icon_cache = False
284285
self.install_update_desktop_database = False
286+
self.install_update_mime_database = False
285287
self.devenv: T.Optional[build.EnvironmentVariables] = None
286288
self.native_glib_version: T.Optional[str] = None
287289
self.methods.update({
@@ -332,6 +334,7 @@ def _print_gdbus_warning() -> None:
332334
KwargInfo('gio_querymodules', ContainerTypeInfo(list, str), default=[], listify=True),
333335
KwargInfo('gtk_update_icon_cache', bool, default=False),
334336
KwargInfo('update_desktop_database', bool, default=False, since='0.59.0'),
337+
KwargInfo('update_mime_database', bool, default=False, since='0.64.0'),
335338
)
336339
@noPosargs
337340
@FeatureNew('gnome.post_install', '0.57.0')
@@ -370,6 +373,13 @@ def post_install(self, state: 'ModuleState', args: T.List['TYPE_var'], kwargs: '
370373
script = state.backend.get_executable_serialisation([prog, '-q', appdir])
371374
script.skip_if_destdir = True
372375
rv.append(script)
376+
if kwargs['update_mime_database'] and not self.install_update_mime_database:
377+
self.install_update_mime_database = True
378+
prog = state.find_program('update-mime-database')
379+
appdir = os.path.join(datadir_abs, 'mime')
380+
script = state.backend.get_executable_serialisation([prog, appdir])
381+
script.skip_if_destdir = True
382+
rv.append(script)
373383
return ModuleReturnValue(None, rv)
374384

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

0 commit comments

Comments
 (0)