~blr/launchpad-buildd/snap_http_proxy

« back to all changes in this revision

Viewing changes to lpbuildd/binarypackage.py

  • Committer: Colin Watson
  • Date: 2015-08-04 20:57:12 UTC
  • Revision ID: cjwatson@canonical.com-20150804205712-69ef0cn9yzi0hnbf
Strip qualifications and restrictions even from dep-waits derived solely
from sbuild output.

Show diffs side-by-side

added added

removed removed

Lines of Context:
251
251
                return True
252
252
        return False
253
253
 
 
254
    def stripDependencies(self, deps):
 
255
        """Return a stripped and stringified representation of a dependency.
 
256
 
 
257
        The build master can't handle the various qualifications and
 
258
        restrictions that may be present in control-format
 
259
        build-dependencies (e.g. ":any", "[amd64]", or "<!nocheck>"), so we
 
260
        strip these out before returning them.
 
261
 
 
262
        :param deps: Build-dependencies in the form returned by
 
263
            `debian.deb822.PkgRelation.parse_relations`.
 
264
        :return: A stripped dependency relation string, or None if deps is
 
265
            empty.
 
266
        """
 
267
        stripped_deps = []
 
268
        for or_dep in deps:
 
269
            stripped_or_dep = []
 
270
            for simple_dep in or_dep:
 
271
                stripped_simple_dep = dict(simple_dep)
 
272
                stripped_simple_dep["arch"] = None
 
273
                stripped_simple_dep["archqual"] = None
 
274
                stripped_simple_dep["restrictions"] = None
 
275
                stripped_or_dep.append(stripped_simple_dep)
 
276
            stripped_deps.append(stripped_or_dep)
 
277
        if stripped_deps:
 
278
            return PkgRelation.str(stripped_deps)
 
279
        else:
 
280
            return None
 
281
 
254
282
    def analyseDepWait(self, deps, avail):
255
283
        """Work out the correct dep-wait for a failed build, if any.
256
284
 
274
302
            unsat_deps = []
275
303
            for or_dep in deps:
276
304
                if not any(self.relationMatches(dep, avail) for dep in or_dep):
277
 
                    stripped_or_dep = []
278
 
                    for simple_dep in or_dep:
279
 
                        stripped_simple_dep = dict(simple_dep)
280
 
                        stripped_simple_dep["arch"] = None
281
 
                        stripped_simple_dep["archqual"] = None
282
 
                        stripped_simple_dep["restrictions"] = None
283
 
                        stripped_or_dep.append(stripped_simple_dep)
284
 
                    unsat_deps.append(stripped_or_dep)
285
 
            if unsat_deps:
286
 
                return PkgRelation.str(unsat_deps)
 
305
                    unsat_deps.append(or_dep)
 
306
            return self.stripDependencies(unsat_deps)
287
307
        except Exception:
288
308
            self._slave.log("Failed to analyse dep-wait:\n")
289
309
            for line in traceback.format_exc().splitlines(True):
290
310
                self._slave.log(line)
291
 
        return None
 
311
            return None
292
312
 
293
313
    def iterate_SBUILD(self, success):
294
314
        """Finished the sbuild run."""
347
367
            elif rx in BuildLogRegexes.DEPFAIL:
348
368
                # A depwait match forces depwait.
349
369
                missing_dep = mo.expand(BuildLogRegexes.DEPFAIL[rx])
 
370
                missing_dep = self.stripDependencies(
 
371
                    PkgRelation.parse_relations(missing_dep))
350
372
            else:
351
373
                # Otherwise it was a givenback pattern, so leave it
352
374
                # in givenback.