#935426 mailcap.order entries aren't always keyed by package name

#935426#5
Date:
2019-08-22 13:25:06 UTC
From:
To:
According to the mailcap.order(5) man page,

    "The order of entries in the /etc/mailcap file can be altered by editing
     the /etc/mailcap.order file. Each line of that file specifies a package
     and an optional mime type."

This only holds true if the package adds a file to /usr/lib/mime/packages.
Many /etc/mailcap entries, however, are obtained by parsing files in
/usr/share/applications; in that case the "package" name is taken to be
the name of the .desktop file, minus the .desktop suffix. In some cases
this is different from the actual package name. Moreover, the name can
change in a package's history, resulting in surprising behaviour changes
across release upgrades if /etc/mailcap.order isn't updated to match.

The behaviour is old but became noticeable for me after upgrading from
stretch to buster. evince.desktop was renamed to org.gnome.Evince.desktop,
causing gimp to become the preferred PDF viewer. As I tried to correct
this by adding
    evince:application/pdf
to the mailcap.order file I got a warning
"Warning: package evince listed in /etc/mailcap.order does not have mailcap entries."
and no reordering of entries.

#935426#14
Date:
2024-02-10 12:01:49 UTC
From:
To:
This is still the case in bookworm.

To make 'zathura' the default PDF viewer, I have to use the line

| org.pwmt.zathura-pdf-poppler:application/pdf

in </etc/mailcap.order>.

This one:

| zathura:application/pdf

does nothing and triggers the above-mentioned warning.

#935426#19
Date:
2024-06-03 11:43:54 UTC
From:
To:
Le Thu, Aug 22, 2019 at 03:25:06PM +0200, Sergio Gelato a écrit :

Le Sat, Feb 10, 2024 at 01:01:49PM +0100, Dietrich Clauss a écrit :

Dear Sergio and Dietrich,

I just tried using dpkg-query to find with package the desktop file
belongs to.  However, this is way too slow for a script that may be run
multiple times when packages are installed or removed.

At the moment I do not see another solution than documenting the issue
better in the manual page of update-mime.

Do you have a better suggestion?

Have a nice day,

Charles Plessy

#935426#24
Date:
2024-06-03 13:13:20 UTC
From:
To:
In the short term, no. In the longer run, though, I'd propose to make
debhelper generate files in /usr/lib/mime/packages/ for any packages
that install .desktop files in /usr/share/applications/, and then
change update-mime to no longer parse the .desktop files itself (unless
explicitly told to by a command-line option, perhaps). This may require
some adjustments to Debian policy.

I haven't researched the development history of update-mime, but the
parsing of the .desktop files feels like it was added as an
afterthought and doesn't fit in very well; I would either drop it
or redesign the whole thing.