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 AF506198005 for ; Sat, 2 Mar 2013 03:24:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 69FA4E04D6; Sat, 2 Mar 2013 03:24:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D34A1E04D6 for ; Sat, 2 Mar 2013 03:24:05 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8BA9B33DC37 for ; Sat, 2 Mar 2013 03:24:04 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B5CBEE41E2 for ; Sat, 2 Mar 2013 03:24:01 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1362194627.02db319dd7a3c5ca3f499e70f4ab922cc3c71717.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/repoman X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 02db319dd7a3c5ca3f499e70f4ab922cc3c71717 X-VCS-Branch: master Date: Sat, 2 Mar 2013 03:24:01 +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: 48944807-0064-4a1c-8561-8b0804f07f55 X-Archives-Hash: 557ec1d95478691cd90c4e8904b9c0af commit: 02db319dd7a3c5ca3f499e70f4ab922cc3c71717 Author: Zac Medico gentoo org> AuthorDate: Sat Mar 2 03:23:47 2013 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Mar 2 03:23:47 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=02db319d repoman: check metadata.xml doctype, bug #328113 --- bin/repoman | 30 ++++++++++++++++++++++++++++-- 1 files changed, 28 insertions(+), 2 deletions(-) diff --git a/bin/repoman b/bin/repoman index a77b5de..07f0adc 100755 --- a/bin/repoman +++ b/bin/repoman @@ -508,6 +508,7 @@ suspect_virtual = { "dev-libs/libusb-compat":"virtual/libusb", } +metadata_doctype_name = 'pkgmetadata' metadata_dtd_uri = 'http://www.gentoo.org/dtd/metadata.dtd' # force refetch if the local copy creation time is older than this metadata_dtd_ctime_interval = 60 * 60 * 24 * 7 # 7 days @@ -1278,8 +1279,12 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder): Implements doctype() as required to avoid deprecation warnings with >=python-2.7. """ + def __init__(self, data): + xml.etree.ElementTree.TreeBuilder.__init__(self) + self._portage_data = data + def doctype(self, name, pubid, system): - pass + self._portage_data["DOCTYPE"] = (name, pubid, system) try: herd_base = make_herd_base(os.path.join(repoman_settings["PORTDIR"], "metadata/herds.xml")) @@ -1638,6 +1643,7 @@ for x in effective_scanlist: # metadata.xml parse check else: metadata_bad = False + xml_info = {} # read metadata.xml into memory try: @@ -1645,13 +1651,33 @@ for x in effective_scanlist: _unicode_encode(os.path.join(checkdir, "metadata.xml"), encoding=_encodings['fs'], errors='strict'), parser=xml.etree.ElementTree.XMLParser( - target=_MetadataTreeBuilder())) + target=_MetadataTreeBuilder(xml_info))) except (ExpatError, SyntaxError, EnvironmentError) as e: metadata_bad = True stats["metadata.bad"] += 1 fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, e)) del e else: + if "DOCTYPE" not in xml_info: + metadata_bad = True + stats["metadata.bad"] += 1 + fails["metadata.bad"].append("%s/metadata.xml: %s" % (x, + "DOCTYPE is missing")) + else: + doctype_name, doctype_pubid, doctype_system = \ + xml_info["DOCTYPE"] + if doctype_system != metadata_dtd_uri: + stats["metadata.bad"] += 1 + fails["metadata.bad"].append("%s/metadata.xml: " + "DOCTYPE: SYSTEM should refer to '%s', not '%s'" % + (x, metadata_dtd_uri, doctype_system)) + + if doctype_name != metadata_doctype_name: + stats["metadata.bad"] += 1 + fails["metadata.bad"].append("%s/metadata.xml: " + "DOCTYPE: name should be '%s', not '%s'" % + (x, metadata_doctype_name, doctype_name)) + # load USE flags from metadata.xml try: musedict = utilities.parse_metadata_use(_metadata_xml)