Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

File associations

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
schadfield
Posts: 12
Joined: 2006-12-20 13:39

File associations

#1 Post by schadfield »

Can someone point me in the right direction for understanding file associations for deb packages?

I develop an open source shogi analysis GUI https://github.com/schadfield/shogi-explorer which uses https://github.com/fvarrui/JavaPackager to create deb packages during the build.

My aim is to associate "kif" files with my application Shogi Explorer. The deb files include a file named ShogiExplorer.xml which appears to include the necessary configuration data but when installing the deb with dpkg ShogiExplorer.xml is not created anywhere on the file system.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
	<mime-type type="application/x-shogi-explorer">
		<comment>Shogi KIFU</comment>
		<glob pattern="*.kif" />
	</mime-type>
</mime-info>
Attachments
gdebi screenshot
gdebi screenshot

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: File associations

#2 Post by Aki »

Hello,

That mimetype configuration is a quite interesting topic and there are more than a solution. I'm not an expert in the packaging of graphic applications, but these are some references [1][2][3] I found about mimetypes configuration in Debian, for example:
[..]
For the command line
Declarations of which program handles which media type is done by placing files in /usr/lib/mime/packages/. The format of the file is described in the mailcap(5) manpage, and many examples can be found in /etc/mailcap. On recent systems, dpkg triggers from the mailcap package do all the necessary operations when packages are installed or removed. Also, information from FreeDesktop menu entry files (see below) is automatically translated to mailcap entries, so it is not necessary to have both. Media type (MIME) support in Debian is formally described in the Debian policy.
[..]
For the desktop
[..]
Programs are indirectly associated to file suffixes through the association with a file type. This is done through their .desktop file, with the MimeType entry.
[..]
create a FreeDesktop entry named by the program name plus .desktop as a suffix, and document inside what file types the program can accept. Install it in ,
The topic is addressed by Debian Policy Manual, too [4].

The screen dump from gdebi-gtk in your previous message shows that the .desktop file seems to be in the control section of the package and not in the upstream/data section of the package (where it should be).

If you analyze a package from a Debian repository as an example, you will see that the .desktop file is in the data/upstream section and it is installed in the directory named /usr/share/applications .

For example, the package "audacity" [5] configures the mimetypes and its file extensions in multiple ways.

It uses the .desktop file method creating a fine named "audacity.desktop" in /usr/share/applications :

Code: Select all

$ apt download audacity
$ dpkg -c audacity_2.4.2~dfsg0-5_amd64.deb | grep -i desktop
-rw-r--r-- root/root      2322 2021-05-26 22:26 ./usr/share/applications/audacity.desktop
It uses the appstream method (if appstream is installed) creating a file named "audacity.appdata.xml" in the directory named /usr/share/metainfo :

Code: Select all

$ apt download audacity
$ dpkg -c audacity_2.4.2~dfsg0-5_amd64.deb | grep -i appdata
-rw-r--r-- root/root      3000 2020-06-19 17:16 ./usr/share/metainfo/audacity.appdata.xml
It creates a file named "audacity" in the directory named /usr/lib/mime/packages with the association between file extensions and mimetyes:

Code: Select all

$ apt download audacity
$ dpkg -c audacity_2.4.2~dfsg0-5_amd64.deb | grep -i mime
drwxr-xr-x root/root         0 2021-05-26 22:26 ./usr/lib/mime/
drwxr-xr-x root/root         0 2021-05-26 22:26 ./usr/lib/mime/packages/
-rw-r--r-- root/root       778 2021-02-27 16:24 ./usr/lib/mime/packages/audacity
Hope that helps.

EDIT: I have realized now you opened two days ago a issue report on the packaging system you are using https://github.com/fvarrui/JavaPackager/issues/274 .

[1] https://wiki.debian.org/MIME
[2] https://wiki.debian.org/MimeTypesSupport
[3] https://wiki.debian.org/MIME/etc/mime.types
[4] https://www.debian.org/doc/debian-polic ... a-handlers
[5] https://packages.debian.org/bullseye/audacity
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

User avatar
schadfield
Posts: 12
Joined: 2006-12-20 13:39

Re: File associations

#3 Post by schadfield »

Thank you very much. The ".desktop" file is included in the Upstream data with path "/usr/share/applications" but the xml file is not. So I guess this means that it will not be created anywhere in the filesystem. I am guessing it belongs in "/usr/share/mime/packages". This seems to be simply a bug in the upstream packager application.

Aki
Global Moderator
Global Moderator
Posts: 2823
Joined: 2014-07-20 18:12
Location: Europe
Has thanked: 69 times
Been thanked: 385 times

Re: File associations

#4 Post by Aki »

Hello,
schadfield wrote: 2022-12-12 09:47 Thank you very much. The ".desktop" file is included in the Upstream data with path "/usr/share/applications" but the xml file is not. So I guess this means that it will not be created anywhere in the filesystem. I am guessing it belongs in "/usr/share/mime/packages". This seems to be simply a bug in the upstream packager application.
Yes, you are right: the xml file belongs in "/usr/share/mime/packages".

I've rebuilt the deb from your project using maven and JavaPackager with my Debian Stable (11.5).

The "kif" file extension is correctly recognized in respect to its mime type after package installation if the deb package is manually modified including the xml file so that it is installed in the directory named /usr/share/mime/packages.
⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀

Post Reply