[Pkg-debile-commits] [debile-master] 01/28: Implemented folder creation for APT repo.

Léo Cavaillé leo.cavaille-guest at alioth.debian.org
Wed Aug 21 13:36:48 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 0458f5c78bdb44d896ee467730f8e5b5084c6d67
Author: Léo Cavaillé <leo at cavaille.net>
Date:   Fri Aug 16 21:55:35 2013 +0200

    Implemented folder creation for APT repo.
    
    + config up to date
---
 lucy/archive.py                       |  136 +++++++++++++++++++++++++++++++++
 lucy/incoming.py                      |   31 ++++----
 lucy/server.py                        |   10 ++-
 lucy/templates/reprepro/distributions |    6 ++
 skel/lucy.ini                         |    8 +-
 5 files changed, 170 insertions(+), 21 deletions(-)

diff --git a/lucy/archive.py b/lucy/archive.py
index caf9154..8fea96e 100644
--- a/lucy/archive.py
+++ b/lucy/archive.py
@@ -1,6 +1,142 @@
 from lucy.config import Config
+from lucy.orm import User, Source, Binary, Package
+from debian import deb822
 import shutil
 import os
+import logging
+
+from jinja2 import Template
+
+def listize(entry):
+    items = [x.strip() for x in entry.split(",")]
+    return [None if x == "null" else x for x in items]
+
+def check_user_repository_consitency():
+    """
+    Check the database for all the users in there.
+    Check the incoming/pool repositories for all the users in there.
+    Check also the arches supported by the daemon
+    Merge everything with deletion behavior by default.
+    """
+    # TODO : add the thorough check of checking all Packages in DB first.
+    # TODO : implement the function
+    return
+
+def generate_builders_dputcf():
+    return
+
+
+class UserRepository:
+    """
+    We call a UserRepository the set incoming + pool
+    debile-master repository is structured as :
+    
+    <incoming_debile_dir>
+      / <user_login>
+          / source                -> for dputting from the user
+              tar_1.26+dfsg-8.debian.tar.gz
+              tar_1.26+dfsg-8.dsc
+              tar_1.26+dfsg-8_source.changes
+              tar_1.26+dfsg.orig.tar.xz
+          / <compiler_type>       -> for dputting from a builder
+     
+    <pool_debile_dir>
+      / <user_login>
+          / source                -> the source packages in a pool
+              / conf
+                  distributions   -> file we setup
+                  options         -> file we setup
+              / db
+              / dist
+              / pool
+          / <compiler_type>       -> another pool for each binaries
+                                  compiler flavor
+    """
+    def __init__(self, user):
+        self.user = user
+        self.config = Config()
+        incoming_path = self.config.get('paths', 'incoming')
+        self.incoming_path = os.path.join(incoming_path, self.user.login)
+        pool_path = self.config.get('paths', 'pool')
+        self.pool_path = os.path.join(pool_path, self.user.login)
+
+    def get_apt_entry(self):
+        return
+
+    def add_source(self, source):
+        return
+
+    def add_binary(self, binary, compiler):
+        return
+
+    def create_repository(self):
+        """
+        Called when adding a user, it creates all the paths and file needed, to
+        store sources and binaries for the debile platform.
+        This method does not check any existing paths or permission so be sure
+        to run check_user_repository_consitency and check_permissions_repository
+        before.
+        """
+        # Create the incoming directory
+        logging.debug("Creating incoming directory : %s" % self.incoming_path)
+        os.makedirs(self.incoming_path)
+
+        # Create the subdirs of the incoming directory
+        path = os.path.join(self.incoming_path, "source")
+        logging.debug("Creating incoming directory : %s" % path)
+        os.makedirs(path)
+        build_flavors = listize(self.config.get('jobs', 'build-flavors'))
+        for compiler in build_flavors:
+            path = os.path.join(self.incoming_path, compiler)
+            logging.debug("Creating incoming directory : %s" % path)
+            os.makedirs(path)
+
+
+        # Create the pool directory
+        logging.debug("Creating pool directory : %s" % self.pool_path)
+        os.makedirs(self.pool_path)
+
+        # Create the pool sub-directories
+        build_flavors = listize(self.config.get('jobs', 'build-flavors'))
+        for compiler in (build_flavors + ['source']):
+            path = os.path.join(self.pool_path, compiler)
+            logging.debug("Creating pool directory : %s" % path)
+            os.makedirs(path)
+
+        # Now that we have a nice skeleton, setup the directories needed for
+        # reprepro utilization
+        arches = listize(self.config.get('jobs', 'arches'))
+        for compiler in (build_flavors + ['source']):
+            path = os.path.join(self.pool_path, compiler)
+            # Create the configuration /conf pool directory
+            os.makedirs(os.path.join(path, 'conf'))
+            # Create the distributions configuration file
+            jinjafile = os.path.join(
+                os.path.dirname(__file__), 
+                "templates", 
+                "reprepro", 
+                "distributions") 
+            template = Template(open(jinjafile).read())
+            distribution_file = os.path.join(path, 'conf', 'distributions')
+            with open(distribution_file, 'w') as f:
+                if compiler == 'source':
+                    description = 'source packages'
+                else:
+                    description = 'binary packages compiled with %s'
+                f.write(
+                    template.render(
+                        username=self.user.login,
+                        description=description,
+                        arches=arches))
+
+    def delete_repository(self):
+        return
+
+    def generate_dputcf(self):
+        return
+
+
+
 
 # FIXME: really who duplicates code like this ?
 
