On Mon, Jun 22, 2009 at 11:45:42AM +0200, Antoine Jacoutot wrote:
> > > > Yes, except that it's less complicated, because you don't have to
> > > > touch shared-mime-infos plist when a new port that overrides some
> > > > mime infos gets imported into the tree.
> > > 
> > > My idea was to set all .xml files provided by shared-mime-info with 
> > > @comment no checksum

Which would be a lot of work; you will have to tweak the plist
whenever another port containing a mime-info .xml file (those in
share/mime/packages) is added or changed and overrides existing
mime-types.

And there's the asymmetric situation that shared-mime-info contains
the mime-type .xml files (those *generated* from the mime-info .xml,
freedesktop.org.xml in this case), but the other ports carrying
mime-info .xml's don't.

> > If I understand correctly, Kili's method means that each port
> > is responsible for its own .xml files, so they are still protected
> > by the checksums, and you don't get a bunch of files installed
> > for software you don't have.

No, my diff would stop shared-mime-info from *containing* any
generated mime-type .xml file at all.

> Ok but then you'll loose mime info on these files.
> I like to have mime info on files even when I don't have the required 
> software to handle them... no?

Of course we don't want to throw away any mime-types.

There are two options:

1. Completely rely on the mime-info files in share/mime/packages
and regenerate the other .xml files (i.e. share/mime/!(packages)/*.xml)
whenever one of the ports providing a mime-info file is added,
removed or updated. All those ports would *only* have
share/mime/packages/whatever.xml in their plist. If a port contains
mime-info file share/mime/packages/stupid.xml that overrides the
mime-type text/html in a bad way, that would mean that you get a
bad share/mime/text/html.xml.

2. Put all generated mime-type .xml files into the plists of the
corresponding ports, run update-mime-database in a temporary directory
at build time, install them in post-install: and @comment all files
already contained in shared-mime-info or other ports. But neither
include share/mime/packages/*.xml nor @exec/@unexec update-mime-database.

That would be more safe in that mime-type .xml files will never
change just because some other port tries to override stuff, but
it also means lot of work and it still doesn't stop ports from
installing some evil mime-types which don't exist in any other port.

My diff would be a better solution for 1. If you think that it's
too dangerous, take option 2, but also review any mime-info .xml
file of new or updated ports (again: that's the shit in
share/mime/packages). Every single line of it.

Heck, if someone is scared of bad things happening due to some
strange mime-type .xml files, why didn't anyone notice that even
the freedesktop.org.xml included in shared-mime-info contains
duplicate mime-type definitions?

If you want some hints of suspicious mime-type duplicates and
overrides, try run this script on /usr/local/share/mime/packages/*.xml
(lazy developers can get it from ~kili/fucking-mime-types):

#!/usr/bin/awk -f
/<mime-type[[:space:]]*type="/ {
        sub(/.*<mime-type[[:space:]]*type="/, "")
        sub(/".*/, "")
        if (f[$0])
                printf("%s: %s already defined in %s\n",
                        FILENAME, $0, f[$0])
        else
                f[$0] = FILENAME
}

Ciao,
        Kili

Reply via email to