Hi Julien,

|--==> Julien Danjou writes:

[...]

  >>I'll attach it as soon as I'm done!

  JD> Thanks :)

Here you go.. The patch seems to work fine in most situations, but
probably needs to be checked against corner cases (especially when the
build_more_recent and build_arch_any options are used).

I've made a few comments to the new code, hope that's clear enough,
anyway the changes are very few.

While I am at it I attach another patch which fixes the renaming from
Job.build_status to Job.build in the webpy templates (maybe you did it
yourself but didn't commit).

If you don't mind I'd like to be added to the rebuildd Alioth project
(I'm free-guest), so that if I play more with the code I can commit it
in a branch, and you can review it more easily.

Ciao!

Free
Index: rebuildd/Job.py
===================================================================
--- rebuildd/Job.py	(revision 144)
+++ rebuildd/Job.py	(working copy)
@@ -101,10 +101,15 @@
         with self.status_lock:
             self.status = JobStatus.BUILDING
 
+        arch = self.arch
+        # if arch is 'any' use the first arch defined
+        if arch == 'any':
+            arch = RebuilddConfig().get('build', 'archs').split(' ')[0]
+
         # execute commands
         for cmd, failed_status in ([Dists().dists[self.dist].get_source_cmd(self.package),
                                     JobStatus.SOURCE_FAILED],
-                                   [Dists().dists[self.dist].get_build_cmd(self.package),
+                                   [Dists().dists[self.dist].get_build_cmd(self.package, arch),
                                     JobStatus.BUILD_FAILED],
                                    [Dists().dists[self.dist].get_post_build_cmd(self.package),
                                     JobStatus.POST_BUILD_FAILED]):
Index: rebuildd/Rebuildd.py
===================================================================
--- rebuildd/Rebuildd.py	(revision 144)
+++ rebuildd/Rebuildd.py	(working copy)
@@ -126,7 +126,8 @@
                 return 0
 
             jobs = []
-            jobs.extend(Job.selectBy(status=JobStatus.WAIT, arch=self.cfg.arch)[:max_new])
+            for arch in self.cfg.get('build', 'archs').split(' '):
+                jobs.extend(Job.selectBy(status=JobStatus.WAIT, arch=arch)[:max_new])
             if self.cfg.getboolean('build', 'build_arch_any'):
                 jobs.extend(Job.selectBy(status=JobStatus.WAIT, arch='any')[:max_new])
 
@@ -146,11 +147,11 @@
                     # try to see if there's a job for us
                     for cpackage in candidate_packages:
                         candidate_jobs = []
-                        candidate_jobs.extend(Job.selectBy(package=cpackage, arch=self.cfg.arch))
+                        candidate_jobs.extend(Job.selectBy(package=cpackage, arch=job.arch))
                         if self.cfg.getboolean('build', 'build_arch_any'):
                             candidate_jobs.extend(Job.selectBy(package=cpackage, arch='any'))
                         for cjob in candidate_jobs:
-                            if newjob and newjob.arch == self.cfg.arch and cjob.arch == self.cfg.arch and cjob.status == JobStatus.WAIT:
+                            if newjob and newjob.arch == job.arch and cjob.arch == job.arch and cjob.status == JobStatus.WAIT:
                                 cjob.status = JobStatus.GIVEUP
                             elif newjob and newjob.arch == "any" and cjob.status == JobStatus.WAIT:
                                 cjob.status = JobStatus.GIVEUP
@@ -271,30 +272,38 @@
         if not Dists().dists.has_key(dist):
             return False
 
+        archs = []
         if not arch:
-            arch = self.cfg.arch
-
-        pkgs = Package.selectBy(name=name, version=version)
-        if pkgs.count():
-            # If several packages exists, just take the first
-            pkg = pkgs[0]
+            # Add a job for every arch we support
+            archs = self.cfg.get('build', 'archs').split(' ')
         else:
-            # Maybe we found no packages, so create a brand new one!
-            pkg = Package(name=name, version=version, priority=priority)
+            # Just add one job
+            archs[0] = arch
 
-        jobs_count = Job.selectBy(package=pkg, dist=dist, arch=arch, mailto=mailto, status=JobStatus.WAIT).count()
-        if jobs_count:
-            RebuilddLog.error("Job already existing for %s_%s on %s/%s, don't adding it" \
-                           % (pkg.name, pkg.version, dist, arch))
-            return False
+        for arch in archs:
 
-        job = Job(package=pkg, dist=dist, arch=arch)
-        job.status = JobStatus.WAIT
-        job.arch = arch
-        job.mailto = mailto
+            pkgs = Package.selectBy(name=name, version=version)
+            if pkgs.count():
+                # If several packages exists, just take the first
+                pkg = pkgs[0]
+            else:
+                # Maybe we found no packages, so create a brand new one!
+                pkg = Package(name=name, version=version, priority=priority)
 
-        RebuilddLog.info("Added job for %s_%s on %s/%s for %s" \
-                      % (name, version, dist, arch, mailto))
+            jobs_count = Job.selectBy(package=pkg, dist=dist, arch=arch, mailto=mailto, status=JobStatus.WAIT).count()
+            if jobs_count:
+                RebuilddLog.error("Job already existing for %s_%s on %s/%s, don't adding it" \
+                                      % (pkg.name, pkg.version, dist, arch))
+                return False
+
+            job = Job(package=pkg, dist=dist, arch=arch)
+            job.status = JobStatus.WAIT
+            job.arch = arch
+            job.mailto = mailto
+
+            RebuilddLog.info("Added job for %s_%s on %s/%s for %s" \
+                                 % (name, version, dist, arch, mailto))
+
         return True
 
     def clean_jobs(self):
Index: rebuildd/Distribution.py
===================================================================
--- rebuildd/Distribution.py	(revision 144)
+++ rebuildd/Distribution.py	(working copy)
@@ -35,20 +35,20 @@
             RebuilddLog.error("get_source_cmd has invalid format: %s" % error)
             return None
  
-    def get_build_cmd(self, package):
+    def get_build_cmd(self, package, arch):
         """Return command used for building source for this distribution"""
 
         # Strip epochs (x:) away
         try:
             index = package.version.index(":")
             return RebuilddConfig().get('build', 'build_cmd') \
-                    % (self.name, package.name, package.version[index+1:])
+                    % (self.name, arch, package.name, package.version[index+1:])
         except ValueError:
             pass
 
         try:
             return RebuilddConfig().get('build', 'build_cmd') \
-                    % (self.name, package.name, package.version)
+                    % (self.name, arch, package.name, package.version)
         except TypeError, error:
             RebuilddLog.error("get_build_cmd has invalid format: %s" % error)
             return None
Index: rebuildd/RebuilddConfig.py
===================================================================
--- rebuildd/RebuilddConfig.py	(revision 144)
+++ rebuildd/RebuilddConfig.py	(working copy)
@@ -46,13 +46,16 @@
         self.set('build', 'max_jobs', '5')
         self.set('build', 'kill_timeout', '90')
         self.set('build', 'source_cmd', 'apt-get -q --download-only -t %s source %s=%s')
-        self.set('build', 'build_cmd', 'pbuilder build --basetgz /var/cache/pbuilder/%s.tgz %s_%s.dsc')
+        self.set('build', 'build_cmd', 'pbuilder build --basetgz /var/cache/pbuilder/%s-%s.tgz %s_%s.dsc')
         self.set('build', 'post_build_cmd', '')
         self.set('build', 'dists', 'etch lenny sid')
         self.set('build', 'work_dir', '/var/cache/rebuildd/build')
         self.set('build', 'database_uri', 'sqlite:///var/lib/rebuildd/rebuildd.db')
         self.set('build', 'build_more_recent', '1')
         self.set('build', 'build_arch_any', '1')
+        parch = os.popen("dpkg --print-architecture")
+        self.set('build', 'archs', parch.readline().strip())
+        parch.close()
 
         self.set('mail', 'from', '[EMAIL PROTECTED]')
         self.set('mail', 'mailto', '[EMAIL PROTECTED]')
@@ -77,10 +80,6 @@
         self.set('log', 'mail_failed', '1')
         self.set('log', 'mail_successful', '0')
 
-        parch = os.popen("dpkg --print-architecture")
-        self.arch = parch.readline().strip()
-        parch.close()
-
         if not dontparse:
             self.reload()
 
Index: templates/tab.html
===================================================================
--- templates/tab.html	(revision 144)
+++ templates/tab.html	(working copy)
@@ -23,23 +23,23 @@
     <td><a href="/dist/$job.dist/arch/$job.arch">$job.dist/$job.arch</a></td>
     <td>$job.creation_date</td>
     <td>$job.mailto</td>
-    $if job.build_status == 0:
+    $if job.status == 0:
         <td bgcolor="gray" align="center">Duh?</td>
-    $if job.build_status == 100:
+    $if job.status == 100:
         <td bgcolor="yellow" align="center">WAIT</td>
-    $if job.build_status == 150:
+    $if job.status == 150:
         <td bgcolor="yellow" align="center">WAIT_LOCKED</td>
-    $if job.build_status == 200:
+    $if job.status == 200:
         <td bgcolor="orange" align="center">BUILDING</td>
-    $if job.build_status == 300:
+    $if job.status == 300:
         <td bgcolor="red" align="center">BUILD_FAILED</td>
-    $if job.build_status == 400:
+    $if job.status == 400:
         <td bgcolor="green" align="center">BUILD_OK</td>
-    $if job.build_status == 800:
+    $if job.status == 800:
         <td bgcolor="red" align="center">CANCELED</td>
-    $if job.build_status == 900:
+    $if job.status == 900:
         <td bgcolor="red" align="center">FAILED</td>
-    $if job.build_status == 1000:
+    $if job.status == 1000:
         <td bgcolor="green" align="center">OK</td>
     <td><a href="/host/$job.host"></a>$job.host</td>
     <td>$job.build_start</td>
Index: templates/job.html
===================================================================
--- templates/job.html	(revision 144)
+++ templates/job.html	(working copy)
@@ -22,23 +22,23 @@
     <td><a href="/dist/$job.dist/arch/$job.arch">$job.dist/$job.arch</a></td>
     <td>$job.creation_date</td>
     <td>$job.mailto</td>
-    $if job.build_status == 0:
+    $if job.status == 0:
         <td bgcolor="gray" align="center">Duh?</td>
-    $if job.build_status == 100:
+    $if job.status == 100:
         <td bgcolor="yellow" align="center">WAIT</td>
-    $if job.build_status == 150:
+    $if job.status == 150:
         <td bgcolor="yellow" align="center">WAIT_LOCKED</td>
-    $if job.build_status == 200:
+    $if job.status == 200:
         <td bgcolor="orange" align="center">BUILDING</td>
-    $if job.build_status == 300:
+    $if job.status == 300:
         <td bgcolor="red" align="center">BUILD_FAILED</td>
-    $if job.build_status == 400:
+    $if job.status == 400:
         <td bgcolor="green" align="center">BUILD_OK</td>
-    $if job.build_status == 800:
+    $if job.status == 800:
         <td bgcolor="red" align="center">CANCELED</td>
-    $if job.build_status == 900:
+    $if job.status == 900:
         <td bgcolor="red" align="center">FAILED</td>
-    $if job.build_status == 1000:
+    $if job.status == 1000:
         <td bgcolor="green" align="center">OK</td>
     <td><a href="/host/$job.host"></a>$job.host</td>
     <td>$job.build_start</td>

Reply via email to