1 |
commit: 801f9a8a4d50baee38c8c06eaf4183e76c018e58 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Dec 16 06:44:53 2015 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Dec 16 16:18:34 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=801f9a8a |
7 |
|
8 |
repoman: use metadata.dtd from rsync tree if available (bug 567746) |
9 |
|
10 |
Search for metadata.dtd in current repository and masters, and if that |
11 |
fails then fetch it as usual. |
12 |
|
13 |
X-Gentoo-Bug: 567746 |
14 |
X-Gentoo-Bug-url: https://bugs.gentoo.org/show_bug.cgi?id=567746 |
15 |
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org> |
16 |
|
17 |
pym/repoman/_xml.py | 10 ++++++---- |
18 |
pym/repoman/checks/ebuilds/pkgmetadata.py | 6 ++++-- |
19 |
pym/repoman/scanner.py | 10 +++++++++- |
20 |
3 files changed, 19 insertions(+), 7 deletions(-) |
21 |
|
22 |
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py |
23 |
index 0acda28..43fc930 100644 |
24 |
--- a/pym/repoman/_xml.py |
25 |
+++ b/pym/repoman/_xml.py |
26 |
@@ -51,11 +51,12 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder): |
27 |
|
28 |
class XmlLint(object): |
29 |
|
30 |
- def __init__(self, options, repoman_settings): |
31 |
- self.metadata_dtd = os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd') |
32 |
+ def __init__(self, options, repoman_settings, metadata_dtd=None): |
33 |
+ self.metadata_dtd = (metadata_dtd or |
34 |
+ os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd')) |
35 |
self.options = options |
36 |
self.repoman_settings = repoman_settings |
37 |
- self._is_capable = False |
38 |
+ self._is_capable = metadata_dtd is not None |
39 |
self.binary = None |
40 |
self._check_capable() |
41 |
|
42 |
@@ -65,7 +66,8 @@ class XmlLint(object): |
43 |
self.binary = find_binary('xmllint') |
44 |
if not self.binary: |
45 |
print(red("!!! xmllint not found. Can't check metadata.xml.\n")) |
46 |
- else: |
47 |
+ self._is_capable = False |
48 |
+ elif not self._is_capable: |
49 |
if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings): |
50 |
sys.exit(1) |
51 |
# this can be problematic if xmllint changes their output |
52 |
|
53 |
diff --git a/pym/repoman/checks/ebuilds/pkgmetadata.py b/pym/repoman/checks/ebuilds/pkgmetadata.py |
54 |
index f22ef19..74fec69 100644 |
55 |
--- a/pym/repoman/checks/ebuilds/pkgmetadata.py |
56 |
+++ b/pym/repoman/checks/ebuilds/pkgmetadata.py |
57 |
@@ -40,18 +40,20 @@ from repoman._xml import _XMLParser, _MetadataTreeBuilder, XmlLint |
58 |
class PkgMetadata(object): |
59 |
'''Package metadata.xml checks''' |
60 |
|
61 |
- def __init__(self, options, qatracker, repoman_settings): |
62 |
+ def __init__(self, options, qatracker, repoman_settings, metadata_dtd=None): |
63 |
'''PkgMetadata init function |
64 |
|
65 |
@param options: ArgumentParser.parse_known_args(argv[1:]) options |
66 |
@param qatracker: QATracker instance |
67 |
@param repoman_settings: settings instance |
68 |
+ @param metadata_dtd: path of metadata.dtd |
69 |
''' |
70 |
self.options = options |
71 |
self.qatracker = qatracker |
72 |
self.repoman_settings = repoman_settings |
73 |
self.musedict = {} |
74 |
- self.xmllint = XmlLint(self.options, self.repoman_settings) |
75 |
+ self.xmllint = XmlLint(self.options, self.repoman_settings, |
76 |
+ metadata_dtd=metadata_dtd) |
77 |
|
78 |
def check(self, xpkg, checkdir, checkdirlist, repolevel): |
79 |
'''Performs the checks on the metadata.xml for the package |
80 |
|
81 |
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py |
82 |
index 9e5a313..9a87f65 100644 |
83 |
--- a/pym/repoman/scanner.py |
84 |
+++ b/pym/repoman/scanner.py |
85 |
@@ -82,6 +82,13 @@ class Scanner(object): |
86 |
portage.util.stack_lists([self.categories], incremental=1)) |
87 |
self.categories = self.repo_settings.repoman_settings.categories |
88 |
|
89 |
+ metadata_dtd = None |
90 |
+ for path in reversed(self.repo_settings.repo_config.eclass_db.porttrees): |
91 |
+ path = os.path.join(path, 'metadata/dtd/metadata.dtd') |
92 |
+ if os.path.exists(path): |
93 |
+ metadata_dtd = path |
94 |
+ break |
95 |
+ |
96 |
self.portdb = repo_settings.portdb |
97 |
self.portdb.settings = self.repo_settings.repoman_settings |
98 |
# We really only need to cache the metadata that's necessary for visibility |
99 |
@@ -201,7 +208,8 @@ class Scanner(object): |
100 |
self.status_check = VCSStatus(self.vcs_settings, self.qatracker) |
101 |
self.fetchcheck = FetchChecks( |
102 |
self.qatracker, self.repo_settings, self.portdb, self.vcs_settings) |
103 |
- self.pkgmeta = PkgMetadata(self.options, self.qatracker, self.repo_settings.repoman_settings) |
104 |
+ self.pkgmeta = PkgMetadata(self.options, self.qatracker, |
105 |
+ self.repo_settings.repoman_settings, metadata_dtd=metadata_dtd) |
106 |
self.thirdparty = ThirdPartyMirrors(self.repo_settings.repoman_settings, self.qatracker) |
107 |
self.use_flag_checks = USEFlagChecks(self.qatracker, uselist) |
108 |
self.keywordcheck = KeywordChecks(self.qatracker, self.options) |