Only validate .desktop files that are installed into XDG-compliant locations.
authorMichael Palimaka <kensington@gentoo.org>
Tue, 11 Sep 2012 17:22:05 +0000 (03:22 +1000)
committerZac Medico <zmedico@gentoo.org>
Tue, 11 Sep 2012 17:46:57 +0000 (10:46 -0700)
This replaces the existing error blacklist, and therefore removes the repoman check.

bin/repoman
pym/portage/package/ebuild/doebuild.py
pym/portage/util/_desktop_entry.py

index 53d138c8d12c881e5e5873df12b2763f523fc860..bc2ac9be6505435f238f11a3e4c7868c3ec33554 100755 (executable)
@@ -78,7 +78,6 @@ from portage.output import bold, create_color_func, \
        green, nocolor, red
 from portage.output import ConsoleStyleFile, StyleWriter
 from portage.util import writemsg_level
-from portage.util._desktop_entry import validate_desktop_entry
 from portage.package.ebuild.digestgen import digestgen
 from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
 
@@ -303,7 +302,6 @@ def ParseArgs(argv, qahelp):
 
 qahelp={
        "CVS/Entries.IO_error":"Attempting to commit, and an IO error was encountered access the Entries file",
-       "desktop.invalid":"desktop-file-validate reports errors in a *.desktop file",
        "ebuild.invalidname":"Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)",
        "ebuild.namenomatch":"Ebuild files that do not have the same name as their parent directory",
        "changelog.ebuildadded":"An ebuild was added but the ChangeLog was not modified",
@@ -406,7 +404,6 @@ qawarnings = set((
 "digest.unused",
 "ebuild.notadded",
 "ebuild.nesteddie",
-"desktop.invalid",
 "DEPEND.badmasked","RDEPEND.badmasked","PDEPEND.badmasked",
 "DEPEND.badindev","RDEPEND.badindev","PDEPEND.badindev",
 "DEPEND.badmaskedindev","RDEPEND.badmaskedindev","PDEPEND.badmaskedindev",
@@ -1054,10 +1051,6 @@ dev_keywords = dev_keywords(profiles)
 stats={}
 fails={}
 
-# provided by the desktop-file-utils package
-desktop_file_validate = find_binary("desktop-file-validate")
-desktop_pattern = re.compile(r'.*\.desktop$')
-
 for x in qacats:
        stats[x]=0
        fails[x]=[]
@@ -1630,23 +1623,6 @@ for x in effective_scanlist:
                                stats["file.name"] += 1
                                fails["file.name"].append("%s/files/%s: char '%s'" % \
                                        (checkdir, y, m.group(0)))
-
-                       if desktop_file_validate and desktop_pattern.match(y):
-                               cmd_output = validate_desktop_entry(full_path)
-                               if cmd_output:
-                                       # Note: in the future we may want to grab the
-                                       # warnings in addition to the errors. We're
-                                       # just doing errors now since we don't want
-                                       # to generate too much noise at first.
-                                       error_re = re.compile(r'.*\s*error:\s*(.*)')
-                                       for line in cmd_output:
-                                               error_match = error_re.match(line)
-                                               if error_match is None:
-                                                       continue
-                                               stats["desktop.invalid"] += 1
-                                               fails["desktop.invalid"].append(
-                                                       relative_path + ': %s' % error_match.group(1))
-
        del mydigests
 
        if check_changelog and "ChangeLog" not in checkdirlist:
index 471a5daebdd4efcfda76ca368b650b113352e5f4..a6426eed595b3607815c1b6521becac1ce00d64a 100644 (file)
@@ -1773,6 +1773,9 @@ def _post_src_install_uid_fix(mysettings, out):
        unicode_errors = []
        desktop_file_validate = \
                portage.process.find_binary("desktop-file-validate") is not None
+       xdg_dirs = mysettings.get('XDG_DATA_DIRS', '/usr/share').split(':')
+       xdg_dirs = tuple(os.path.join(i, "applications") + os.sep
+               for i in xdg_dirs if i)
 
        while True:
 
@@ -1821,7 +1824,9 @@ def _post_src_install_uid_fix(mysettings, out):
                                        fpath = os.path.join(parent, fname)
 
                                if desktop_file_validate and fname.endswith(".desktop") and \
-                                       os.path.isfile(fpath):
+                                       os.path.isfile(fpath) and \
+                                       fpath[ed_len - 1:].startswith(xdg_dirs):
+
                                        desktop_validate = validate_desktop_entry(fpath)
                                        if desktop_validate:
                                                desktopfile_errors.extend(desktop_validate)
index aa730ded323d65b9378b29d19fdd3a94ce4c3315..2973d12fffd0405f1ecbaa34252fe9e914157dd0 100644 (file)
@@ -42,20 +42,6 @@ def parse_desktop_entry(path):
        return parser
 
 _trivial_warnings = re.compile(r' looks redundant with value ')
-_ignore_kde_key_re = re.compile(r'^\s*(configurationType\s*=|Type\s*=\s*Service)')
-_ignore_kde_types = frozenset(
-       ["AkonadiAgent", "AkonadiResource", "Service", "ServiceType", "XSession"])
-
-# kdebase-data installs files with [Currency Code] sections
-# in /usr/share/locale/currency
-# kdepim-runtime installs files with [Plugin] and [Wizard]
-# sections in /usr/share/apps/akonadi/{plugins,accountwizard}
-# kdm installs files with [KCM Locale], [KDE Desktop Pattern],
-# [KdmGreeterTheme] and [Wallpaper] sections in various directories
-# libkdegames installs files with [KDE Backdeck] sections in
-# /usr/share/apps/carddecks/
-# Various KDE games install files with [KGameTheme] sections
-_ignore_kde_sections = ("Currency Code", "KCM Locale", "KDE Backdeck", "KDE Desktop Pattern", "KDE Desktop Program", "KdmGreeterTheme", "KGameTheme", "Plugin", "Wallpaper", "Wizard")
 
 _ignored_errors = (
                # Ignore error for emacs.desktop:
@@ -73,49 +59,12 @@ def validate_desktop_entry(path):
        output_lines = _unicode_decode(proc.communicate()[0]).splitlines()
        proc.wait()
 
-       if output_lines:
-               # Ignore kde extensions for bug #414125 and bug #432862.
-               try:
-                       desktop_entry = parse_desktop_entry(path)
-               except ConfigParserError:
-                       with io.open(_unicode_encode(path,
-                               encoding=_encodings['fs'], errors='strict'),
-                               mode='r', encoding=_encodings['repo.content'],
-                               errors='replace') as f:
-                               for line in f:
-                                       if _ignore_kde_key_re.match(line):
-                                               # Ignore kde extensions for bug #432862.
-                                               del output_lines[:]
-                                               break
-               else:
-                       if desktop_entry.has_section("Desktop Entry"):
-                               try:
-                                       entry_type = desktop_entry.get("Desktop Entry", "Type")
-                               except ConfigParserError:
-                                       pass
-                               else:
-                                       if entry_type in _ignore_kde_types:
-                                               del output_lines[:]
-                               try:
-                                       desktop_entry.get("Desktop Entry", "Hidden")
-                               except ConfigParserError:
-                                       pass
-                               else:
-                                       # The "Hidden" key appears to be unique to special kde
-                                       # service files (which don't validate well), installed
-                                       # in /usr/share/kde4/services/ by packages like
-                                       # nepomuk-core and kurifilter-plugins.
-                                       del output_lines[:]
-                       for section in _ignore_kde_sections:
-                               if desktop_entry.has_section(section):
-                                       del output_lines[:]
-
        if output_lines:
                filtered_output = []
                for line in output_lines:
-                               if line[len(path)+2:] in _ignored_errors:
-                                       continue
-                               filtered_output.append(line)
+                       if line[len(path)+2:] in _ignored_errors:
+                               continue
+                       filtered_output.append(line)
                output_lines = filtered_output
 
        if output_lines: