Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [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 01:44:21
Message-Id: CAAr7Pr_jt=wKjYee-tEWyY3RW1OLUV1ydV9sUOY-EPFneZ+D+g@mail.gmail.com
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 On Wed, Jan 15, 2014 at 4:07 PM, Tom Wijsman <tomwij@g.o> wrote:
2
3 > ---
4 > bin/repoman | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
5 > man/repoman.1 | 4 ++++
6 > 2 files changed, 57 insertions(+)
7 >
8 >
9 I urge you to not author new checks like this. /usr/bin/repoman is already
10 a mess.
11
12 Write these checks as functions, put them in a different file, and just
13 call them from the giant messy loop. At least that way the checks are self
14 contained (great for avoiding things like variable re-use or shadowing).
15
16 -A
17
18
19
20 > diff --git a/bin/repoman b/bin/repoman
21 > index d1542e9..9b703dc 100755
22 > --- a/bin/repoman
23 > +++ b/bin/repoman
24 > @@ -36,6 +36,9 @@ pym_path =
25 > osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")
26 > sys.path.insert(0, pym_path)
27 > import portage
28 > portage._internal_caller = True
29 > +
30 > +from portage._sets.profiles import PackagesSystemSet
31 > +system_set_atoms = PackagesSystemSet(portage.settings.profiles).getAtoms()
32 > portage._disable_legacy_globals()
33 >
34 > try:
35 > @@ -300,6 +303,7 @@ qahelp = {
36 > "inherit.missing": "Ebuild uses functions from an eclass but does
37 > not inherit it",
38 > "inherit.unused": "Ebuild inherits an eclass but does not use it",
39 > "java.eclassesnotused": "With virtual/jdk in DEPEND you must
40 > inherit a java eclass",
41 > + "unpack.DEPEND.missing": "A rare archive format was used in
42 > SRC_URI, but its package to unpack it is missing in DEPEND.",
43 > "wxwidgets.eclassnotused": "Ebuild DEPENDs on x11-libs/wxGTK
44 > without inheriting wxwidgets.eclass",
45 > "KEYWORDS.dropped": "Ebuilds that appear to have dropped KEYWORDS
46 > for some arch",
47 > "KEYWORDS.missing": "Ebuilds that have a missing or empty KEYWORDS
48 > variable",
49 > @@ -399,6 +403,7 @@ qawarnings = set((
50 > "metadata.warning",
51 > "portage.internal",
52 > "repo.eapi.deprecated",
53 > +"unpack.DEPEND.missing",
54 > "usage.obsolete",
55 > "upstream.workaround",
56 > "LIVEVCS.stable",
57 > @@ -479,6 +484,25 @@ ruby_deprecated = frozenset([
58 > "ruby_targets_ree18",
59 > ])
60 >
61 > +# TODO: Add functionality to support checking for deb2targz on platforms
62 > where
63 > +# GNU binutils is absent; see PMS 5, section 11.3.3.13.
64 > +archive_formats = {
65 > + "\.7[zZ]":"app-arch/p7zip",
66 > + "\.(bz2?|tbz2)":"app-arch/bzip2",
67 > + "\.jar":"app-arch/unzip",
68 > + "\.(LH[aA]|lha|lzh)":"app-arch/lha",
69 > + "\.lzma":"app-arch/lzma-utils",
70 > + "\.(rar|RAR)":"app-arch/unrar",
71 > + "\.(tar(\.(bz2?|gz|Z))?|tbz2|t[bg]z)?":"app-arch/tar",
72 > + "\.(gz|tar\.Z|t[bg]z|[zZ])":"app-arch/gzip",
73 > + "\.(zip|ZIP)":"app-arch/unzip",
74 > +}
75 > +
76 > +archive_formats_eapi_3_to_5 = {
77 > + "\.tar.xz":"app-arch/tar",
78 > + "\.xz":"app-arch/xz-utils",
79 > +}
80 > +
81 > metadata_xml_encoding = 'UTF-8'
82 > metadata_xml_declaration = '<?xml version="1.0" encoding="%s"?>' % \
83 > (metadata_xml_encoding,)
84 > @@ -1559,6 +1583,7 @@ for x in effective_scanlist:
85 > fetchlist_dict = portage.FetchlistDict(checkdir, repoman_settings,
86 > portdb)
87 > myfiles_all = []
88 > src_uri_error = False
89 > + needed_unpack_depends = {}
90 > for mykey in fetchlist_dict:
91 > try:
92 > myfiles_all.extend(fetchlist_dict[mykey])
93 > @@ -1573,7 +1598,22 @@ for x in effective_scanlist:
94 > stats["SRC_URI.syntax"] += 1
95 > fails["SRC_URI.syntax"].append(
96 > "%s.ebuild SRC_URI: %s" % (mykey,
97 > e))
98 > +
99 > + # Compare each SRC_URI entry against archive_formats; if
100 > one of the
101 > + # extensions match, we remember which archive depends are
102 > needed to
103 > + # check them later on.
104 > + needed_unpack_depends[mykey] = []
105 > + for file_extension in archive_formats or \
106 > + ((re.match('[345]$', eapi) is not None) \
107 > + and file_extension in
108 > archive_formats_eapi_3_to_5):
109 > + for entry in fetchlist_dict[mykey]:
110 > + if re.match('.*%s$' % file_extension,
111 > entry) is not None:
112 > + format =
113 > archive_formats[file_extension]
114 > +
115 > + if format not in
116 > needed_unpack_depends[mykey]:
117 > +
118 > needed_unpack_depends[mykey].append(format)
119 > del fetchlist_dict
120 > +
121 > if not src_uri_error:
122 > # This test can produce false positives if SRC_URI could
123 > not
124 > # be parsed for one or more ebuilds. There's no point in
125 > @@ -2010,6 +2050,17 @@ for x in effective_scanlist:
126 > atoms = None
127 > badsyntax.append(str(e))
128 >
129 > + if atoms and mytype == 'DEPEND':
130 > + # We check whether the needed archive
131 > dependencies are present
132 > + # in DEPEND, which were determined from
133 > SRC_URI.
134 > + for entry in needed_unpack_depends[catdir
135 > + '/' + y]:
136 > + if entry not in system_set_atoms
137 > and entry \
138 > + not in [atom.cp for atom
139 > in atoms if atom != "||"]:
140 > + stats['unpack.' + mytype +
141 > '.missing'] += 1
142 > + fails['unpack.' + mytype +
143 > '.missing'].append( \
144 > + relative_path + ":
145 > %s is missing in %s" % \
146 > + (entry, mytype))
147 > +
148 > if atoms and mytype.endswith("DEPEND"):
149 > if runtime and \
150 > "test?" in mydepstr.split():
151 > @@ -2384,6 +2435,8 @@ for x in effective_scanlist:
152 > "%s/metadata.xml: unused local
153 > USE-description: '%s'" % \
154 > (x, myflag))
155 >
156 > + del needed_unpack_depends
157 > +
158 > if options.if_modified == "y" and len(effective_scanlist) < 1:
159 > logging.warn("--if-modified is enabled, but no modified packages
160 > were found!")
161 >
162 > diff --git a/man/repoman.1 b/man/repoman.1
163 > index a78f94e..e739d56 100644
164 > --- a/man/repoman.1
165 > +++ b/man/repoman.1
166 > @@ -334,6 +334,10 @@ Ebuild inherits a deprecated eclass
167 > With virtual/jdk in DEPEND you must inherit a java eclass. Refer to
168 > \fIhttp://www.gentoo.org/proj/en/java/java\-devel.xml\fR for more
169 > information.
170 > .TP
171 > +.B unpack.DEPEND.missing
172 > +A rare archive format was used in SRC_URI, but its package to unpack it is
173 > +missing in DEPEND.
174 > +TP
175 > .B manifest.bad
176 > Manifest has missing or incorrect digests
177 > .TP
178 > --
179 > 1.8.5.2
180 >
181 >
182 >

Replies