]> Frank Brehm's Git Trees - profitbricks/jenkins-build-scripts.git/commitdiff
debian_build.py: Use sbuild instead of pbuilder.
authorBenjamin Drung <benjamin.drung@profitbricks.com>
Wed, 23 Jul 2014 14:20:10 +0000 (16:20 +0200)
committerBenjamin Drung <benjamin.drung@profitbricks.com>
Wed, 23 Jul 2014 14:20:10 +0000 (16:20 +0200)
debian_build.py
lib/sbuild.py [new file with mode: 0644]

index b07353a73b0ee040cf339f990a1a4ced10b6e8e1..f7d46449cdebce86f24db8a2763b350f92a508de 100755 (executable)
@@ -25,7 +25,7 @@ from common_code import (figlet, logger_init, exit_ok, exit_error, ENV, BIN_SUDO
 from db_add import add_package_instances
 from lib import dput
 from lib import gitpkg
-from lib import pbuilder
+from lib import sbuild
 
 
 # from common_code
@@ -595,17 +595,17 @@ if __name__ == '__main__':
     ret = source_builder.build()
 
     #
-    # ACT V: build the binary with pbuilder from the created source tarball
+    # ACT V: build the binary with sbuild from the created source tarball
     #
-    builder = pbuilder.Pbuilder(
+    builder = sbuild.Sbuild(
         dsc_file=source_builder.dsc_file,
-        dist=curr_dist,
-        arch='amd64',
-        git_commit_id=curr_commit_hexsha[0:7],
+        dist=new_dist,
+        chroot='pb-'+curr_dist,
+        arch='amd64'
     )
     if ret == 0:
         logger.info('Current environment:\n\n{env}\n'.format(env=builder.env))
-        logger.info('Start building the binary package with pbuilder...\n')
+        logger.info('Start building the binary package with sbuild...\n')
         ret = builder.build()
 
     # .. remove last commit (the one where we added the changelog entry)
@@ -643,7 +643,7 @@ export {builder_env} FORCE_SHELL=TRUE
     # .. and finally handle the result
     if ret:
         build_failed = True
-        logger.error('git-buildpackage failed with exitcode {code}'.format(code=ret))
+        logger.error('sbuild failed with exitcode {code}'.format(code=ret))
         figlet('Build failed')
         failed_message = 'package build has failed'
         do_cidb = False
diff --git a/lib/sbuild.py b/lib/sbuild.py
new file mode 100644 (file)
index 0000000..82e8957
--- /dev/null
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+"""
+@author: Benjamin Drung <benjamin.drung@profitbricks.com>
+"""
+
+import os
+import sys
+import subprocess
+
+SBUILD = 'sbuild'
+
+
+class Sbuild(object):
+    def __init__(self, dsc_file=None, dist=None, chroot=None, arch=None):
+        '''
+        TODO
+        '''
+        self.dsc_file = dsc_file
+        self.arch = arch
+        self.chroot = chroot
+        self.dist = dist
+
+    @property
+    def env(self):
+        '''
+        TODO
+        '''
+        result = os.environ
+        return result
+
+    @property
+    def command(self):
+        '''
+        TODO
+        '''
+        result = [
+            SBUILD,
+            '-d', self.dist,
+            '-c', self.chroot,
+            '--arch=' + self.arch,
+            self.dsc_file,
+        ]
+        return result
+
+    def build(self):
+        '''
+        TODO
+        '''
+        # if we would build orig.tar.gz we would need to be able to access
+        # them later, which we probably could achieve with using pristine-tar
+        # and storing that in the git repo - but this has the downside that
+        # the jenkins build job would need to push this back into the git repo
+        # (so this makes things complicated) and then still, we could not
+        # gurantee that this orig.tar.gz actually reflects the git repo at
+        # that point.
+        # So in summary, it would be expensive and buys as nothing, as we
+        # can always generate the source from said git repos...
+
+        cmdobj = subprocess.Popen(
+            self.command,
+            shell=False,
+            close_fds=True,
+            #stdout=subprocess.PIPE,
+            #stderr=subprocess.PIPE,
+            stdout=sys.stdout,
+            stderr=sys.stderr,
+            env=self.env,
+            cwd=os.getcwd(),
+        )
+
+        ret = cmdobj.wait()
+        return ret