[Pkg-debile-commits] [debile-master] 17/28: Added handling of binary uploads through APT repo

Léo Cavaillé leo.cavaille-guest at alioth.debian.org
Wed Aug 21 13:36:51 UTC 2013


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

leo.cavaille-guest pushed a commit to branch master
in repository debile-master.

commit 84d7bff31bbf4bd33f180c84b8f7c2634f773c67
Author: Léo Cavaillé <leo at cavaille.net>
Date:   Sat Aug 17 11:26:05 2013 +0200

    Added handling of binary uploads through APT repo
---
 lucy/archive.py  |   28 ++++++++--
 lucy/incoming.py |  149 ++++++++++++++++++++++++++++++------------------------
 2 files changed, 108 insertions(+), 69 deletions(-)

diff --git a/lucy/archive.py b/lucy/archive.py
index e758c84..1c83937 100644
--- a/lucy/archive.py
+++ b/lucy/archive.py
@@ -66,10 +66,11 @@ class UserRepository:
 
     def add_source(self, source, remove_before=False):
         # FIXME: suite, hardcoded everywhere here
+        repo_path = os.path.join(self.pool_path, 'source')
         if remove_before:
             out, err, ret = run_command([
                 'reprepro',
-                '-b', os.path.join(self.pool_path, 'source'),
+                '-b', repo_path,
                 'removesrc',
                 'sid',
                 source.name,
@@ -79,15 +80,34 @@ class UserRepository:
         dsc = os.path.join(self.incoming_path, 'source', source.dsc)
         out, err, ret = run_command([
             'reprepro',
-            '-b', os.path.join(self.pool_path, 'source'),
+            '-b', repo_path,
             'includedsc',
             'sid',
             dsc
             ])
         print out
 
-    def add_binary(self, binary, compiler):
-        return
+    def add_binary(self, binary, remove_before=False):
+        # FIXME: suite, hardcoded everywhere here
+        repo_path = os.path.join(self.pool_path, binary.compiler_type)
+        if remove_before:
+            out, err, ret = run_command([
+                'reprepro',
+                '-b', repo_path,
+                'remove',
+                'sid',
+                binary.name,
+                binary.version
+                ])
+        deb = os.path.join(self.incoming_path, binary.compiler_type, binary.deb)
+        out, err, ret = run_command([
+            'reprepro',
+            '-b', repo_path,
+            'includedeb',
+            'sid',
+            deb
+            ])
+        print out
 
     def create_repository(self):
         """
diff --git a/lucy/incoming.py b/lucy/incoming.py
index 9827d54..7048392 100644
--- a/lucy/incoming.py
+++ b/lucy/incoming.py
@@ -32,21 +32,14 @@ def process():
             for changes in fglob("*changes", pcf):
                 accept_source(changes, u)
 
-
-def accept(changes, user):
-    try:
-        changes.validate_signature()
-    except ChangesFileException:
-        return reject(changes, "invalid-signature")
-
-    if changes.is_source_only_upload():
-        return accept_source(changes, user)
-
-    if changes.is_binary_only_upload():
-        return accept_binary(changes, user)
-
-    return reject(changes, "not-only-sourceful")
-
+        binary_incoming_root = os.path.join(config.get('paths', 'incoming'), u.login)
+        build_flavors = listize(self.config.get('jobs', 'build-flavors'))
+        for compiler in build_flavors:
+            binary_incoming = os.path.join(binary_incoming_root, compiler)
+            with cd(binary_incoming):
+                pcf = lambda x: parse_changes_file(x, binary_incoming)
+                for changes in fglob("*changes", pcf):
+                    accept_binary(changes, compiler, u)
 
 def accept_source(changes, user):
     session = Session()
@@ -131,58 +124,23 @@ def accept_source(changes, user):
             s.arch)
     add_jobs(s)
 
-# This method looks at lucy's configuration to see what jobs we need to run on
-# either a source/binary package.
-def add_jobs(package):
-    config = Config()
+def accept_binary(changes):
     session = Session()
-    for type in listize(config.get('jobs', package.type)):
-        # For source packages, use only unstable and set arch to all
-        # so that any builder arch can take jobs
-        j = Job(uuid=uuid.uuid4(),
-                package=package,
-                suite=package.suite,
-                arch=package.arch,
-                type=type)
-        session.add(j)
-
-        logging.info("Adding job type %s,%s (id %s) for package %s (%s/%s/%s)",
-                package.type,
-                j.type,
-                j.id,
-                package.name,
-                package.version,
-                package.suite,
-                package.arch)
-
-    # If this a source package, add some build jobs    
-    if package.type == 'source' and config.getboolean('jobs', 'build-enabled'):
-        for arch in listize(config.get('jobs', 'arches')):
-            for compiler in listize(config.get('jobs', 'build-flavors')):
-                j = Job(uuid=uuid.uuid4(),
-                        arch=arch,
-                        suite=package.suite,
-                        type='build',
-                        subtype=compiler,
-                        package=package)
-
-                logging.info("Adding job type %s/%s/%s (id %s) for package %s (%s/%s/%s)",
-                        package.type,
-                        j.type,
-                        j.subtype,
-                        j.id,
-                        package.name,
-                        package.version,
-                        package.suite,
-                        package.arch)
-                session.add(j)
-    session.commit()
+    try:
+        print "Binary acceptance : validating the .changes file"
+        changes.validate()
+    except ChangesFileException:
+        return reject(changes, "invalid")
 
+    try:
+        key = changes.validate_signature()
+        print "Binary acceptance : validating the .changes signature"
+    except ChangesFileException:
+        return reject(changes, "invalid-signature")
 
-def accept_binary(changes):
-    session = Session()
+    if not changes.is_binary_only_upload():
+        return reject(changes, "not-only-sourceful")
 
-    key = changes.validate_signature()
 
     arch = changes['Architecture']
     if " " in arch:
@@ -195,24 +153,28 @@ def accept_binary(changes):
             return reject(changes, 'too-many-arches')
 
         arch = changes._data['Architecture'] = arches[0]
-
+    print "Binary acceptance : arch is %s" % arch
 
     suite = changes['Distribution']
+    print "Binary acceptance : suite is %s" % arch
     binaries = changes.get_files()
 
     try:
         job_id = changes['x-lucy-job']
+        print "Binary acceptance : produced by lucy job %s" % str(job_id)
     except KeyError:
         return reject(changes, 'no-job')
 
     try:
         j = session.query(Job).filter(Job.id == job_id).one()
+        print "Binary acceptance : job is %s/%s" % (j.type, j.subtype)
     except NoResultFound:
         return reject(changes, 'invalid-job')
 
     # Now find the source related to this build job
     try:
         s = session.query(Source).join(Source.jobs).filter(Job.id == job_id).one()
+        print "Binary acceptance : originating source is %s (%s)" % (s.name, s.version)
     except NoResultFound:
         return reject(changes, 'job-with-no-source')
 
@@ -222,8 +184,10 @@ def accept_binary(changes):
     buildd = session.query(Machine).filter(Machine.gpg_fingerprint == key).first()
     if not buildd:
         return reject(changes, 'youre-not-a-machine')
+    print "Binary acceptance : originating debile-slave %s" % buildd.name
 
     for bfile in binaries: 
+        print "Binary acceptance : processing %s" % bfile
         # From the deb filemname, get the package name
         bfilename=os.path.basename(bfile)
         bname = bfilename.split('_')[0]
@@ -237,9 +201,15 @@ def accept_binary(changes):
                     compiler_type=j.subtype)
         session.add(b)
         session.commit()
+
+        # Add the binary to the local user repository
+        ur = UserRepository(s.user)
+        # If run>1 delete the previous binary before storing the new one
+        ur.add_binary(b, (run>1))
+
         add_jobs(b)
 
-        path = move_to_pool_binary(b, bfilename, root=arch)
+        #path = move_to_pool_binary(b, bfilename, root=arch)
         logging.info("Accepted binary package : %s / %s (%s/%s) from compiler %s",
                 b.name,
                 b.version,
@@ -248,6 +218,55 @@ def accept_binary(changes):
                 b.compiler_type)
     os.unlink(changes.get_filename())
 
+# This method looks at lucy's configuration to see what jobs we need to run on
+# either a source/binary package.
+def add_jobs(package):
+    config = Config()
+    session = Session()
+    for type in listize(config.get('jobs', package.type)):
+        # For source packages, use only unstable and set arch to all
+        # so that any builder arch can take jobs
+        j = Job(uuid=uuid.uuid4(),
+                package=package,
+                suite=package.suite,
+                arch=package.arch,
+                type=type)
+        session.add(j)
+
+        logging.info("Adding job type %s,%s (id %s) for package %s (%s/%s/%s)",
+                package.type,
+                j.type,
+                j.id,
+                package.name,
+                package.version,
+                package.suite,
+                package.arch)
+
+    # If this a source package, add some build jobs
+    if package.type == 'source' and config.getboolean('jobs', 'build-enabled'):
+        for arch in listize(config.get('jobs', 'arches')):
+            for compiler in listize(config.get('jobs', 'build-flavors')):
+                j = Job(uuid=uuid.uuid4(),
+                        arch=arch,
+                        suite=package.suite,
+                        type='build',
+                        subtype=compiler,
+                        package=package)
+
+                logging.info("Adding job type %s/%s/%s (id %s) for package %s (%s/%s/%s)",
+                        package.type,
+                        j.type,
+                        j.subtype,
+                        j.id,
+                        package.name,
+                        package.version,
+                        package.suite,
+                        package.arch)
+                session.add(j)
+    session.commit()
+
+
+
 def reject(changes, reason):
     print("reject", reason)
     # email luser with reason template

-- 
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