#440 mimeinfo scriptlet update
Closed: Fixed None Opened 6 years ago by rdieter.


been working with hadess to address some performance issues with update-mime-database scriptlets recently. We came up with a solution to optimize things so that it runs only once per transaction, similar to how icon cache scriptlets currently work.

Here's the draft for consideration:

It utilizes a new update-mime-database -n option being developed. I'll help test and incorporate that change into rawhide's shared-mime-info packaging asap. As such, this change is targetted for f21+ only (though I will likely eventually work on older fedora shared-mime-info packaging to accept but ignore that new option)

And for added performance, you can consider adding PKGSYSTEM_ENABLE_FSYNC=0 too, replacing all
update-mime-database ...
PKGSYSTEM_ENABLE_FSYNC=0 update-mime-database ...
in the draft too, avoiding the performance regression introduced per the aforementioned bug report.

Full disclosure, the need for fsync or not is currently under dispute, see also:

Sorry, please ignore my comment #1 about PKGSYSTEM_ENABLE_FSYNC, it was inappropriate. Please consider the draft as-is without it.

Simple enough. +1 from me.


fesco ruled in the aforementioned ticket not to overrule upstream default behavior in f20.

updates for older fedora versions that include support for new -n option:

info EDIT: mimeinfo scriptlet update PASSED (+1:5, 0:0, -1:0)

Was brainstorming at lunch today worrying about how to simplify matters for EPEL (where the update-mime-database -n option probably will never exist, not anytime soon), and allow maintainers to avoid forking and conditionals.

Came up with this construct that would work everywhere:
update-mime-database -n %{_datadir}/mime >& /dev/null || \
update-mime-database %{_datadir}/mime >& /dev/null ||:
(line-wrapped here for legibility).

A second option could theoretically try to hide the first part in fedora via a macro if that's appealing to any fpc members, the equivalent of:
%global update_mime_database update-mime-database -n %{_datadir}/mime
%{?update_mime_database} >& /dev/null ||:
%{!?update_mime_database:update-mime-database %{_datadir}/mime } >& /dev/null ||:
This second version benefits the epel case a little in that u-m-d doesn't run twice (where the first attempt using the unknown option -n fails)

A third possibility that works (now) but is less future proof (for when/if some future rhel version supports -n), included for completeness in case anyone likes it anyway... :)
update-mime-database %{?fedora:-n} %{_datadir}/mime >& /dev/null ||:

The suggested scriptlet could do with either an added dependency or silencing:

shared-mime-info.x86_64 0:1.3-7.fc21 - u scriptlet output:
/var/tmp/rpm-tmp.4wrac3: řádek 1: touch: command not found

Good point, draft updated to account for that (properly copy-n-paste from iconcache scriptlet example), and now includes %{?fedora:-n} variant from comment 7 above.

According to Rex Dieter (and to comment 5), the suggested change was already approved FPC. However, the official wiki page is not updated yet.

What is the current status of this ticket? Can http://fedoraproject.org/wiki/Packaging:ScriptletSnippets#mimeinfo be updated?

Announcement text:

The scriptlets for calling update-mime-database when mimeinfo files are installed have been updated: https://fedoraproject.org/wiki/Packaging:ScriptletSnippets#mimeinfo

Login to comment on this ticket.