broken shared-mime-info and MIME typing
Looking at MIME binding, I found that it is now completely broken.
We have mime.class, that provides install-time generating of the database.
shared-mime-info attempts to provide compile-time generating of the database. As it does not contain freedesktop.org.xml, any package using mime.class calling update-mime-database will remove 99% of entries in the MIME database.
Creating database during the build time is not possible yet and would require significant changes in update-mime-database (or writing a different tool):
There is no way to create /usr/share/mime/magic, subclasses, mime.cache during the build time => it must be done during installation. Note that mime.cache is a binary file.
Proposal:
- Install freedesktop.org.xml again.
- Change mime.class:
- Change scripts: First test, whether update-mime-database is installed, if yes, then call it.
- mime class should not RDEPEND on shared-mime-info (now it depends, but it is missing there and may cause installation errors)
- mime_prerm should be probably postrm => update database after package removal
- default to --disable-update-mimedb
Alternatives:
- Write update-mime-database alternative capable to build magic without freedesktop.org.xml.
- Patch update-mime-database to allow compressed packages/*.xml.
- Return to compile time and write a tool capable to create MIME database for all packages available in the feed as the part of package-index creation. It would need a special XDG_* variables settings, so applications will be able to collect magic from all repositories.
Signature · 2 lines
Stanislav Brabec http://www.penguin.cz/~utx/zaurus
Quoted 18 lines · Stanislav Brabec
Looking at MIME binding, I found that it is now completely broken.
We have mime.class, that provides install-time generating of the database.
shared-mime-info attempts to provide compile-time generating of the database. As it does not contain freedesktop.org.xml, any package using mime.class calling update-mime-database will remove 99% of entries in the MIME database.
Creating database during the build time is not possible yet and would require significant changes in update-mime-database (or writing a different tool):
There is no way to create/usr/share/mime/magic, subclasses, mime.cache during the build time => it must be done during installation. Note that mime.cache is a binary file.
Quoted 6 lines
Proposal:
- Install freedesktop.org.xml again.
- Change mime.class:
- Change scripts: First test, whether update-mime-database is installed, if yes, then call it.
Done
Quoted 2 lines
-
mime_prermshould be probably postrm => update database after package removal
Done
regards,
Koen
Quoted 20 lines · Stanislav Brabec
Looking at MIME binding, I found that it is now completely broken.
We have mime.class, that provides install-time generating of the database.
shared-mime-info attempts to provide compile-time generating of the database. As it does not contain freedesktop.org.xml, any package using mime.class calling update-mime-database will remove 99% of entries in the MIME database.
Creating database during the build time is not possible yet and would require significant changes in update-mime-database (or writing a different tool):
There is no way to create/usr/share/mime/magic, subclasses, mime.cache during the build time => it must be done during installation. Note that mime.cache is a binary file.Proposal:
Quoted 9 lines
- Install freedesktop.org.xml again.
- Change mime.class:
- Change scripts: First test, whether update-mime-database is installed, if yes, then call it.
- mime class should not RDEPEND on shared-mime-info (now it depends, but it is missing there and may cause installation errors)
-mime_prermshould be probably postrm => update database after package removal
- default to --disable-update-mimedb
The current implementation is:
* shared-mime-info does *NOT* include freedesktop.org.xml to save space
* mime.bbclass *DOES* check for /usr/bin/update-mime-info
* mime.bbclass *DOES* add rdepends to freedesktop.org.xml when needed
This means that people not needing freedesktop.org.xml don't get it installed and people that do need it get it installed automagically when using mime.bbclass
regards,
Koen
Quoted 12 lines
Alternatives:
- Write update-mime-database alternative capable to build magic without freedesktop.org.xml.
- Patch update-mime-database to allow compressed packages/*.xml.
- Return to compile time and write a tool capable to create MIME database for all packages available in the feed as the part of package-index creation. It would need a special XDG_* variables settings, so applications will be able to collect magic from all repositories.
Quoted 7 lines · Koen Kooi
* shared-mime-info does *NOT* include freedesktop.org.xml to save space
* mime.bbclass *DOES* check for/usr/bin/update-mime-info
* mime.bbclass *DOES* add rdepends to freedesktop.org.xml when neededThis means that people not needing freedesktop.org.xml don't get it installed and people that do need it get it installed automagically when using mime.bbclass
NOTE: adding mime postinst and postrm scripts to libgeda
NOTE: adding shared-mime-info dependency to libgeda
This would not work. Without freedesktop.org.xml the command "update-mime-database /usr/share/mime" will ruin the database.
I would like to propose following changes:
1. Move update-mime-database to freedesktop-mime-info.
2. RRECCOMMENDS="freedesktop-mime-info" in the class instead of RDEPENDS In fact, MIME database is required by its consumers, not packages provides XML files.
3. Implicit FILES_${PN} += "${datadir}/mime/packages"
4. Remove the warning and error in mime_.
5. shared-mime-info-locale-* should not depend on freedesktop-mime-info. It should be probably named freedesktop-mime-info-locale-*, as shared-mime-info itself does not need it.
Signature · 2 lines
Stanislav Brabec http://www.penguin.cz/~utx/zaurus
Op 4 dec 2008, om 14:09 heeft Stanislav Brabec het volgende geschreven:
Quoted 10 lines
Quoted 7 lines · Koen Kooi
* shared-mime-info does *NOT* include freedesktop.org.xml to save space
* mime.bbclass *DOES* check for/usr/bin/update-mime-info
* mime.bbclass *DOES* add rdepends to freedesktop.org.xml when neededThis means that people not needing freedesktop.org.xml don't get it installed and people that do need it get it installed automagically when using mime.bbclass
Quoted 5 lines
NOTE: adding mime postinst and postrm scripts to libgeda
NOTE: adding shared-mime-info dependency to libgedaThis would not work. Without freedesktop.org.xml the command "update-mime-database
/usr/share/mime" will ruin the database.
That does work, had you looked a bit better:
mime.bbclass does:
rdepends.append("freedesktop-mime-info")
shared-mime-info_0.51.bb does:
RDEPENDS_freedesktop-mime-info = "shared-mime-info"
So how will that *NOT* install freedesktop.org.xml?
I tested it on 2 devices and it does the right thing: freedesktop.org.xml gets installed before the update-mime-database command is run.
FWIW: this is a subscriber only list, so quit with the reply-all
Quoted 7 lines · Koen Kooi
Quoted 2 lines
This would not work. Without freedesktop.org.xml the command "update-mime-database
/usr/share/mime" will ruin the database.That does work, had you looked a bit better:
mime.bbclass does:
rdepends.append("freedesktop-mime-info")
My mistake, NOTE says different. But problem 1 is still valid for manual calling of "update-mime-database /usr/share/mime" on a system, that does not have freedesktop-mime-info.
2., 3. and 4. were just a suggestions, 5. is a minor issue.
See attached patch (untested), which should do 2., 3. and 4. Issue 5 fix is not done yet.
Quoted 3 lines
I tested it on 2 devices and it does the right thing:
freedesktop.org.xml gets installed before the update-mime-database command is run.
Yes, it works for packages. Actually users of locales will get freedesktop-mime-info automatically due to 5.
classes/mime.bbclass +5 -9
@@ -5,9 +5,6 @@ if [ "$1" = configure ]; then if [ -x ${bindir}/update-mime-database ] ; then echo "Updating MIME database... this may take a while." update-mime-database $D${datadir}/mime - else - echo "Missing ${bindir}/update-mime-database, update of mime database failed!" - exit 1 fi fi }
@@ -17,9 +14,6 @@ if [ "$1" = remove ] || [ "$1" = upgrade ]; then if [ -x ${bindir}/update-mime-database ] ; then echo "Updating MIME database... this may take a while." update-mime-database $D${datadir}/mime - else - echo "Missing ${bindir}/update-mime-database, update of mime database failed!" - exit 1 fi fi }
@@ -50,7 +44,9 @@ python populate_packages_append () { postrm += bb.data.getVar('mime_postrm', d, 1) bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d) bb.note("adding shared-mime-info dependency to %s" % pkg) - rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "") - rdepends.append("freedesktop-mime-info") - bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) + rrecommends = explode_deps(bb.data.getVar('RRECOMMENDS_' + pkg, d, 0) or bb.data.getVar('RRECOMMENDS', d, 0) or "") + rrecommends.append("freedesktop-mime-info") + bb.data.setVar('RRECOMMENDS_' + pkg, " " + " ".join(rrecommends), d) } + +FILES_${PN} += "${datadir}/mime/packages"
packages/shared-mime-info/shared-mime-info_0.51.bb +1 -1
@@ -10,6 +10,6 @@ do_install_append() { # freedesktop.org.xml is huge and only needed when updating the db # mime.bbclass will add the dependency on it automagically PACKAGES =+ "freedesktop-mime-info" -FILES_freedesktop-mime-info = "${datadir}/mime/packages/freedesktop.org.xml" +FILES_freedesktop-mime-info = "${datadir}/mime/packages/freedesktop.org.xml ${bindir}/update-mime-database" RDEPENDS_freedesktop-mime-info = "shared-mime-info"
Signature · 2 lines
Stanislav Brabec http://www.penguin.cz/~utx/zaurus
Quoted 40 lines · Stanislav Brabec
Quoted 6 lines · Koen Kooi
Quoted 2 lines
This would not work. Without freedesktop.org.xml the command "update-mime-database
/usr/share/mime" will ruin the database.That does work, had you looked a bit better:
mime.bbclass does:
rdepends.append("freedesktop-mime-info")My mistake, NOTE says different. But problem 1 is still valid for manual calling of "update-mime-database
/usr/share/mime" on a system, that does not have freedesktop-mime-info.2., 3. and 4. were just a suggestions, 5. is a minor issue.
See attached patch (untested), which should do 2., 3. and 4. Issue 5 fix is not done yet.
Quoted 3 lines
I tested it on 2 devices and it does the right thing:
freedesktop.org.xml gets installed before the update-mime-database command is run.Yes, it works for packages. Actually users of locales will get freedesktop-mime-info automatically due to 5.
classes/mime.bbclass +0
-3@@ -5,9 +5,6 @@ if [ "$1" = configure ]; then if [ -x ${bindir}/update-mime-database ] ; then echo "Updating MIME database... this may take a while." update-mime-database $D${datadir}/mime - else - echo "Missing ${bindir}/update-mime-database, update of mime database failed!" - exit 1 fi fi }
classes/mime.bbclass if [ "$1" = remove ] || [ "$1" = upgrade ]; then · line 19
Quoted 9 lines
classes/mime.bbclass +0
-3@@ -17,9 +14,6 @@ if [ "$1" = remove ] || [ "$1" = upgrade ]; then if [ -x ${bindir}/update-mime-database ] ; then echo "Updating MIME database... this may take a while." update-mime-database $D${datadir}/mime - else - echo "Missing ${bindir}/update-mime-database, update of mime database failed!" - exit 1 fi fi }
You want it to error out of u-m-d is not found, since the purpose of the postinst (updating the database) couldn't be done. Do you have a use-case for this non-error behaviour?
classes/mime.bbclass python populate_packages_append () { · line 49
Quoted 10 lines
classes/mime.bbclass +3
-3@@ -50,7 +44,9 @@ python populate_packages_append () { postrm += bb.data.getVar('mime_postrm', d, 1) bb.data.setVar('pkg_postrm_%s' % pkg, postrm, d) bb.note("adding shared-mime-info dependency to %s" % pkg) - rdepends = explode_deps(bb.data.getVar('RDEPENDS_' + pkg, d, 0) or bb.data.getVar('RDEPENDS', d, 0) or "") - rdepends.append("freedesktop-mime-info") - bb.data.setVar('RDEPENDS_' + pkg, " " + " ".join(rdepends), d) + rrecommends = explode_deps(bb.data.getVar('RRECOMMENDS_' + pkg, d, 0) or bb.data.getVar('RRECOMMENDS', d, 0) or "") + rrecommends.append("freedesktop-mime-info") + bb.data.setVar('RRECOMMENDS_' + pkg, " " + " ".join(rrecommends), d)
I'm not sure what the above accomplished, apart from making it easier to shoot yourself in the foot. What's the usecase for allowing to install the xml files, but not the update tool (assuming you applied the changes below)?
classes/mime.bbclass python populate_packages_append () { · line 52
Quoted 1 line
classes/mime.bbclass +1
-0+FILES_${PN} += "${datadir}/mime/packages"
I'm not so sure on that one, but I guess recipes can put the package theu want the xml file in before ${PN} in PACKAGES
packages/shared-mime-info/shared-mime-info_0.51.bb do_install_append() { · line 14
Quoted 11 lines
packages/shared-mime-info/shared-mime-info_0.51.bb +1
-1@@ -10,6 +10,6 @@ do_install_append() { # freedesktop.org.xml is huge and only needed when updating the db # mime.bbclass will add the dependency on it automagically PACKAGES =+ "freedesktop-mime-info" -FILES_freedesktop-mime-info = "${datadir}/mime/packages/freedesktop.org.xml" +FILES_freedesktop-mime-info = "${datadir}/mime/packages/freedesktop.org.xml ${bindir}/update-mime-database" RDEPENDS_freedesktop-mime-info = "shared-mime-info"
If you're going to package those together you should name the package 'update-mime-database' to avoid confusion when people want to install the utils and do 'opkg list | grep mime'.
regards,
Koen
Quoted 8 lines · Koen Kooi
You want it to error out of u-m-d is not found, since the purpose of the postinst (updating the database) couldn't be done. Do you have a use-case for this non-error behaviour?
I'm not sure what the above accomplished, apart from making it easier to shoot yourself in the foot. What's the usecase for allowing to install the xml files, but not the update tool (assuming you applied the changes below)?
These XML files are important for consumers (typically file managers of desktop systems), not for providers (packages providing a description for its own obscure file format).
If you want such packages installed on an image with the desktop systems that does not support shared-mime-info, you don't need shared-mime-info nor freedesktop-mime-info packages and you will save ~1MB.
During installation of shared-mime-info+freedesktop-mime-info the database will be created.
Quoted 3 lines
If you're going to package those together you should name the package 'update-mime-database' to avoid confusion when people want to install the utils and do 'opkg list | grep mime'.
Whatever name we pick, allowing to install update-mime-database installed without freedesktop.org.xml is a bad combination.
Having generated data files without both of them seems to be safe.
Signature · 2 lines
Stanislav Brabec http://www.penguin.cz/~utx/zaurus