Commit 8533d09a authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Add support for newer versions of git-buildpackage

In newer versions of git-buildpackage, the various git-* executables
have been replaced with a single gbp one that expects the command as
the first argument. Hence, "git-buildpackage" is replaced with: "gbp
parent fee46803
......@@ -35,10 +35,22 @@
import os
import sys
import subprocess
from git import GitCommandError
from optparse import OptionParser
from sh import mktemp, cd, rm, git_dch # pylint: disable=E0611
from sh import mktemp, cd, rm # pylint: disable=E0611
from functools import partial
from sh import git_dch as gbp_dch # pylint: disable=E0611
gbp_buildpackage = ['git-buildpackage']
except ImportError:
# In newer versions of git-buildpackage the executables have changed.
# Instead of having various git-* executables, there is only a gbp one,
# which expects the command (dch, buildpackage, etc) as the first argument.
from sh import gbp # pylint: disable=E0611
gbp_dch = partial(gbp, 'dch')
gbp_buildpackage = ['gbp', 'buildpackage']
from devflow import versioning
from devflow import utils
......@@ -270,7 +282,7 @@ def main():
repo.git.tag(upstream_tag, branch)
# Update changelog
dch = git_dch("--debian-branch=%s" % debian_branch,
dch = gbp_dch("--debian-branch=%s" % debian_branch,
......@@ -294,7 +306,7 @@ def main():
if mode == "release":
call("vim debian/changelog")
subprocess.check_call(['editor', "debian/changelog"])
# Add changelog to INDEX
......@@ -320,19 +332,25 @@ def main():
# Export version info to debuilg environment
os.environ["DEB_DEVFLOW_DEBIAN_VERSION"] = debian_version
os.environ["DEB_DEVFLOW_VERSION"] = python_version
build_cmd = "git-buildpackage --git-export-dir=%s"\
" --git-upstream-branch=%s --git-debian-branch=%s"\
" --git-export=INDEX --git-ignore-new -sa"\
" --source-option=--auto-commit"\
" --git-upstream-tag=%s"\
% (build_dir, branch, debian_branch, upstream_tag)
args = list(gbp_buildpackage)
args.extend(["--git-export-dir=%s" % build_dir,
"--git-upstream-branch=%s" % branch,
"--git-debian-branch=%s" % debian_branch,
" --source-option=--auto-commit",
" --git-upstream-tag=%s" % upstream_tag])
if options.source_only:
build_cmd += " -S"
if not options.sign:
build_cmd += " -uc -us"
args.extend(["-uc", "-us"])
elif options.keyid:
build_cmd += " -k\"'%s'\"" % options.keyid
args.append("-k\"'%s'\"" % options.keyid)
# Remove cloned repo
if mode != 'release' and not options.keep_repo:
......@@ -372,11 +390,5 @@ def create_temp_directory(suffix):
return create_dir_cmd.stdout.strip()
def call(cmd):
rc = os.system(cmd)
if rc:
raise RuntimeError("Command '%s' failed!" % cmd)
if __name__ == "__main__":
import os
import re
import subprocess
import logging
......@@ -9,7 +10,6 @@ from argparse import ArgumentParser
os.environ["GIT_PYTHON_TRACE"] = "full"
from devflow import utils, versioning, RC_RE
from devflow.version import __version__
from devflow.autopkg import call
from devflow.ui import query_action, query_user, query_yes_no
from functools import wraps, partial
from contextlib import contextmanager
......@@ -51,7 +51,7 @@ def conflicts():
f = open(tmpbashrc, 'w')
f.write("source $HOME/.bashrc ; export PS1=(Conflict)\"$PS1\"")
call('bash --rcfile %s' % tmpbashrc)
subprocess.check_call(['bash', '--rcfile', tmpbashrc])
......@@ -197,10 +197,7 @@ class GitManager(object):
editor = os.getenv('EDITOR')
if not editor:
editor = 'vim'
call("%s %s" % (editor, changelog))
subprocess.check_call(['editor', changelog])
repo.git.commit(m="Update changelog")
print "Updated changelog on branch %s" % branch
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment