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] Have repoman check if the packages to unpack rare archive formats from SRC_URI are present in DEPEND (bug #205909).
Date: Thu, 16 Jan 2014 00:08:38
Message-Id: 1389830840-25848-2-git-send-email-tomwij@gentoo.org
In Reply to: [gentoo-portage-dev] Repoman patches for bugs #205909, #245305 and #482084. by Tom Wijsman
1 ---
2 bin/repoman | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 man/repoman.1 | 4 ++++
4 2 files changed, 57 insertions(+)
5
6 diff --git a/bin/repoman b/bin/repoman
7 index d1542e9..9b703dc 100755
8 --- a/bin/repoman
9 +++ b/bin/repoman
10 @@ -36,6 +36,9 @@ pym_path = osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
11 sys.path.insert(0, pym_path)
12 import portage
13 portage._internal_caller = True
14 +
15 +from portage._sets.profiles import PackagesSystemSet
16 +system_set_atoms = PackagesSystemSet(portage.settings.profiles).getAtoms()
17 portage._disable_legacy_globals()
18
19 try:
20 @@ -300,6 +303,7 @@ qahelp = {
21 "inherit.missing": "Ebuild uses functions from an eclass but does not inherit it",
22 "inherit.unused": "Ebuild inherits an eclass but does not use it",
23 "java.eclassesnotused": "With virtual/jdk in DEPEND you must inherit a java eclass",
24 + "unpack.DEPEND.missing": "A rare archive format was used in SRC_URI, but its package to unpack it is missing in DEPEND.",
25 "wxwidgets.eclassnotused": "Ebuild DEPENDs on x11-libs/wxGTK without inheriting wxwidgets.eclass",
26 "KEYWORDS.dropped": "Ebuilds that appear to have dropped KEYWORDS for some arch",
27 "KEYWORDS.missing": "Ebuilds that have a missing or empty KEYWORDS variable",
28 @@ -399,6 +403,7 @@ qawarnings = set((
29 "metadata.warning",
30 "portage.internal",
31 "repo.eapi.deprecated",
32 +"unpack.DEPEND.missing",
33 "usage.obsolete",
34 "upstream.workaround",
35 "LIVEVCS.stable",
36 @@ -479,6 +484,25 @@ ruby_deprecated = frozenset([
37 "ruby_targets_ree18",
38 ])
39
40 +# TODO: Add functionality to support checking for deb2targz on platforms where
41 +# GNU binutils is absent; see PMS 5, section 11.3.3.13.
42 +archive_formats = {
43 + "\.7[zZ]":"app-arch/p7zip",
44 + "\.(bz2?|tbz2)":"app-arch/bzip2",
45 + "\.jar":"app-arch/unzip",
46 + "\.(LH[aA]|lha|lzh)":"app-arch/lha",
47 + "\.lzma":"app-arch/lzma-utils",
48 + "\.(rar|RAR)":"app-arch/unrar",
49 + "\.(tar(\.(bz2?|gz|Z))?|tbz2|t[bg]z)?":"app-arch/tar",
50 + "\.(gz|tar\.Z|t[bg]z|[zZ])":"app-arch/gzip",
51 + "\.(zip|ZIP)":"app-arch/unzip",
52 +}
53 +
54 +archive_formats_eapi_3_to_5 = {
55 + "\.tar.xz":"app-arch/tar",
56 + "\.xz":"app-arch/xz-utils",
57 +}
58 +
59 metadata_xml_encoding = 'UTF-8'
60 metadata_xml_declaration = '<?xml version="1.0" encoding="%s"?>' % \
61 (metadata_xml_encoding,)
62 @@ -1559,6 +1583,7 @@ for x in effective_scanlist:
63 fetchlist_dict = portage.FetchlistDict(checkdir, repoman_settings, portdb)
64 myfiles_all = []
65 src_uri_error = False
66 + needed_unpack_depends = {}
67 for mykey in fetchlist_dict:
68 try:
69 myfiles_all.extend(fetchlist_dict[mykey])
70 @@ -1573,7 +1598,22 @@ for x in effective_scanlist:
71 stats["SRC_URI.syntax"] += 1
72 fails["SRC_URI.syntax"].append(
73 "%s.ebuild SRC_URI: %s" % (mykey, e))
74 +
75 + # Compare each SRC_URI entry against archive_formats; if one of the
76 + # extensions match, we remember which archive depends are needed to
77 + # check them later on.
78 + needed_unpack_depends[mykey] = []
79 + for file_extension in archive_formats or \
80 + ((re.match('[345]$', eapi) is not None) \
81 + and file_extension in archive_formats_eapi_3_to_5):
82 + for entry in fetchlist_dict[mykey]:
83 + if re.match('.*%s$' % file_extension, entry) is not None:
84 + format = archive_formats[file_extension]
85 +
86 + if format not in needed_unpack_depends[mykey]:
87 + needed_unpack_depends[mykey].append(format)
88 del fetchlist_dict
89 +
90 if not src_uri_error:
91 # This test can produce false positives if SRC_URI could not
92 # be parsed for one or more ebuilds. There's no point in
93 @@ -2010,6 +2050,17 @@ for x in effective_scanlist:
94 atoms = None
95 badsyntax.append(str(e))
96
97 + if atoms and mytype == 'DEPEND':
98 + # We check whether the needed archive dependencies are present
99 + # in DEPEND, which were determined from SRC_URI.
100 + for entry in needed_unpack_depends[catdir + '/' + y]:
101 + if entry not in system_set_atoms and entry \
102 + not in [atom.cp for atom in atoms if atom != "||"]:
103 + stats['unpack.' + mytype + '.missing'] += 1
104 + fails['unpack.' + mytype + '.missing'].append( \
105 + relative_path + ": %s is missing in %s" % \
106 + (entry, mytype))
107 +
108 if atoms and mytype.endswith("DEPEND"):
109 if runtime and \
110 "test?" in mydepstr.split():
111 @@ -2384,6 +2435,8 @@ for x in effective_scanlist:
112 "%s/metadata.xml: unused local USE-description: '%s'" % \
113 (x, myflag))
114
115 + del needed_unpack_depends
116 +
117 if options.if_modified == "y" and len(effective_scanlist) < 1:
118 logging.warn("--if-modified is enabled, but no modified packages were found!")
119
120 diff --git a/man/repoman.1 b/man/repoman.1
121 index a78f94e..e739d56 100644
122 --- a/man/repoman.1
123 +++ b/man/repoman.1
124 @@ -334,6 +334,10 @@ Ebuild inherits a deprecated eclass
125 With virtual/jdk in DEPEND you must inherit a java eclass. Refer to
126 \fIhttp://www.gentoo.org/proj/en/java/java\-devel.xml\fR for more information.
127 .TP
128 +.B unpack.DEPEND.missing
129 +A rare archive format was used in SRC_URI, but its package to unpack it is
130 +missing in DEPEND.
131 +TP
132 .B manifest.bad
133 Manifest has missing or incorrect digests
134 .TP
135 --
136 1.8.5.2

Replies