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 EC55913824B for ; Sun, 8 May 2016 21:21:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3873721C012; Sun, 8 May 2016 21:21:19 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5B58A21C074 for ; Sun, 8 May 2016 21:21:18 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1080C340BB4 for ; Sun, 8 May 2016 21:21:17 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 7F0A7856 for ; Sun, 8 May 2016 21:21:14 +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: <1462742304.5f15e81967f8dca211cbd87d8696059aeac9ada2.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/metadata/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/modules/scan/metadata/pkgmetadata.py X-VCS-Directories: pym/repoman/modules/scan/metadata/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 5f15e81967f8dca211cbd87d8696059aeac9ada2 X-VCS-Branch: repoman Date: Sun, 8 May 2016 21:21:14 +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: 8ff9aeea-5d45-4273-a1db-4f3b780a4ffb X-Archives-Hash: 6dc845a12cbe47af15ed5de8715292d2 commit: 5f15e81967f8dca211cbd87d8696059aeac9ada2 Author: Dirkjan Ochtman ochtman nl> AuthorDate: Tue May 3 06:33:47 2016 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sun May 8 21:18:24 2016 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=5f15e819 repoman/modules/.../pkgmetadata.py: Early return on metadata parse errors pym/repoman/modules/scan/metadata/pkgmetadata.py | 148 ++++++++++++----------- 1 file changed, 75 insertions(+), 73 deletions(-) diff --git a/pym/repoman/modules/scan/metadata/pkgmetadata.py b/pym/repoman/modules/scan/metadata/pkgmetadata.py index 3c1c2d0..3b48b8e 100644 --- a/pym/repoman/modules/scan/metadata/pkgmetadata.py +++ b/pym/repoman/modules/scan/metadata/pkgmetadata.py @@ -102,89 +102,91 @@ class PkgMetadata(ScanBase, USEFlagChecks): metadata_bad = True self.qatracker.add_error("metadata.bad", "%s/metadata.xml: %s" % (xpkg, e)) del e + self.muselist = frozenset(self.musedict) + return False + + if not hasattr(xml_parser, 'parser') or \ + sys.hexversion < 0x2070000 or \ + (sys.hexversion > 0x3000000 and sys.hexversion < 0x3020000): + # doctype is not parsed with python 2.6 or 3.1 + pass else: - if not hasattr(xml_parser, 'parser') or \ - sys.hexversion < 0x2070000 or \ - (sys.hexversion > 0x3000000 and sys.hexversion < 0x3020000): - # doctype is not parsed with python 2.6 or 3.1 - pass + if "XML_DECLARATION" not in xml_info: + self.qatracker.add_error( + "metadata.bad", "%s/metadata.xml: " + "xml declaration is missing on first line, " + "should be '%s'" % (xpkg, metadata_xml_declaration)) else: - if "XML_DECLARATION" not in xml_info: + xml_version, xml_encoding, xml_standalone = \ + xml_info["XML_DECLARATION"] + if xml_encoding is None or \ + xml_encoding.upper() != metadata_xml_encoding: + if xml_encoding is None: + encoding_problem = "but it is undefined" + else: + encoding_problem = "not '%s'" % xml_encoding self.qatracker.add_error( "metadata.bad", "%s/metadata.xml: " - "xml declaration is missing on first line, " - "should be '%s'" % (xpkg, metadata_xml_declaration)) - else: - xml_version, xml_encoding, xml_standalone = \ - xml_info["XML_DECLARATION"] - if xml_encoding is None or \ - xml_encoding.upper() != metadata_xml_encoding: - if xml_encoding is None: - encoding_problem = "but it is undefined" - else: - encoding_problem = "not '%s'" % xml_encoding - self.qatracker.add_error( - "metadata.bad", "%s/metadata.xml: " - "xml declaration encoding should be '%s', %s" % - (xpkg, metadata_xml_encoding, encoding_problem)) + "xml declaration encoding should be '%s', %s" % + (xpkg, metadata_xml_encoding, encoding_problem)) - if "DOCTYPE" not in xml_info: - metadata_bad = True - self.qatracker.add_error( - "metadata.bad", - "%s/metadata.xml: %s" % (xpkg, "DOCTYPE is missing")) - else: - doctype_name, doctype_system, doctype_pubid = \ - xml_info["DOCTYPE"] - if doctype_system != metadata_dtd_uri: - if doctype_system is None: - system_problem = "but it is undefined" - else: - system_problem = "not '%s'" % doctype_system - self.qatracker.add_error( - "metadata.bad", "%s/metadata.xml: " - "DOCTYPE: SYSTEM should refer to '%s', %s" % - (xpkg, metadata_dtd_uri, system_problem)) - - if doctype_name != metadata_doctype_name: - self.qatracker.add_error( - "metadata.bad", "%s/metadata.xml: " - "DOCTYPE: name should be '%s', not '%s'" % - (xpkg, metadata_doctype_name, doctype_name)) - - # load USE flags from metadata.xml - try: - self.musedict = parse_metadata_use(_metadata_xml) - except portage.exception.ParseError as e: + if "DOCTYPE" not in xml_info: metadata_bad = True self.qatracker.add_error( - "metadata.bad", "%s/metadata.xml: %s" % (xpkg, e)) + "metadata.bad", + "%s/metadata.xml: %s" % (xpkg, "DOCTYPE is missing")) else: - for atom in chain(*self.musedict.values()): - if atom is None: - continue - try: - atom = Atom(atom) - except InvalidAtom as e: + doctype_name, doctype_system, doctype_pubid = \ + xml_info["DOCTYPE"] + if doctype_system != metadata_dtd_uri: + if doctype_system is None: + system_problem = "but it is undefined" + else: + system_problem = "not '%s'" % doctype_system + self.qatracker.add_error( + "metadata.bad", "%s/metadata.xml: " + "DOCTYPE: SYSTEM should refer to '%s', %s" % + (xpkg, metadata_dtd_uri, system_problem)) + + if doctype_name != metadata_doctype_name: + self.qatracker.add_error( + "metadata.bad", "%s/metadata.xml: " + "DOCTYPE: name should be '%s', not '%s'" % + (xpkg, metadata_doctype_name, doctype_name)) + + # load USE flags from metadata.xml + try: + self.musedict = parse_metadata_use(_metadata_xml) + except portage.exception.ParseError as e: + metadata_bad = True + self.qatracker.add_error( + "metadata.bad", "%s/metadata.xml: %s" % (xpkg, e)) + else: + for atom in chain(*self.musedict.values()): + if atom is None: + continue + try: + atom = Atom(atom) + except InvalidAtom as e: + self.qatracker.add_error( + "metadata.bad", + "%s/metadata.xml: Invalid atom: %s" % (xpkg, e)) + else: + if atom.cp != xpkg: self.qatracker.add_error( "metadata.bad", - "%s/metadata.xml: Invalid atom: %s" % (xpkg, e)) - else: - if atom.cp != xpkg: - self.qatracker.add_error( - "metadata.bad", - "%s/metadata.xml: Atom contains " - "unexpected cat/pn: %s" % (xpkg, atom)) - - # Run other metadata.xml checkers - try: - check_metadata(_metadata_xml, get_herd_base( - self.repoman_settings)) - except (UnknownHerdsError, ) as e: - metadata_bad = True - self.qatracker.add_error( - "metadata.bad", "%s/metadata.xml: %s" % (xpkg, e)) - del e + "%s/metadata.xml: Atom contains " + "unexpected cat/pn: %s" % (xpkg, atom)) + + # Run other metadata.xml checkers + try: + check_metadata(_metadata_xml, get_herd_base( + self.repoman_settings)) + except (UnknownHerdsError, ) as e: + metadata_bad = True + self.qatracker.add_error( + "metadata.bad", "%s/metadata.xml: %s" % (xpkg, e)) + del e # Only carry out if in package directory or check forced if not metadata_bad: