From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 6D8981393E9 for ; Fri, 30 May 2014 13:03:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BFE7FE0885; Fri, 30 May 2014 13:03:34 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 200ADE0885 for ; Fri, 30 May 2014 13:03:33 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E91C033FDA9 for ; Fri, 30 May 2014 13:03:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 98467182D3 for ; Fri, 30 May 2014 13:03:31 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1401211879.71f8e844940eba8ba73d833e9e786a7ea65f2bfd.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/ebuild.py pym/repoman/main.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 71f8e844940eba8ba73d833e9e786a7ea65f2bfd X-VCS-Branch: repoman Date: Fri, 30 May 2014 13:03:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 544af4af-c1e0-4363-a650-d6e91203b589 X-Archives-Hash: d53809a5faa45b5029641fb8cf0ac939 commit: 71f8e844940eba8ba73d833e9e786a7ea65f2bfd Author: Brian Dolbec gentoo org> AuthorDate: Tue May 27 17:31:19 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Tue May 27 17:31:19 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=71f8e844 repoman/main.py: Create ebuild.py and Ebuild class This moves all relavent data to a class for a common access point. It also adds an untracked function. --- pym/repoman/ebuild.py | 30 ++++++++++++++++++ pym/repoman/main.py | 88 ++++++++++++++++++++++++--------------------------- 2 files changed, 71 insertions(+), 47 deletions(-) diff --git a/pym/repoman/ebuild.py b/pym/repoman/ebuild.py new file mode 100644 index 0000000..fbe25a9 --- /dev/null +++ b/pym/repoman/ebuild.py @@ -0,0 +1,30 @@ + + +from portage import os + + +class Ebuild(object): + '''Class to run primary checks on ebuilds''' + + def __init__(self, repo_settings, repolevel, pkgdir, catdir, vcs_settings, x, y): + self.vcs_settings = vcs_settings + self.relative_path = os.path.join(x, y + ".ebuild") + self.full_path = os.path.join(repo_settings.repodir, self.relative_path) + self.ebuild_path = y + ".ebuild" + if repolevel < 3: + self.ebuild_path = os.path.join(pkgdir, self.ebuild_path) + if repolevel < 2: + self.ebuild_path = os.path.join(catdir, self.ebuild_path) + self.ebuild_path = os.path.join(".", self.ebuild_path) + + + def untracked(self, check_ebuild_notadded, y, eadded): + do_check = self.vcs_settings.vcs in ("cvs", "svn", "bzr") + really_notadded = check_ebuild_notadded and y not in eadded + + if do_check and really_notadded: + # ebuild not added to vcs + return True + return False + + diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 158323e..9e2ba76 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -67,6 +67,7 @@ from repoman.argparser import parse_args from repoman.checks.ebuilds.checks import run_checks, checks_init from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors from repoman.checks.herds.herdbase import make_herd_base +from repoman.ebuild import Ebuild from repoman.errors import err from repoman.metadata import (metadata_xml_encoding, metadata_doctype_name, metadata_dtd_uri, metadata_xml_declaration) @@ -806,22 +807,16 @@ for x in effective_scanlist: used_useflags = set() for y in ebuildlist: - relative_path = os.path.join(x, y + ".ebuild") - full_path = os.path.join(repo_settings.repodir, relative_path) - ebuild_path = y + ".ebuild" - if repolevel < 3: - ebuild_path = os.path.join(pkgdir, ebuild_path) - if repolevel < 2: - ebuild_path = os.path.join(catdir, ebuild_path) - ebuild_path = os.path.join(".", ebuild_path) +################## + ebuild = Ebuild(repo_settings, repolevel, pkgdir, catdir, vcs_settings, x, y) +################## + if check_changelog and not changelog_modified \ - and ebuild_path in changed.new_ebuilds: + and ebuild.ebuild_path in changed.new_ebuilds: stats['changelog.ebuildadded'] += 1 - fails['changelog.ebuildadded'].append(relative_path) + fails['changelog.ebuildadded'].append(ebuild.relative_path) - vcs_settings.vcs_is_cvs_or_svn_or_bzr = vcs_settings.vcs in ("cvs", "svn", "bzr") - check_ebuild_really_notadded = check_ebuild_notadded and y not in eadded - if vcs_settings.vcs_is_cvs_or_svn_or_bzr and check_ebuild_really_notadded: + if ebuild.untracked(check_ebuild_notadded, y, eadded): # ebuild not added to vcs stats["ebuild.notadded"] += 1 fails["ebuild.notadded"].append(x + "/" + y + ".ebuild") @@ -850,7 +845,7 @@ for x in effective_scanlist: for k, msgs in pkg.invalid.items(): for msg in msgs: stats[k] += 1 - fails[k].append("%s: %s" % (relative_path, msg)) + fails[k].append("%s: %s" % (ebuild.relative_path, msg)) continue myaux = pkg._metadata @@ -861,12 +856,12 @@ for x in effective_scanlist: if repo_settings.repo_config.eapi_is_banned(eapi): stats["repo.eapi.banned"] += 1 fails["repo.eapi.banned"].append( - "%s: %s" % (relative_path, eapi)) + "%s: %s" % (ebuild.relative_path, eapi)) elif repo_settings.repo_config.eapi_is_deprecated(eapi): stats["repo.eapi.deprecated"] += 1 fails["repo.eapi.deprecated"].append( - "%s: %s" % (relative_path, eapi)) + "%s: %s" % (ebuild.relative_path, eapi)) for k, v in myaux.items(): if not isinstance(v, basestring): @@ -877,18 +872,18 @@ for x in effective_scanlist: fails["variable.invalidchar"].append( "%s: %s variable contains non-ASCII " "character at position %s" % - (relative_path, k, m.start() + 1)) + (ebuild.relative_path, k, m.start() + 1)) if not src_uri_error: ####################### thirdparty = ThirdPartyMirrors(repoman_settings) - thirdparty.check(myaux, relative_path) + thirdparty.check(myaux, ebuild.relative_path) stats["SRC_URI.mirror"] = thirdparty.stats fails["SRC_URI.mirror"] = thirdparty.fails ####################### if myaux.get("PROVIDE"): stats["virtual.oldstyle"] += 1 - fails["virtual.oldstyle"].append(relative_path) + fails["virtual.oldstyle"].append(ebuild.relative_path) for pos, missing_var in enumerate(missingvars): if not myaux.get(missing_var): @@ -906,20 +901,20 @@ for x in effective_scanlist: if myaux.get(var): myqakey = var + ".virtual" stats[myqakey] += 1 - fails[myqakey].append(relative_path) + fails[myqakey].append(ebuild.relative_path) if myaux['DESCRIPTION'][-1:] in ['.']: stats['DESCRIPTION.punctuation'] += 1 fails['DESCRIPTION.punctuation'].append( "%s: DESCRIPTION ends with a '%s' character" - % (relative_path, myaux['DESCRIPTION'][-1:])) + % (ebuild.relative_path, myaux['DESCRIPTION'][-1:])) # 14 is the length of DESCRIPTION="" if len(myaux['DESCRIPTION']) > max_desc_len: stats['DESCRIPTION.toolong'] += 1 fails['DESCRIPTION.toolong'].append( "%s: DESCRIPTION is %d characters (max %d)" % - (relative_path, len(myaux['DESCRIPTION']), max_desc_len)) + (ebuild.relative_path, len(myaux['DESCRIPTION']), max_desc_len)) keywords = myaux["KEYWORDS"].split() stable_keywords = [] @@ -928,7 +923,7 @@ for x in effective_scanlist: not keyword.startswith("-"): stable_keywords.append(keyword) if stable_keywords: - if ebuild_path in changed.new_ebuilds and catdir != "virtual": + if ebuild.ebuild_path in changed.new_ebuilds and catdir != "virtual": stable_keywords.sort() stats["KEYWORDS.stable"] += 1 fails["KEYWORDS.stable"].append( @@ -947,7 +942,7 @@ for x in effective_scanlist: stats["KEYWORDS.dropped"] += 1 fails["KEYWORDS.dropped"].append( "%s: %s" % - (relative_path, " ".join(sorted(dropped_keywords)))) + (ebuild.relative_path, " ".join(sorted(dropped_keywords)))) slot_keywords[pkg.slot].update(ebuild_archs) @@ -984,7 +979,7 @@ for x in effective_scanlist: if keywords and not has_global_mask(pkg): stats["LIVEVCS.unmasked"] += 1 - fails["LIVEVCS.unmasked"].append(relative_path) + fails["LIVEVCS.unmasked"].append(ebuild.relative_path) if options.ignore_arches: arches = [[ @@ -1054,7 +1049,7 @@ for x in effective_scanlist: stats[mytype + '.suspect'] += 1 fails[mytype + '.suspect'].append( "%s: 'test?' USE conditional in %s" % - (relative_path, mytype)) + (ebuild.relative_path, mytype)) for atom in atoms: if atom == "||": @@ -1075,7 +1070,7 @@ for x in effective_scanlist: atom.cp in suspect_virtual: stats['virtual.suspect'] += 1 fails['virtual.suspect'].append( - relative_path + + ebuild.relative_path + ": %s: consider using '%s' instead of '%s'" % (mytype, suspect_virtual[atom.cp], atom)) @@ -1084,7 +1079,7 @@ for x in effective_scanlist: not inherited_java_eclass and \ atom.cp == "virtual/jdk": stats['java.eclassesnotused'] += 1 - fails['java.eclassesnotused'].append(relative_path) + fails['java.eclassesnotused'].append(ebuild.relative_path) elif buildtime and \ not is_blocker and \ not inherited_wxwidgets_eclass and \ @@ -1092,13 +1087,13 @@ for x in effective_scanlist: stats['wxwidgets.eclassnotused'] += 1 fails['wxwidgets.eclassnotused'].append( "%s: %ss on x11-libs/wxGTK without inheriting" - " wxwidgets.eclass" % (relative_path, mytype)) + " wxwidgets.eclass" % (ebuild.relative_path, mytype)) elif runtime: if not is_blocker and \ atom.cp in suspect_rdepend: stats[mytype + '.suspect'] += 1 fails[mytype + '.suspect'].append( - relative_path + ": '%s'" % atom) + ebuild.relative_path + ": '%s'" % atom) if atom.operator == "~" and \ portage.versions.catpkgsplit(atom.cpv)[3] != "r0": @@ -1107,7 +1102,7 @@ for x in effective_scanlist: fails[qacat].append( "%s: %s uses the ~ operator" " with a non-zero revision: '%s'" % - (relative_path, mytype, atom)) + (ebuild.relative_path, mytype, atom)) type_list.extend([mytype] * (len(badsyntax) - len(type_list))) @@ -1117,7 +1112,7 @@ for x in effective_scanlist: else: qacat = m + ".syntax" stats[qacat] += 1 - fails[qacat].append("%s: %s: %s" % (relative_path, m, b)) + fails[qacat].append("%s: %s: %s" % (ebuild.relative_path, m, b)) badlicsyntax = len([z for z in type_list if z == "LICENSE"]) badprovsyntax = len([z for z in type_list if z == "PROVIDE"]) @@ -1147,7 +1142,7 @@ for x in effective_scanlist: fails['EAPI.incompatible'].append( "%s: IUSE defaults" " not supported with EAPI='%s': '%s'" % - (relative_path, eapi, myflag)) + (ebuild.relative_path, eapi, myflag)) for mypos in range(len(myuse)): stats["IUSE.invalid"] += 1 @@ -1163,7 +1158,7 @@ for x in effective_scanlist: for myruby in ruby_intersection: stats["IUSE.rubydeprecated"] += 1 fails["IUSE.rubydeprecated"].append( - (relative_path + ": Deprecated ruby target: %s") % myruby) + (ebuild.relative_path + ": Deprecated ruby target: %s") % myruby) # license checks if not badlicsyntax: @@ -1180,7 +1175,7 @@ for x in effective_scanlist: fails["LICENSE.invalid"].append(x + "/" + y + ".ebuild: %s" % lic) elif lic in liclist_deprecated: stats["LICENSE.deprecated"] += 1 - fails["LICENSE.deprecated"].append("%s: %s" % (relative_path, lic)) + fails["LICENSE.deprecated"].append("%s: %s" % (ebuild.relative_path, lic)) # keyword checks myuse = myaux["KEYWORDS"].split() @@ -1208,7 +1203,7 @@ for x in effective_scanlist: except portage.exception.InvalidDependString as e: stats["RESTRICT.syntax"] += 1 fails["RESTRICT.syntax"].append( - "%s: RESTRICT: %s" % (relative_path, e)) + "%s: RESTRICT: %s" % (ebuild.relative_path, e)) del e if myrestrict: myrestrict = set(myrestrict) @@ -1224,33 +1219,32 @@ for x in effective_scanlist: stats['EAPI.incompatible'] += 1 fails['EAPI.incompatible'].append( "%s: REQUIRED_USE" - " not supported with EAPI='%s'" % (relative_path, eapi,)) + " not supported with EAPI='%s'" % (ebuild.relative_path, eapi,)) try: portage.dep.check_required_use( required_use, (), pkg.iuse.is_valid_flag, eapi=eapi) except portage.exception.InvalidDependString as e: stats["REQUIRED_USE.syntax"] += 1 fails["REQUIRED_USE.syntax"].append( - "%s: REQUIRED_USE: %s" % (relative_path, e)) + "%s: REQUIRED_USE: %s" % (ebuild.relative_path, e)) del e # Syntax Checks - relative_path = os.path.join(x, y + ".ebuild") - full_path = os.path.join(repo_settings.repodir, relative_path) + if not vcs_settings.vcs_preserves_mtime: - if ebuild_path not in changed.new_ebuilds and \ - ebuild_path not in changed.ebuilds: + if ebuild.ebuild_path not in changed.new_ebuilds and \ + ebuild.ebuild_path not in changed.ebuilds: pkg.mtime = None try: # All ebuilds should have utf_8 encoding. f = io.open( _unicode_encode( - full_path, encoding=_encodings['fs'], errors='strict'), + ebuild.full_path, encoding=_encodings['fs'], errors='strict'), mode='r', encoding=_encodings['repo.content']) try: for check_name, e in run_checks(f, pkg): stats[check_name] += 1 - fails[check_name].append(relative_path + ': %s' % e) + fails[check_name].append(ebuild.relative_path + ': %s' % e) finally: f.close() except UnicodeDecodeError: @@ -1410,13 +1404,13 @@ for x in effective_scanlist: stats[mykey] += 1 fails[mykey].append( "%s: %s: %s(%s) %s" % ( - relative_path, mytype, keyword, prof, + ebuild.relative_path, mytype, keyword, prof, repr(atoms))) else: stats[mykey] += 1 fails[mykey].append( "%s: %s: %s(%s) %s" % ( - relative_path, mytype, keyword, prof, + ebuild.relative_path, mytype, keyword, prof, repr(atoms))) if not baddepsyntax and unknown_pkgs: @@ -1427,7 +1421,7 @@ for x in effective_scanlist: stats["dependency.unknown"] += 1 fails["dependency.unknown"].append( "%s: %s: %s" % ( - relative_path, mytype, ", ".join(sorted(atoms)))) + ebuild.relative_path, mytype, ", ".join(sorted(atoms)))) # check if there are unused local USE-descriptions in metadata.xml # (unless there are any invalids, to avoid noise)