[Pkg-debile-commits] [debile-master] 15/26: Fix support for binary package testing

Sylvestre Ledru sylvestre at alioth.debian.org
Tue Aug 20 16:22:37 UTC 2013


This is an automated email from the git hooks/post-receive script.

sylvestre pushed a commit to branch master
in repository debile-master.

commit 6319ccdc219f9205510df55ce1151ce52aee2dde
Author: Léo Cavaillé <leo at cavaille.net>
Date:   Tue Aug 13 22:48:06 2013 +0200

    Fix support for binary package testing
---
 lucy/archive.py  |   20 +++++++++++++++++++-
 lucy/incoming.py |   41 ++++++++++++++++++++++-------------------
 lucy/orm.py      |    1 +
 lucy/server.py   |   10 ++++------
 4 files changed, 46 insertions(+), 26 deletions(-)

diff --git a/lucy/archive.py b/lucy/archive.py
index 5fde314..745a862 100644
--- a/lucy/archive.py
+++ b/lucy/archive.py
@@ -2,7 +2,9 @@ from lucy.config import Config
 import shutil
 import os
 
-def move_to_pool(package, changes, root=None):
+# FIXME: really who duplicates code like this ?
+
+def move_to_pool_source(package, changes, root=None):
     config = Config()
     pool = config.get('paths', 'pool')
     path = os.path.join(pool, str(package.package_id))
@@ -17,3 +19,19 @@ def move_to_pool(package, changes, root=None):
         bn = os.path.basename(entry)
         dest = os.path.join(path, bn)
         os.rename(entry, dest)
+
+def move_to_pool_binary(package, changes, root=None):
+    config = Config()
+    pool = config.get('paths', 'pool')
+    path = os.path.join(pool, str(package.source.id))
+    if root:
+        path = os.path.join(path, root)
+
+    if os.path.exists(path):
+        shutil.rmtree(path)  # odd. very odd.
+
+    os.makedirs(path)
+    for entry in changes.get_files():
+        bn = os.path.basename(entry)
+        dest = os.path.join(path, bn)
+        os.rename(entry, dest)
diff --git a/lucy/incoming.py b/lucy/incoming.py
index 01b8103..328cddb 100644
--- a/lucy/incoming.py
+++ b/lucy/incoming.py
@@ -1,6 +1,6 @@
 from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
 from lucy.orm import User, Source, Machine, Binary, Job, Group
-from lucy.archive import move_to_pool
+from lucy.archive import move_to_pool_source, move_to_pool_binary
 
 from lucy.changes import parse_changes_file, ChangesFileException
 from lucy.utils import cd, fglob
@@ -86,7 +86,7 @@ def accept_source(changes):
     session.add(s)
     session.commit()
 
-    path = move_to_pool(s, changes)
+    path = move_to_pool_source(s, changes)
     os.unlink(changes.get_filename())
 
     #send_mail("ACCEPTED: {source}/{version} for {owner} as {_id}".format(
@@ -185,24 +185,27 @@ def accept_binary(changes):
     if not buildd:
         return reject(changes, 'youre-not-a-machine')
 
-    b = Binary( source=s,
-                name=changes['source'],
-                version=changes['version'],
-                arch=arch,
-                suite=suite,
-                run=int(s.run))
-    session.add(b)
-    session.commit()
-    add_jobs(b)
-
-    path = move_to_pool(b, changes, root=arch)
+    for bfile in binaries: 
+        # From the deb filemname, get the package name
+        bname = bfile.split('_')[0]
+        b = Binary( source=s,
+                    name=bname,
+                    version=changes['version'],
+                    deb=bfile,
+                    arch=arch,
+                    suite=suite,
+                    run=int(s.run))
+        session.add(b)
+        session.commit()
+        add_jobs(b)
+
+        path = move_to_pool_binary(b, changes, root=arch)
+        logging.info("Accepted binary package : %s / %s (%s/%s)",
+                b.name,
+                b.version,
+                b.suite,
+                b.arch)
     os.unlink(changes.get_filename())
-    logging.info("Accepted binary package : %s / %s (%s/%s)",
-            b.name,
-            b.version,
-            b.suite,
-            b.arch)
-
 
 def reject(changes, reason):
     print("reject", reason)
diff --git a/lucy/orm.py b/lucy/orm.py
index 7438d2c..de1b436 100644
--- a/lucy/orm.py
+++ b/lucy/orm.py
@@ -99,6 +99,7 @@ class Binary(Package):
     group_id = Column(Integer, ForeignKey('groups.id'))
     group = relationship("Group", backref=backref('binaries', order_by=name))
     run = Column(Integer)
+    deb = Column(String(100))
     def serialize(self):
         binary_dict = row2dict(self)
         binary_dict['type'] = 'binary'
diff --git a/lucy/server.py b/lucy/server.py
index a41c423..e05aab5 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -200,7 +200,7 @@ class LucyInterface(object):
         public = config.get('paths', 'public')
         return "{public}/{pool}/{dsc}".format(
             public=public,
-            pool=s.source_id,
+            pool=s.package_id,
             dsc=s.dsc,
         )
 
@@ -221,14 +221,13 @@ class LucyInterface(object):
         b = session.query(Binary).filter(Binary.binary_id == binary_id).one()
         public = config.get('paths', 'public')
 
-        root = "{public}/{pool}/{arch}".format(
+        return "{public}/{pool}/{arch}/{deb}".format(
             public=public,
-            pool=b.source.source_id,
+            pool=b.source.id,
             arch=b.arch,
+            deb=b.deb
         )
 
-        return {"root": root, "packages": pkg['binaries']}
-
     @machine_method
     def get_current_jobs(self):
         """
@@ -389,7 +388,6 @@ class AsyncXMLRPCServer(SocketServer.ThreadingMixIn, LucyAuthMixIn):
 
 
 def serve(server, port):
-    print("Serving on `{server}' on port `{port}'".format(**locals()))
     server = SimpleXMLRPCServer((server, port),
                                 requestHandler=AsyncXMLRPCServer,
                                 allow_none=True)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-debile/debile-master.git



More information about the Pkg-debile-commits mailing list