Gentoo Archives: gentoo-portage-dev

From: Tom Wijsman <tomwij@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 1/3 v2] Have repoman check if the packages to unpack rare archive formats from SRC_URI are present in DEPEND (bug #205909).
Date: Fri, 17 Jan 2014 23:04:57
Message-Id: 1389999837-16516-1-git-send-email-tomwij@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/3] Have repoman check if the packages to unpack rare archive formats from SRC_URI are present in DEPEND (bug #205909). by Tom Wijsman
1 ---
2 bin/repoman | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++---
3 man/repoman.1 | 4 +++
4 pym/portage/eapi.py | 3 ++
5 3 files changed, 91 insertions(+), 4 deletions(-)
6
7 diff --git a/bin/repoman b/bin/repoman
8 index d1542e9..eed1024 100755
9 --- a/bin/repoman
10 +++ b/bin/repoman
11 @@ -36,6 +36,14 @@ pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
12 sys.path.insert(0, pym_path)
13 import portage
14 portage._internal_caller = True
15 +
16 +from portage._sets.profiles import PackagesSystemSet
17 +from portage import os
18 +
19 +config_root = os.environ.get("PORTAGE_CONFIGROOT")
20 +repoman_settings = portage.config(config_root=config_root, local_config=False)
21 +system_set_atoms = [atom.cp \
22 + for atom in PackagesSystemSet(repoman_settings.profiles).getAtoms()]
23 portage._disable_legacy_globals()
24
25 try:
26 @@ -53,7 +61,6 @@ except (ImportError, SystemError, RuntimeError, Exception):
27 out.eerror(line)
28 sys.exit(1)
29
30 -from portage import os
31 from portage import _encodings
32 from portage import _unicode_encode
33 import repoman.checks
34 @@ -78,7 +85,8 @@ from portage.output import ConsoleStyleFile, StyleWriter
35 from portage.util import writemsg_level
36 from portage.util._argparse import ArgumentParser
37 from portage.package.ebuild.digestgen import digestgen
38 -from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
39 +from portage.eapi import (eapi_has_iuse_defaults, eapi_has_required_use,
40 + eapi_has_xz_utils)
41
42 if sys.hexversion >= 0x3000000:
43 basestring = str
44 @@ -98,8 +106,6 @@ os.umask(0o22)
45 # behave incrementally.
46 repoman_incrementals = tuple(x for x in \
47 portage.const.INCREMENTALS if x != 'ACCEPT_KEYWORDS')
48 -config_root = os.environ.get("PORTAGE_CONFIGROOT")
49 -repoman_settings = portage.config(config_root=config_root, local_config=False)
50
51 if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \
52 repoman_settings.get('TERM') == 'dumb' or \
53 @@ -300,6 +306,7 @@ qahelp = {
54 "inherit.missing": "Ebuild uses functions from an eclass but does not inherit it",
55 "inherit.unused": "Ebuild inherits an eclass but does not use it",
56 "java.eclassesnotused": "With virtual/jdk in DEPEND you must inherit a java eclass",
57 + "unpack.DEPEND.missing": "A rare archive format was used in SRC_URI, but its package to unpack it is missing in DEPEND.",
58 "wxwidgets.eclassnotused": "Ebuild DEPENDs on x11-libs/wxGTK without inheriting wxwidgets.eclass",
59 "KEYWORDS.dropped": "Ebuilds that appear to have dropped KEYWORDS for some arch",
60 "KEYWORDS.missing": "Ebuilds that have a missing or empty KEYWORDS variable",
61 @@ -399,6 +406,7 @@ qawarnings = set((
62 "metadata.warning",
63 "portage.internal",
64 "repo.eapi.deprecated",
65 +"unpack.DEPEND.missing",
66 "usage.obsolete",
67 "upstream.workaround",
68 "LIVEVCS.stable",
69 @@ -479,6 +487,65 @@ ruby_deprecated = frozenset([
70 "ruby_targets_ree18",
71 ])
72
73 +def getNonSystemArchiveDepends(fetchlist, eapi):
74 + """
75 + Compare each SRC_URI entry against archivers; if one of the
76 + extensions match, we remember which archive depends are needed.
77 +
78 + We don't pass back dependencies that are in the system set.
79 +
80 + TODO: Add functionality to support checking for deb2targz on platforms
81 + where GNU binutils is absent; see PMS 5, section 11.3.3.13.
82 + """
83 +
84 + def addMatchingFormatsToResult(formats, result):
85 + for file_ext in formats:
86 + format = formats[file_ext]
87 +
88 + if format not in system_set_atoms:
89 + for entry in fetchlist:
90 + if file_ext.match(entry) is not None:
91 + result.add(format)
92 +
93 + result = set()
94 +
95 + addMatchingFormatsToResult(getNonSystemArchiveDepends.archivers, result)
96 +
97 + if eapi_has_xz_utils(eapi):
98 + addMatchingFormatsToResult(getNonSystemArchiveDepends.archivers_xz, result)
99 +
100 + return result
101 +
102 +getNonSystemArchiveDepends.archivers = {
103 + re.compile('.*\.7[zZ]$'):"app-arch/p7zip",
104 + re.compile('.*\.(bz2?|tbz2)$'):"app-arch/bzip2",
105 + re.compile('.*\.jar$'):"app-arch/unzip",
106 + re.compile('.*\.(LH[aA]|lha|lzh)$'):"app-arch/lha",
107 + re.compile('.*\.lzma$'):"app-arch/lzma-utils",
108 + re.compile('.*\.(rar|RAR)$'):"app-arch/unrar",
109 + re.compile('.*\.(tar(\.(bz2?|gz|Z))?|tbz2|t[bg]z)?$'):"app-arch/tar",
110 + re.compile('.*\.(gz|tar\.Z|t[bg]z|[zZ])$'):"app-arch/gzip",
111 + re.compile('.*\.(zip|ZIP)$'):"app-arch/unzip",
112 +}
113 +
114 +getNonSystemArchiveDepends.archivers_xz = {
115 + re.compile('.*\.tar.xz$'):"app-arch/tar",
116 + re.compile('.*\.xz$'):"app-arch/xz-utils",
117 +}
118 +
119 +def checkArchiveDepends(atoms, catpkg, relative_path, \
120 + system_set_atoms, needed_unpack_depends, stats, fails):
121 + """
122 + We check whether the needed archive dependencies are present in DEPEND,
123 + which were determined from SRC_URI.
124 + """
125 + for entry in needed_unpack_depends[catpkg]:
126 + if entry not in [atom.cp for atom in atoms if atom != "||"]:
127 + stats['unpack.' + mytype + '.missing'] += 1
128 + fails['unpack.' + mytype + '.missing'].append( \
129 + relative_path + ": %s is missing in %s" % \
130 + (entry, mytype))
131 +
132 metadata_xml_encoding = 'UTF-8'
133 metadata_xml_declaration = '<?xml version="1.0" encoding="%s"?>' % \
134 (metadata_xml_encoding,)
135 @@ -1559,6 +1626,7 @@ for x in effective_scanlist:
136 fetchlist_dict = portage.FetchlistDict(checkdir, repoman_settings, portdb)
137 myfiles_all = []
138 src_uri_error = False
139 + needed_unpack_depends = {}
140 for mykey in fetchlist_dict:
141 try:
142 myfiles_all.extend(fetchlist_dict[mykey])
143 @@ -1573,7 +1641,13 @@ for x in effective_scanlist:
144 stats["SRC_URI.syntax"] += 1
145 fails["SRC_URI.syntax"].append(
146 "%s.ebuild SRC_URI: %s" % (mykey, e))
147 +
148 + needed_unpack_depends[mykey] = \
149 + getNonSystemArchiveDepends(fetchlist_dict[mykey], \
150 + pkgs[y[:-7]]._metadata["EAPI"])
151 +
152 del fetchlist_dict
153 +
154 if not src_uri_error:
155 # This test can produce false positives if SRC_URI could not
156 # be parsed for one or more ebuilds. There's no point in
157 @@ -2010,6 +2084,10 @@ for x in effective_scanlist:
158 atoms = None
159 badsyntax.append(str(e))
160
161 + if atoms and buildtime:
162 + checkArchiveDepends(atoms, catpkg, relative_path, \
163 + system_set_atoms, needed_unpack_depends, stats, fails)
164 +
165 if atoms and mytype.endswith("DEPEND"):
166 if runtime and \
167 "test?" in mydepstr.split():
168 @@ -2384,6 +2462,8 @@ for x in effective_scanlist:
169 "%s/metadata.xml: unused local USE-description: '%s'" % \
170 (x, myflag))
171
172 + del needed_unpack_depends
173 +
174 if options.if_modified == "y" and len(effective_scanlist) < 1:
175 logging.warn("--if-modified is enabled, but no modified packages were found!")
176
177 diff --git a/man/repoman.1 b/man/repoman.1
178 index a78f94e..fb89610 100644
179 --- a/man/repoman.1
180 +++ b/man/repoman.1
181 @@ -334,6 +334,10 @@ Ebuild inherits a deprecated eclass
182 With virtual/jdk in DEPEND you must inherit a java eclass. Refer to
183 \fIhttp://www.gentoo.org/proj/en/java/java\-devel.xml\fR for more information.
184 .TP
185 +.B unpack.DEPEND.missing
186 +A rare archive format was used in SRC_URI, but the package to unpack it is
187 +missing from DEPEND.
188 +TP
189 .B manifest.bad
190 Manifest has missing or incorrect digests
191 .TP
192 diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
193 index 4f77910..5f8919b 100644
194 --- a/pym/portage/eapi.py
195 +++ b/pym/portage/eapi.py
196 @@ -95,6 +95,9 @@ def eapi_has_hdepend(eapi):
197 def eapi_has_targetroot(eapi):
198 return eapi in ("5-hdepend",)
199
200 +def eapi_has_xz_utils(eapi):
201 + return eapi not in ("0", "1", "2")
202 +
203 _eapi_attrs = collections.namedtuple('_eapi_attrs',
204 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
205 'feature_flag_test feature_flag_targetroot '
206 --
207 1.8.5.2

Replies