#!/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 rpmquery --scripts -p $REPOCOP_PKG | grep update-desktop-database >/dev/null; then
            [ "$STATUS" = "skip" ] && STATUS=ok
        else
            STATUS=warn
            MESSAGE="missing %post:%update_desktopdb  %postun:%clean_desktopdb in %post/un scripts: are required to properly register mime info from MimeType= entry in .desktop files. See http://freesource.info/wiki/AltLinux/Sisyphus/devel/OsobennostiSborkiPaketov"
        fi
    fi
done
exec repocop-test-$STATUS $MESSAGE
