#!/bin/sh
files_exist()
{
    [ -e "$1" ]
}
STATUS=skip
MESSAGE=
for f in $REPOCOP_PKG_ROOT/usr/share/applications/*.desktop $REPOCOP_PKG_ROOT/usr/share/applications/*/*.desktop; do
    if [ -e "$f" ] && grep -i '^MimeType=' "$f" >/dev/null; then
        if grep Exec $f | egrep '%(f|u|F|U)' >/dev/null; then
            [ "$STATUS" = "skip" ] && STATUS=ok
        else
            STATUS=warn
            MESSAGE="$i: found MimeType= entry, but to handle it properly you have to declare one of %f,%F,%u,%U in Exec= entry. See http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-1.0.html#exec-variables"
        fi
    fi
done
exec repocop-test-$STATUS $MESSAGE
