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
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",
"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",
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]=[]
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:
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:
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)
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:
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: