[Pkg-debile-commits] [debile-slave] 11/100: more meh

Sylvestre Ledru sylvestre at alioth.debian.org
Mon Aug 19 14:52:59 UTC 2013


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

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

commit 11d51dae13833285ac3b64fdf967a8d3609a951a
Author: Paul Tagliamonte <tag at pault.ag>
Date:   Wed May 22 19:32:57 2013 -0400

    more meh
---
 ethel/chroot.py            |   23 +----------------------
 ethel/commands/piuparts.py |    4 +++-
 ethel/commands/sbuild.py   |   24 ++++++++++++++++++++++++
 ethel/daemon.py            |   29 +++++++++++++++++++++++++++++
 ethel/utils.py             |   34 ++++++++++++++++++++++++++++++----
 setup.py                   |    4 +++-
 6 files changed, 90 insertions(+), 28 deletions(-)

diff --git a/ethel/chroot.py b/ethel/chroot.py
index 56cdc3c..13944aa 100644
--- a/ethel/chroot.py
+++ b/ethel/chroot.py
@@ -1,5 +1,4 @@
-from ethel.utils import run_command
-from ethel.error import EthelError
+from ethel.utils import run_command, safe_run, EthelSubprocessError
 
 import configparser
 import contextlib
@@ -8,15 +7,6 @@ import sys
 import os
 
 
-class EthelSubprocessError(EthelError):
-    def __init__(self, out, err, ret, cmd):
-        super(EthelError, self).__init__()
-        self.out = out
-        self.err = err
-        self.ret = ret
-        self.cmd = cmd
-
-
 def get_session_file(session):
     return '/var/lib/schroot/session/%s' % (session)
 
@@ -44,17 +34,6 @@ def get_tarball(chroot):
     return obj['file']
 
 
-def safe_run(cmd, expected=0):
-    out, err, ret = run_command(cmd)
-    out, err = (x.decode('utf-8') for x in (out, err))
-
-    if ret != expected:
-        e = EthelSubprocessError(out, err, ret, cmd)
-        raise e
-
-    return out, err
-
-
 def scmd(session, command, expected=0, user=None):
     cmds = ['schroot', '-r', '-c', session]
     if user:
diff --git a/ethel/commands/piuparts.py b/ethel/commands/piuparts.py
index c5bd7c8..2fbc92b 100644
--- a/ethel/commands/piuparts.py
+++ b/ethel/commands/piuparts.py
@@ -1,4 +1,6 @@
-from ethel.chroot import schroot, copy, scmd, get_tarball, EthelSubprocessError
+from ethel.chroot import schroot, copy, scmd, get_tarball
+from ethel.utils import EthelSubprocessError
+
 from firehose.model import Issue, Message, File, Location
 from storz.wrapper import generate_analysis
 
diff --git a/ethel/commands/sbuild.py b/ethel/commands/sbuild.py
new file mode 100644
index 0000000..aed2bb3
--- /dev/null
+++ b/ethel/commands/sbuild.py
@@ -0,0 +1,24 @@
+from ethel.utils import safe_run, run_command, tdir
+
+from contextlib import contextmanager
+import sys
+import os
+
+
+def sbuild(package, dist, chroot):
+    out, err, ret = run_command([
+        "sbuild",
+        "-c", chroot,
+        "-v",
+        "--source",
+        "-A",
+        "-d", dist,
+        "-j", "8",
+        package,
+    ])
+    out, err = out.decode('utf-8'), err.decode('utf-8')
+    return out, err, ret
+
+
+def main():
+    sbuild(*sys.argv[1:])
diff --git a/ethel/daemon.py b/ethel/daemon.py
new file mode 100644
index 0000000..d46d16b
--- /dev/null
+++ b/ethel/daemon.py
@@ -0,0 +1,29 @@
+from ethel.commands.sbuild import sbuild
+from ethel.utils import tdir, dget
+
+import glob
+import os
+
+
+def binary_build(package, chroot):
+    dist, _ = chroot.split("-", 1)
+    print("sbuilding %s - %s / %s" % (package, dist, chroot))
+    sbuild(package, dist, chroot)
+    #piuparts
+    #lintian
+    #adequate
+
+
+
+def daemon():
+    with tdir() as where:
+        os.chdir(where)
+
+        print("Fetching..")
+        dget("http://localhost/pool/9d0aa4bc/c250/11e2/"
+             "8600/3859f9e5ff01/3/8/5/9/fluxbox_1.3.5-1.dsc")
+
+        for package in glob.glob("*dsc"):
+            print("Building %s" % (package))
+            package = os.path.abspath(package)
+            binary_build(package, 'unstable-amd64')
diff --git a/ethel/utils.py b/ethel/utils.py
index e74426f..3728edd 100644
--- a/ethel/utils.py
+++ b/ethel/utils.py
@@ -1,17 +1,19 @@
+from ethel.error import EthelError
+
 from contextlib import contextmanager
 import subprocess
 import tempfile
+import shutil
 import shlex
-import os
 
 
 @contextmanager
-def tfile():
-    _, fp = tempfile.mkstemp()
+def tdir():
+    fp = tempfile.mkdtemp()
     try:
         yield fp
     finally:
-        os.unlink(fp)
+        shutil.rmtree(fp)
 
 
 def run_command(command, stdin=None):
@@ -31,3 +33,27 @@ def run_command(command, stdin=None):
 
     (output, stderr) = pipe.communicate(**kwargs)
     return (output, stderr, pipe.returncode)
+
+
+def safe_run(cmd, expected=0):
+    out, err, ret = run_command(cmd)
+    out, err = (x.decode('utf-8') for x in (out, err))
+
+    if ret != expected:
+        e = EthelSubprocessError(out, err, ret, cmd)
+        raise e
+
+    return out, err
+
+
+def dget(url):
+    safe_run(["dget", "-u", "-d", url])
+
+
+class EthelSubprocessError(EthelError):
+    def __init__(self, out, err, ret, cmd):
+        super(EthelError, self).__init__()
+        self.out = out
+        self.err = err
+        self.ret = ret
+        self.cmd = cmd
diff --git a/setup.py b/setup.py
index affb7a5..1aff8b7 100755
--- a/setup.py
+++ b/setup.py
@@ -20,11 +20,13 @@ setup(
     platforms=['any'],
     entry_points = {
         'console_scripts': [
-            'ethel-submit = ethel.cli:submit',
             'ethel-next = ethel.cli:next',
+            'etheld = ethel.daemon:daemon',
             'ethel-close = ethel.cli:close',
+            'ethel-submit = ethel.cli:submit',
             'ethel-dget-url = ethel.cli:dget',
             'ethel-update = ethel.chroot:run_update',
+            'ethel-sbuild = ethel.commands.sbuild:main',
             'ethel-adequate = ethel.commands.adequate:main',
             'ethel-piuparts = ethel.commands.piuparts:main',
         ],

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



More information about the Pkg-debile-commits mailing list