owner,
)
- # XXX create jobs
+ # Create all jobs
+ build._create_jobs()
+
# XXX generate update ID?
# XXX obsolete other builds
return ret
- def create_autojobs(self, arches=None, **kwargs):
- jobs = []
-
- # Arches may be passed to this function. If not we use all arches
- # this package supports.
- if arches is None:
- arches = self.supported_arches
+ def _create_jobs(self):
+ """
+ Called after a build has been created and creates all jobs
+ """
+ arches = []
- # Create a new job for every given archirecture.
- #for arch in self.backend.arches.expand(arches):
- # # Don't create jobs for src
- # if arch == "src":
- # continue
- #
- # job = self.add_job(arch, **kwargs)
- # jobs.append(job)
+ # Collect all supported arches
+ for arch in self.distro.arches:
+ # Skip any unsupported arches
+ #if self.pkg.supported_arches and not arch in self.pkg.supported_arches:
+ # log.debug("Build %s does not support %s" % (self.pkg, arch))
+ # continue
- # Return all newly created jobs.
- return jobs
+ arches.append(arch)
- def add_job(self, arch, **kwargs):
- job = self.backend.jobs.create(self, arch, **kwargs)
+ # Check for noarch
+ if not arches:
+ if "noarch" in self.pkg.supported_arches:
+ arches.append("noarch")
- # Add new job to cache.
- self.jobs.append(job)
+ # Raise an error if nothing is supported at all
+ if not arches:
+ raise RuntimeError("Build %s does not support any architectures" % self)
- return job
+ # Create the jobs
+ for arch in arches:
+ self.backend.jobs.create(self, arch)
## Update stuff
yield Job(self.backend, row.id, data=row)
def create(self, build, arch, test=False, superseeds=None):
- job = self._get_job("INSERT INTO jobs(build_id, arch, test) \
- VALUES(%s, %s, %s) RETURNING *", build.id, arch, test)
- job.log("created")
+ job = self._get_job("""
+ INSERT INTO
+ jobs
+ (
+ build_id,
+ arch,
+ test
+ )
+ VALUES
+ (
+ %s,
+ %s,
+ %s
+ )
+ RETURNING *""",
+ build,
+ arch,
+ test,
+ )
- # Set cache for Build object.
+ # Set cache for Build object
job.build = build
# Mark if the new job superseeds some other job