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
 buildpackage"
parent fee46803
...@@ -35,10 +35,22 @@ ...@@ -35,10 +35,22 @@
import os import os
import sys import sys
import subprocess
from git import GitCommandError from git import GitCommandError
from optparse import OptionParser 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
try:
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 versioning
from devflow import utils from devflow import utils
...@@ -270,7 +282,7 @@ def main(): ...@@ -270,7 +282,7 @@ def main():
repo.git.tag(upstream_tag, branch) repo.git.tag(upstream_tag, branch)
# Update changelog # Update changelog
dch = git_dch("--debian-branch=%s" % debian_branch, dch = gbp_dch("--debian-branch=%s" % debian_branch,
"--git-author", "--git-author",
"--ignore-regex=\".*\"", "--ignore-regex=\".*\"",
"--multimaint-merge", "--multimaint-merge",
...@@ -294,7 +306,7 @@ def main(): ...@@ -294,7 +306,7 @@ def main():
f.close() f.close()
if mode == "release": if mode == "release":
call("vim debian/changelog") subprocess.check_call(['editor', "debian/changelog"])
# Add changelog to INDEX # Add changelog to INDEX
repo.git.add("debian/changelog") repo.git.add("debian/changelog")
...@@ -320,19 +332,25 @@ def main(): ...@@ -320,19 +332,25 @@ def main():
# Export version info to debuilg environment # Export version info to debuilg environment
os.environ["DEB_DEVFLOW_DEBIAN_VERSION"] = debian_version os.environ["DEB_DEVFLOW_DEBIAN_VERSION"] = debian_version
os.environ["DEB_DEVFLOW_VERSION"] = python_version os.environ["DEB_DEVFLOW_VERSION"] = python_version
build_cmd = "git-buildpackage --git-export-dir=%s"\
" --git-upstream-branch=%s --git-debian-branch=%s"\ args = list(gbp_buildpackage)
" --git-export=INDEX --git-ignore-new -sa"\ args.extend(["--git-export-dir=%s" % build_dir,
" --source-option=--auto-commit"\ "--git-upstream-branch=%s" % branch,
" --git-upstream-tag=%s"\ "--git-debian-branch=%s" % debian_branch,
% (build_dir, branch, debian_branch, upstream_tag) "--git-export=INDEX",
"--git-ignore-new",
"-sa",
" --source-option=--auto-commit",
" --git-upstream-tag=%s" % upstream_tag])
if options.source_only: if options.source_only:
build_cmd += " -S" args.append("-S")
if not options.sign: if not options.sign:
build_cmd += " -uc -us" args.extend(["-uc", "-us"])
elif options.keyid: elif options.keyid:
build_cmd += " -k\"'%s'\"" % options.keyid args.append("-k\"'%s'\"" % options.keyid)
call(build_cmd)
subprocess.check_call(args)
# Remove cloned repo # Remove cloned repo
if mode != 'release' and not options.keep_repo: if mode != 'release' and not options.keep_repo:
...@@ -372,11 +390,5 @@ def create_temp_directory(suffix): ...@@ -372,11 +390,5 @@ def create_temp_directory(suffix):
return create_dir_cmd.stdout.strip() return create_dir_cmd.stdout.strip()
def call(cmd):
rc = os.system(cmd)
if rc:
raise RuntimeError("Command '%s' failed!" % cmd)
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(main()) sys.exit(main())
import os import os
import re import re
import subprocess
import logging import logging
logging.basicConfig() logging.basicConfig()
...@@ -9,7 +10,6 @@ from argparse import ArgumentParser ...@@ -9,7 +10,6 @@ from argparse import ArgumentParser
os.environ["GIT_PYTHON_TRACE"] = "full" os.environ["GIT_PYTHON_TRACE"] = "full"
from devflow import utils, versioning, RC_RE from devflow import utils, versioning, RC_RE
from devflow.version import __version__ from devflow.version import __version__
from devflow.autopkg import call
from devflow.ui import query_action, query_user, query_yes_no from devflow.ui import query_action, query_user, query_yes_no
from functools import wraps, partial from functools import wraps, partial
from contextlib import contextmanager from contextlib import contextmanager
...@@ -51,7 +51,7 @@ def conflicts(): ...@@ -51,7 +51,7 @@ def conflicts():
f = open(tmpbashrc, 'w') f = open(tmpbashrc, 'w')
f.write("source $HOME/.bashrc ; export PS1=(Conflict)\"$PS1\"") f.write("source $HOME/.bashrc ; export PS1=(Conflict)\"$PS1\"")
f.close() f.close()
call('bash --rcfile %s' % tmpbashrc) subprocess.check_call(['bash', '--rcfile', tmpbashrc])
os.unlink(tmpbashrc) os.unlink(tmpbashrc)
else: else:
raise raise
...@@ -197,10 +197,7 @@ class GitManager(object): ...@@ -197,10 +197,7 @@ class GitManager(object):
f.writelines(lines) f.writelines(lines)
f.close() f.close()
editor = os.getenv('EDITOR') subprocess.check_call(['editor', changelog])
if not editor:
editor = 'vim'
call("%s %s" % (editor, changelog))
repo.git.add(changelog) repo.git.add(changelog)
repo.git.commit(m="Update changelog") repo.git.commit(m="Update changelog")
print "Updated changelog on branch %s" % branch 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