From: Mathias Klette Date: Wed, 5 Jun 2013 17:28:17 +0000 (+0200) Subject: git_buildpackage: make env and command properties, usable by debian_build X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=ad3103c8d5a739fc7385f0b0f12445c95af75368;p=profitbricks%2Fjenkins-build-scripts.git git_buildpackage: make env and command properties, usable by debian_build --- diff --git a/lib/git_buildpackage.py b/lib/git_buildpackage.py index e03e48e..b84faeb 100644 --- a/lib/git_buildpackage.py +++ b/lib/git_buildpackage.py @@ -12,8 +12,17 @@ BIN_GIT_BUILDPACKAGE = '/usr/bin/git-buildpackage' BIN_SUDO = '/usr/bin/sudo' class GitBuildPackage(object): - def __init__(self, upstream_branch=None, - debian_branch=None, dist=None, arch=None, pb_suite=None, git_commit_id=None): + def __init__(self, + upstream_branch=None, + debian_branch=None, + dist=None, + arch=None, + pb_suite=None, + git_commit_id=None + ): + ''' + TODO + ''' self.upstream_branch = upstream_branch self.debian_branch = debian_branch self.dist = dist @@ -21,8 +30,23 @@ class GitBuildPackage(object): self.pb_suite = pb_suite self.git_commit_id = git_commit_id - def build(self): - cmd = [ + @property + def env(self): + ''' + TODO + ''' + result = os.environ + result['DIST'] = self.dist + result['PB_SUITE'] = self.pb_suite + result['GIT_COMMIT_ID'] = self.git_commit_id + return result + + @property + def command(self): + ''' + TODO + ''' + result = [ BIN_SUDO, BIN_GIT_BUILDPACKAGE, '--git-upstream-branch=%s' %(self.upstream_branch), @@ -30,6 +54,12 @@ class GitBuildPackage(object): '--git-ignore-new', '--debbuildopts', '-b' # don't build source packages... see directly below ] + 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 @@ -40,33 +70,28 @@ class GitBuildPackage(object): # So in summary, it would be expensive and buys as nothing, as we # can always generate the source from said git repos... - env = os.environ - env['DIST'] = self.dist - env['PB_SUITE'] = self.pb_suite - env['GIT_COMMIT_ID'] = self.git_commit_id - logger.debug( 'Trying to call "%s" with environment export %s' %( - ' '.join(cmd), + ' '.join(self.command), ' '.join( map( lambda x: '%s="%s"' %(x[0], x[1]), - env.iteritems() + self.env.iteritems() ) ) ) ) cmdobj = subprocess.Popen( - cmd, + self.command, shell=False, close_fds=True, #stdout=subprocess.PIPE, #stderr=subprocess.PIPE, stdout=sys.stdout, stderr=sys.stderr, - env=env, + env=self.env, cwd=os.getcwd(), ) @@ -74,17 +99,8 @@ class GitBuildPackage(object): if ret: logger.error( '"%s" returned non-zero. exitcode was: %s' - %(' '.join(cmd), ret) + %(' '.join(self.command), ret) ) -# error_str = cmdobj.stderr.read() -# if not error_str: -# error_str = cmdobj.stdout.read() -# if not error_str: -# error_str = 'No Error Msg found' -# logger.error( -# '%s returned with %s. Output was: %s' -# %(' '.join(cmd), ret, error_str) -# ) return ret