================================ desktop-file-utils:source=0.12-4 cvc rdiff desktop-file-utils -1 /weasel.rpath.org@wgl:3-devel/0.12-4 ================================ 0.12-4 Filip Brcic (brcha@xxxxxxx) Sat Jan 9 21:43:12 2010 Automatic promote by rBuild. desktop-file.taghandler: new --- /dev/null +++ desktop-file.taghandler @@ -0,0 +99 @@ +#!/bin/bash + +if [ $# -lt 2 ]; then + echo "not enough arguments: $0 $*" >&2 + exit 1 +fi + +type="$1" +shift +action="$1" +shift + +# GNOME currently does not automatically prefer entries that include +# GNOME in their category list. Instead, it uses a "defaults.list" +# file that needs to be modified whenever desktop files are added or +# removed. +DEFAULTS_LIST=%(datadir)s/applications/defaults.list + +# KNOWN BUG: If a MimeType entry is *removed* for an application's +# desktop file, this script will not remove it. This was an intentional +# tradeoff to make the script run faster, because we doubt that many +# applications will loose functionality, and it would make an already +# slow process slower. + +update_database () +{ + %(bindir)s/update-desktop-database %(datadir)s/applications > /dev/null +} + +add_to_defaults_list () +{ + # Check for an empty or nonexisting defaults.list, and create it + # with the header if required. + if ! [ -s $DEFAULTS_LIST ] ; then + echo "[Default Applications]" > $DEFAULTS_LIST + fi + + # add appropriate references to gnome apps to the defaults.list file + for GNOME_DESKTOP_FILE in $(grep -l 'Categories.*GNOME' "$@") ; do + MIME_TYPES=$(grep '^MimeType=' $GNOME_DESKTOP_FILE | + sed 's/MimeType=//;s/;/ /g') + if [ -n "$MIME_TYPES" ] ; then + # the defaults.list file is not supposed to have complete paths + BASE_GNOME_DESKTOP_FILE=$(basename $GNOME_DESKTOP_FILE) + fi + for MIME_TYPE in $MIME_TYPES ; do + if ! grep -qs $MIME_TYPE $DEFAULTS_LIST ; then + echo "$MIME_TYPE=$BASE_GNOME_DESKTOP_FILE" >> $DEFAULTS_LIST + fi + done + done +} + +remove_from_defaults_list () +{ + # the first sed subexpression is the equivalent of basename on + # each filename, and the second subexpression just adds the \| + # between filenames + FILES="$(echo $@| sed 's,\(^\| \)[^ ]*/, ,g;s, ,\\|,g')" + # this sed removes any reference to any removed file from the list + sed -i -e "/=\\(${FILES}\\)$/d" $DEFAULTS_LIST +} + +case $type in + files) + case $action in + update) + add_to_defaults_list "$@" + update_database + ;; + remove) + remove_from_defaults_list "$@" + update_database + ;; + *) + echo "ERROR: taghandler $0 invoked for an action ($action) that is not handled" 1>&2 + exit 1 + ;; + esac + ;; + handler) + case $action in + update) + # things might have changed, start over + add_to_defaults_list "$@" + ;; + *) + echo "ERROR: taghandler $0 invoked for an action ($action) that is not handled" 1>&2 + exit 1 + ;; + esac + ;; + *) + echo "ERROR: taghandler $0 invoked for a type ($type) that is not handled" 1>&2 + exit 1 + ;; +esac + +exit 0 desktop-file-utils.recipe: new --- /dev/null +++ desktop-file-utils.recipe @@ -0,0 +34 @@ +# +# Copyright (c) 2004-2007 rPath, Inc. +# This file is distributed under the terms of the MIT License. +# A copy is available at http://www.rpath.com/permanent/mit-license.html +# + +class DesktopFileUtils(AutoPackageRecipe): + name = 'desktop-file-utils' + version = '0.12' + + # Don't add emacs as a buildreq, it will create a buildreq loop between + # emacs and desktop-files-utils. + buildRequires = [ 'glib:devel', 'popt:devel', 'pkg-config:devel' ] + + def unpack(r): + r.addArchive('http://www.freedesktop.org/software/%(name)s/releases/') + r.addSource('desktop-file.tagdescription', macros=True, + dest='%(tagdescriptiondir)s/desktop-file') + r.addSource('desktop-file.taghandler', macros=True, + dest='%(taghandlerdir)s/desktop-file', mode=0755) + + def policy(r): + # zero-length file to help conary verify... which we don't overwrite on + # update + r.Create('%(datadir)s/applications/defaults.list') + r.InitialContents('%(datadir)s/applications/defaults.list') + + # FIXME: remove when/if RPL-1077 is implemented + for req in ('%(essentialbindir)s/sed', + '%(essentialbindir)s/echo', + '%(essentialbindir)s/grep', + '%(essentialbindir)s/basename', + '/dev/null'): + r.Requires(req, '%(taghandlerdir)s/desktop-file') desktop-file.tagdescription: new --- /dev/null +++ desktop-file.tagdescription @@ -0,0 +5 @@ +file %(taghandlerdir)s/desktop-file +implements files update +implements files remove +implements handler update +include %(datadir)s/applications/ desktop-file-utils-0.12.tar.gz: new Committed by: brcha