From: Benjamin Drung Date: Wed, 23 Jul 2014 14:20:10 +0000 (+0200) Subject: debian_build.py: Use sbuild instead of pbuilder. X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=c73846448988cca3821600045b4978dde85165cc;p=profitbricks%2Fjenkins-build-scripts.git debian_build.py: Use sbuild instead of pbuilder. --- diff --git a/debian_build.py b/debian_build.py index b07353a..f7d4644 100755 --- a/debian_build.py +++ b/debian_build.py @@ -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 index 0000000..82e8957 --- /dev/null +++ b/lib/sbuild.py @@ -0,0 +1,72 @@ +# -*- coding: utf-8 -*- +""" +@author: Benjamin Drung +""" + +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