Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 358065 - app-text/calibre installs wrong file type/MIME associations
Summary: app-text/calibre installs wrong file type/MIME associations
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Zac Medico
URL: http://forums.gentoo.org/viewtopic-p-...
Whiteboard:
Keywords: InVCS
: 384289 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-03-09 13:30 UTC by Janek Bevendorff
Modified: 2011-09-24 23:37 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Janek Bevendorff 2011-03-09 13:30:04 UTC
When installing calibre the .desktop files calibre-ebook-viewer.desktop and calibre-gui.desktop in /usr/share/applications contain many MIME type associations which calibre shouldn't be responsible for.

An example line looks like this:
MimeType=text/plain;application/vnd.ctc-posml;text/html;application/oebps-package+xml;text/rtf;application/pdf;application/vnd.amazon.ebook;application/x-cbz;application/x-cbr;application/octet-stream;text/fb2+xml;application/vnd.oasis.opendocument.text;application/epub+zip;application/x-mobipocket-ebook;application/xhtml+xml;

The result is that nearly all file types will now open in calibre, also file types calibre is no able to handle (e.g. application/octet-stream which applies to libraries or archive files in general. Also text/plain or text/html should not be calibre's desktop files.

A simple line such as the following would suffice:
MimeType=application/vnd.ctc-posml;text/html;application/oebps-package+xml;application/vnd.amazon.ebook;application/x-cbz;application/x-cbr;text/fb2+xml;application/epub+zip;application/x-mobipocket-ebook;

You may edit out a few more; I just removed those I know they should not be in that file.

In posted a temporary workaround for this issue in the Gentoo forums (linked above) but this should be fixed soon.

Reproducible: Always

Steps to Reproduce:
1. Install calibre
2. See how messed up your file associations are.
Comment 1 Zac Medico gentoo-dev 2011-03-09 21:38:29 UTC
Thanks, I've updated the calibre-0.7.48 ebuild to remove those mime types:

--- calibre-0.7.48.ebuild
+++ calibre-0.7.48.ebuild
@@ -159,6 +159,14 @@
 	dodir /usr/share/icons
 	mv "$HOME"/.local/share/icons/* "$D"usr/share/icons/ ||
 		die "failed to install icon files"
+
+	# Bug #358065 - Remove inappropriate mime types from *.desktop.
+	sed -e "s:application/octet-stream;::g" \
+		-e "s:text/html;::g" \
+		-e "s:text/plain;::g" \
+		-i "$HOME"/.local/share/applications/*.desktop \
+		|| die "sed failed"
+
 	domenu "$HOME"/.local/share/applications/*.desktop ||
 		die "failed to install .desktop menu files"
Comment 2 Janek Bevendorff 2011-03-09 21:56:33 UTC
(In reply to comment #1)
> Thanks, I've updated the calibre-0.7.48 ebuild to remove those mime types:
> 
> --- calibre-0.7.48.ebuild
> +++ calibre-0.7.48.ebuild
> @@ -159,6 +159,14 @@
>      dodir /usr/share/icons
>      mv "$HOME"/.local/share/icons/* "$D"usr/share/icons/ ||
>          die "failed to install icon files"
> +
> +    # Bug #358065 - Remove inappropriate mime types from *.desktop.
> +    sed -e "s:application/octet-stream;::g" \
> +        -e "s:text/html;::g" \
> +        -e "s:text/plain;::g" \
> +        -i "$HOME"/.local/share/applications/*.desktop \
> +        || die "sed failed"
> +
>      domenu "$HOME"/.local/share/applications/*.desktop ||
>          die "failed to install .desktop menu files"

You ought to add text/rtf, application/pdf and application/xhtml+xml to that list as well then it should be fine.
Comment 3 Janek Bevendorff 2011-03-09 22:00:26 UTC
And application/vnd.oasis.opendocument.text which is the open document format (used by OpenOffice/LibreOffice, file extension: .odt).
Comment 4 Zac Medico gentoo-dev 2011-03-09 22:15:48 UTC
Thanks, those are added now too.
Comment 5 Kovid Goyal 2011-05-26 17:42:41 UTC
This is the wrong fix for this issue. Since calibre handles PDF, RTF, TXT, ODT filetypes removing them from the .desktop files is broken. A desktop file is supposed to list all mimetypes that the application can handle. See http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s07.html

You need to patch xdg-utils on Gentoo to not adjust the default mimetype handlers when installing .desktop files instead.
Comment 6 Zac Medico gentoo-dev 2011-05-26 19:53:27 UTC
(In reply to comment #5)
> This is the wrong fix for this issue. Since calibre handles PDF, RTF, TXT, ODT
> filetypes removing them from the .desktop files is broken. A desktop file is
> supposed to list all mimetypes that the application can handle. See
> http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s07.html
> 
> You need to patch xdg-utils on Gentoo to not adjust the default mimetype
> handlers when installing .desktop files instead.

@freedesktop-bugs: If you guys are thinking about patching xdg-utils as suggested here, then please leave us a comment. Thanks!
Comment 7 Gilles Dartiguelongue (RETIRED) gentoo-dev 2011-05-26 20:18:21 UTC
we don't need to do that, DEs should provide a defaults.list (see gnome-session ebuild for example) if they have a preferred list of applications. xdg-utils just generates a cache and I'm pretty sure it doesn't have a default mechanism itself, it just takes the first entry corresponding the to mime in the cache.
Comment 8 Zac Medico gentoo-dev 2011-05-26 21:12:39 UTC
Thanks for the explanation. I'll go ahead and remove you from CC now.

I plan to fix the ebuild so that it doesn't filter so many mime types from the desktop files. We shouldn't need to filter anything that is likely to have a sane default defined by the DE, or anything for which it would not be insane to have calibre listed as the sole provider in /usr/share/applications/mimeinfo.cache.

I suspect that the main reason for this bug report is that one or more of calibre's desktop files used to list application/octet-stream in the MimeType field, which was somewhat insane to have listed as the sole provider in mimeinfo.cache, given that many DEs may not have a default handler for such a generic mimetype. Looking at the latest calibre desktop files, application/octet-stream is no longer listed in any of the MimeType fields. So, perhaps there's no longer any need to filter anything.
Comment 9 Zac Medico gentoo-dev 2011-09-24 16:59:57 UTC
*** Bug 384289 has been marked as a duplicate of this bug. ***
Comment 10 Roger 2011-09-24 23:37:24 UTC
Just my two cents, I absolutely hate something taking over my personal document and piping it to something else without first asking me. (See duplicate closed bug #384289)

And, even if it did ask, I'd still say no. ;-)

(Thanks Zac for notifying me of this!)