diff --git a/lucy/incoming.py b/lucy/incoming.py
index 95369f9..1bbe5a9 100644
--- a/lucy/incoming.py
+++ b/lucy/incoming.py
@@ -21,32 +21,35 @@ def process():
     config = Config()
     incoming = config.get('paths', 'incoming')
     pcf = lambda x: parse_changes_file(x, incoming)
-    with cd(incoming):
-        for changes in fglob("*changes", pcf):
-            try:
-                changes.validate()
-            except ChangesFileException:
-                reject(changes, "invalid")
-                continue
-            accept(changes)
-
-
-def accept(changes):
+    session = Session()
+    users = session.query(User).all()
+    for u in users:
+        with cd(os.path.join(incoming,u.login)):
+            for changes in fglob("*changes", pcf):
+                try:
+                    changes.validate()
+                except ChangesFileException:
+                    reject(changes, "invalid")
+                    continue
+                accept(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)
+        return accept_source(changes, user)
 
     if changes.is_binary_only_upload():
-        return accept_binary(changes)
+        return accept_binary(changes, user)
 
     return reject(changes, "not-only-sourceful")
 
 
-def accept_source(changes):
+def accept_source(changes, user):
     session = Session()
     key = changes.validate_signature()
 
diff --git a/lucy/server.py b/lucy/server.py
index 20a424b..d1127c8 100644
--- a/lucy/server.py
+++ b/lucy/server.py
@@ -6,6 +6,7 @@ from sqlalchemy.orm.exc import NoResultFound, MultipleResultsFound
 from lucy.orm import Machine, Job, Source, Binary, User, Package
 from lucy.config import Config
 from lucy.mail import send_mail
+from lucy.archive import UserRepository
 
 from SimpleXMLRPCServer import SimpleXMLRPCServer
 from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
@@ -24,7 +25,7 @@ NAMESPACE = threading.local()
 # TODO : Command line arg for overriding default location ?
 config = Config()
 
-engine = create_engine(config.get('db', 'engine'), echo=True)
+engine = create_engine(config.get('db', 'engine'), echo=False)
 session_factory = sessionmaker(bind=engine)
 Session = scoped_session(session_factory)
 
@@ -143,11 +144,14 @@ class LucyInterface(object):
         try:
             session.add(u)
             session.commit()
-        except Exception:
+            ur = UserRepository(u)
+            ur.create_repository()
+        except Exception as e:
+            print e
             session.rollback()
             return None, "Oops something screwed up"
 
-        user_url = "%s/hacker/%s" % (config.get('paths', 'debuildme'), login)
+        user_url = "%s/hacker/%s" % (config.get('paths', 'debile_url'), login)
 
         return u.serialize(), "User %s with key %s added, see %s" % (name, u.gpg_fingerprint, user_url)
 
diff --git a/lucy/templates/reprepro/distributions b/lucy/templates/reprepro/distributions
new file mode 100644
index 0000000..d52f6e4
--- /dev/null
+++ b/lucy/templates/reprepro/distributions
@@ -0,0 +1,6 @@
+Origin: {{username}} debile repository for {{description}}
+Label: {{username}} debile repository for {{description}} 
+Codename: sid
+Architectures: {{arches|join(' ')}}
+Components: main
+Description: {{username}} debile repository for {{description}}
diff --git a/skel/lucy.ini b/skel/lucy.ini
index 6dca12d..66950e6 100644
--- a/skel/lucy.ini
+++ b/skel/lucy.ini
@@ -12,13 +12,13 @@ engine=postgresql://lucy:adamngoodpassword@localhost/lucy
 ; create or accept
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 [jobs]
-suites=unstable,testing
+suites=unstable
 ; Define the type of jobs you want to run with source package (comma separated 
 ; list). This must be ethel.commands module names
 source=lintian,clanganalyzer,perlcritic,cppcheck,pep8,coccinelle
 ; Flag to disable the build jobs
 ; This will also disable the binary jobs as a consequence
-build-enabled=0
+build-enabled=1
 build-flavors=gcc-4.8,clang-3.3
 ; Idem for binary packages
 binary=lintian,piuparts,adequate
@@ -31,9 +31,9 @@ arches=amd64,i386
 ; Different paths needed to access or to store lucy files
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 [paths]
-; debuild.me URL to send links to the clients
+; debile URL to send links to the clients
 ; if needed
-debuildme_url=http://debuild.me
+debile_url=http://debile.debian.net
 ; NOT USED YET
 #keyring=
 ; This has to be the dput target of ricky

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