[Pkg-debile-commits] [debile-master] 21/126: meh
Sylvestre Ledru
sylvestre at alioth.debian.org
Mon Aug 19 14:56:07 UTC 2013
This is an automated email from the git hooks/post-receive script.
sylvestre pushed a commit to branch scan-build-html
in repository debile-master.
commit 0b4ad3bdedf4db1ab3b9a17ad38f18edf2ef19e0
Author: Paul Tagliamonte <tag at pault.ag>
Date: Sun May 26 11:50:28 2013 -0400
meh
---
eg/config.json | 3 ++
lucy/archive.py | 24 ++++++++++++
lucy/changes.py | 2 +-
lucy/cli/incoming.py | 2 +-
lucy/incoming.py | 98 ++++++++++++++++++++++++++++++++++++++++++++++++
lucy/models/binary.py | 1 -
lucy/models/machine.py | 4 ++
setup.py | 6 +--
8 files changed, 134 insertions(+), 6 deletions(-)
diff --git a/eg/config.json b/eg/config.json
index 3659eba..783085b 100644
--- a/eg/config.json
+++ b/eg/config.json
@@ -6,6 +6,7 @@
"amd64"
],
"incoming": "/srv/lucy.pault.ag/incoming",
+ "keyring": "/var/lib/lucy/keyring",
"job_classes": {
"binary": [
"piuparts",
@@ -29,11 +30,13 @@
"_id": "leliel",
"auth": "password",
"owner": "paultag",
+ "gpg": "A998491ADCCB93C7A73A27403D3FDC7A47036CF7"
},
{
"_id": "loki",
"auth": "password",
"owner": "paultag",
+ "gpg": null
}
],
"users": [
diff --git a/lucy/archive.py b/lucy/archive.py
new file mode 100644
index 0000000..7167d90
--- /dev/null
+++ b/lucy/archive.py
@@ -0,0 +1,24 @@
+import os
+
+
+def uuid_to_path(uuid, base=None):
+ nodes = uuid.split("-")
+ ids = os.path.join(*nodes)
+ path = os.path.join(*list(nodes[-1])[:4])
+ path = os.path.join(ids, path)
+ return path
+
+
+def move_to_pool(config, package, changes, root=None):
+ pool = config['pool']
+ uid = package['_id']
+ ret = uuid_to_path(uid, base=pool)
+ path = os.path.join(pool, ret)
+ if root:
+ path = os.path.join(path, root)
+ os.makedirs(path)
+ for entry in changes.get_files():
+ bn = os.path.basename(entry)
+ dest = os.path.join(path, bn)
+ os.rename(entry, dest)
+ return ret
diff --git a/lucy/changes.py b/lucy/changes.py
index 6abe1fe..8bcfb62 100644
--- a/lucy/changes.py
+++ b/lucy/changes.py
@@ -117,7 +117,7 @@ class Changes(object):
return False
return True
- def is_binry_upload(self):
+ def is_binary_only_upload(self):
for f in self.get_files():
if not (f.endswith(".deb") or f.endswith(".udeb")):
return False
diff --git a/lucy/cli/incoming.py b/lucy/cli/incoming.py
index e82cc52..4e65dd7 100644
--- a/lucy/cli/incoming.py
+++ b/lucy/cli/incoming.py
@@ -1,5 +1,5 @@
from lucy.models.config import Config
-from lucy.archive import process
+from lucy.incoming import process
def main():
diff --git a/lucy/incoming.py b/lucy/incoming.py
new file mode 100644
index 0000000..78efef1
--- /dev/null
+++ b/lucy/incoming.py
@@ -0,0 +1,98 @@
+from lucy import User, Source, Machine, Binary
+from lucy.archive import move_to_pool
+
+from lucy.changes import parse_changes_file, ChangesFileException
+from lucy.core import get_config
+from lucy.utils import cd, fglob
+
+import os
+
+
+
+def process(config):
+ incoming = config['incoming']
+ pcf = lambda x: parse_changes_file(x, incoming)
+ with cd(incoming):
+ for changes in fglob("*changes", pcf):
+ try:
+ changes.validate()
+ except ChangesFileException:
+ reject(config, changes, "invalid")
+ continue
+ accept(config, changes)
+
+
+def accept(config, changes):
+ try:
+ changes.validate_signature()
+ except ChangesFileException:
+ return reject(config, changes, "invalid-signature")
+
+ if changes.is_source_only_upload():
+ return accept_source(config, changes)
+
+ if changes.is_binary_only_upload():
+ return accept_binary(config, changes)
+
+ return reject(config, changes, "not-only-sourceful")
+
+
+def accept_source(config, changes):
+ key = changes.validate_signature()
+
+ try:
+ who = User.get_by_key(key)
+ except KeyError:
+ return reject(changes, config, 'bad-user-account')
+
+ obj = Source(source=changes['source'],
+ version=changes['version'],
+ owner=who['_id'])
+ obj.save()
+
+ path = move_to_pool(config, obj, changes)
+ os.unlink(changes.get_filename())
+
+ print("ACCEPT: {source}/{version} for {owner} as {_id}".format(**obj))
+
+
+
+def accept_binary(config, changes):
+ key = changes.validate_signature()
+
+ arch = changes['Architecture']
+ suite = changes['Distribution']
+ binaries = changes.get_files()
+
+ try:
+ source = changes['x-lucy-source-package']
+ except KeyError:
+ return reject(config, changes, 'no-source-package')
+
+ try:
+ source = Source.load(source)
+ except KeyError:
+ return reject(config, changes, 'invalid-source-package')
+
+ try:
+ buildd = Machine.get_by_key(key)
+ except KeyError:
+ return reject(config, changes, 'youre-not-a-machine')
+
+ print("accept binary")
+ binary = Binary(source=source['_id'],
+ arch=arch,
+ suite=suite,
+ binaries=[os.path.basename(x) for x in binaries],
+ builder=buildd['_id'])
+ print(binary)
+
+ path = move_to_pool(config, source, changes, root=arch)
+ os.unlink(changes.get_filename())
+
+
+def reject(config, changes, reason):
+ print("reject", reason)
+ # email luser with reason template
+ for fpath in changes.get_files() + [changes.get_changes_file()]:
+ os.unlink(fpath)
diff --git a/lucy/models/binary.py b/lucy/models/binary.py
index 5762a84..27e625c 100644
--- a/lucy/models/binary.py
+++ b/lucy/models/binary.py
@@ -10,7 +10,6 @@ class Binary(LucyObject):
source = Source.load(source)['_id']
super(Binary, self).__init__(source=source,
- log=log,
arch=arch,
suite=suite,
builder=builder,
diff --git a/lucy/models/machine.py b/lucy/models/machine.py
index f07fc7c..471dc0e 100644
--- a/lucy/models/machine.py
+++ b/lucy/models/machine.py
@@ -15,3 +15,7 @@ class Machine(LucyObject):
def auth(self, auth):
return self['auth'] == auth
+
+ @classmethod
+ def get_by_key(cls, key):
+ return cls.single({"gpg": key})
diff --git a/setup.py b/setup.py
index 993a248..211c26c 100755
--- a/setup.py
+++ b/setup.py
@@ -20,9 +20,9 @@ setup(
platforms=['any'],
entry_points={
'console_scripts': [
-# 'lucy-nuke = lucy.cli.nuke:main',
-# 'lucy-process-incoming = lucy.cli.incoming:main',
-# 'lucy-init = lucy.cli.init:main',
+ 'lucy-nuke = lucy.cli.nuke:main',
+ 'lucy-process-incoming = lucy.cli.incoming:main',
+ 'lucy-init = lucy.cli.init:main',
# 'lucyd = lucy.server:main',
],
}
--
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