summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/manpages/git-buildpackage.sgml8
-rw-r--r--docs/manpages/git-import-dsc.sgml16
-rw-r--r--docs/manpages/git-import-orig.sgml8
-rw-r--r--gbp.conf35
-rwxr-xr-xgit-buildpackage10
-rwxr-xr-xgit-import-dsc25
-rwxr-xr-xgit-import-orig10
-rw-r--r--git_buildpackage/__init__.py2
-rw-r--r--git_buildpackage/config.py8
-rw-r--r--git_buildpackage/deb_utils.py4
-rw-r--r--git_buildpackage/git_utils.py8
11 files changed, 92 insertions, 42 deletions
diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml
index 751cf447..547f1e51 100644
--- a/docs/manpages/git-buildpackage.sgml
+++ b/docs/manpages/git-buildpackage.sgml
@@ -29,6 +29,7 @@
<arg><option>--git-sign-tags</option></arg>
<arg><option>--git-keyid=</option><replaceable>gpg-keyid</replaceable></arg>
<arg><option>--git-posttag=</option><replaceable>command</replaceable></arg>
+ <arg><option>--git-debian-tag=</option><replaceable>tag-format</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
@@ -138,6 +139,13 @@
<para>excecute <replaceable>command</replaceable> after tagging a new version</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--git-debian-tag=</option><replaceable>tag-format</replaceable>
+ </term>
+ <listitem>
+ <para>use this tag format when tagging Debian versions</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/docs/manpages/git-import-dsc.sgml b/docs/manpages/git-import-dsc.sgml
index cc56761f..559e01aa 100644
--- a/docs/manpages/git-import-dsc.sgml
+++ b/docs/manpages/git-import-dsc.sgml
@@ -25,6 +25,8 @@
<arg><option>--upstream-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--sign-tags</option></arg>
<arg><option>--keyid=</option><replaceable>gpg-keyid</replaceable></arg>
+ <arg><option>--debian-tag=</option><replaceable>tag-format</replaceable></arg>
+ <arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg choice="plain"><replaceable>debian-source.dsc</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -70,6 +72,20 @@
<para>use this keyid for gpg signing tags</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--debian-tag=</option><replaceable>tag-format</replaceable>
+ </term>
+ <listitem>
+ <para>use this tag format when tagging Debian versions</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--upstream-tag=</option><replaceable>tag-format</replaceable>
+ </term>
+ <listitem>
+ <para>use this tag format when tagging upstream versions</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/docs/manpages/git-import-orig.sgml b/docs/manpages/git-import-orig.sgml
index f223b0f4..4853e78a 100644
--- a/docs/manpages/git-import-orig.sgml
+++ b/docs/manpages/git-import-orig.sgml
@@ -27,6 +27,7 @@
<arg><option>--upstream-version=</option><replaceable>version</replaceable></arg>
<arg><option>--sign-tags</option></arg>
<arg><option>--keyid=</option><replaceable>gpg-keyid</replaceable></arg>
+ <arg><option>--upstream-tag=</option><replaceable>tag-format</replaceable></arg>
<arg choice="plain"><replaceable>upstream-source</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -94,6 +95,13 @@
<para>use this keyid for gpg signing tags</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--upstream-tag=</option><replaceable>tag-format</replaceable>
+ </term>
+ <listitem>
+ <para>use this tag format when tagging upstream versions</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<refsect1>
diff --git a/gbp.conf b/gbp.conf
index 98d8aa54..c4d0774b 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -1,29 +1,32 @@
# Configuration file for git-buildpackage and friends
[DEFAULT]
-# the default build command
-#builder=debuild
-# the default branch for upstream sources
-#upstream-branch=upstream
-# the default branch for the debian patch
-#debian-branch=master
+# the default build command:
+#builder = debuild
+# the default branch for upstream sources:
+#upstream-branch = upstream
+# the default branch for the debian patch:
+#debian-branch = master
+# the default tag formats used:
+#upstream-tag = upstream/%(version)s
+#debian-tag = debian/%(version)s
-# Special options for git-buildpackage
+# Options only for git-buildpackage
[git-buildpackage]
-#upstream-branch=dfsgclean
-# Uncomment this to automatically GPG sign tags
+#upstream-branch = dfsgclean
+# uncomment this to automatically GPG sign tags
#sign-tags = True
-# Keyid to GPG sign tags with
+# keyid to GPG sign tags with
#keyid = 0xdeadbeef
-# Push to a remote repository after a successful tag:
+# push to a remote repository after a successful tag:
#posttag = git-push git.example.com
-# Special options for git-import-orig
+# Options only for git-import-orig
[git-import-orig]
-#upstream-branch=newupstream
-#debian-branch=dfsgclean
+#upstream-branch = newupstream
+#debian-branch = dfsgclean
-# Special options for git-import-dsc
+# Options only for git-import-dsc
[git-import-dsc]
-#upstream-branch=svn-upstream
+#upstream-branch = svn-upstream
diff --git a/git-buildpackage b/git-buildpackage
index cd3749d6..621c406a 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -22,7 +22,7 @@ import sys,os,os.path,pipes
from git_buildpackage import GitTag, Command, CommandExecFailed
from git_buildpackage.git_utils import (GitRepositoryError,
GitRepository,
- sanitize_version)
+ build_tag)
from git_buildpackage.deb_utils import (parse_changelog,
is_native,
orig_file,
@@ -73,9 +73,9 @@ def main(argv):
parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
parser.add_config_file_option(option_name="builder", dest="build_cmd",
- help="command to build the package e.g. default is '%(builder)s'")
+ help="command to build the package, default is '%(builder)s'")
parser.add_config_file_option(option_name="cleaner", dest="clean_cmd",
- help="command to build the package e.g. default is '%(cleaner)s'")
+ help="command to build the package, default is '%(cleaner)s'")
parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
help="upstream branch, default is '%(upstream-branch)s'")
parser.add_config_file_option(option_name="debian-branch", dest='debian_branch',
@@ -86,6 +86,8 @@ def main(argv):
help="hook to execute after a successfull tag operation")
parser.add_config_file_option(option_name="keyid", dest="keyid",
help="GPG keyid to sign tags with")
+ parser.add_config_file_option(option_name="debian-tag", dest="debian_tag",
+ help="Format string for debian tags, default is '%(debian-tag)s'")
(options, args) = parser.parse_args(args)
if options.verbose:
@@ -126,7 +128,7 @@ def main(argv):
raise GbpError, "Can't parse version from changes file"
else:
print "Tagging", version
- GitTag(options.sign_tag, options.keyid)(sanitize_version(version))
+ GitTag(options.sign_tag, options.keyid)(build_tag(options.debian_tag, version))
if(options.posttag_hook):
Command(options.posttag_hook, shell=True)()
except CommandExecFailed:
diff --git a/git-import-dsc b/git-import-dsc
index b1e8b97a..3bd2d50d 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -25,7 +25,7 @@ import tempfile
import glob
import git_buildpackage
from git_buildpackage.deb_utils import debian_version_chars
-from git_buildpackage.git_utils import sanitize_version
+from git_buildpackage.git_utils import build_tag
from git_buildpackage.config import GBPOptionParser
@@ -82,10 +82,10 @@ def parse_dsc(dscfile):
return dsc
-def import_upstream(src, dirs, upstream_branch, tagger):
+def import_upstream(src, dirs, options, tagger):
"""
- import a new upstream version on the upstream branch and tag
- appropriately
+ import a new upstream version, create the upstream branch in case of a non
+ debian native package and tag appropriately
"""
try:
unpackTGZ = git_buildpackage.UnpackTGZ(src.tgz, dirs['tmp'])
@@ -103,9 +103,10 @@ def import_upstream(src, dirs, upstream_branch, tagger):
git_buildpackage.GitCommitAll()(
msg="Imported %s version %s" % (['upstream', 'Debian'][src.native],
src.upstream_version))
- tagger(sanitize_version(src.upstream_version))
+ format = [options.upstream_tag, options.debian_tag][src.native]
+ tagger(build_tag(format, src.upstream_version))
if not src.native:
- git_buildpackage.GitBranch()(upstream_branch)
+ git_buildpackage.GitBranch()(options.upstream_branch)
except git_buildpackage.CommandExecFailed:
print >>sys.stderr,"Creation of git repository failed"
git_buildpackage.RemoveTree(unpackTGZ.dir)()
@@ -113,13 +114,13 @@ def import_upstream(src, dirs, upstream_branch, tagger):
return True
-def apply_debian_patch(src, dirs, tagger):
+def apply_debian_patch(src, dirs, options, tagger):
"""apply the debian patch and tag appropriately"""
try:
git_buildpackage.DpkgSourceExtract()(src.dscfile, dirs['dpkg-src'])
os.chdir(dirs['git'])
git_buildpackage.GitLoadDirs()(dirs['dpkg-src'], 'Imported Debian patch')
- tagger(sanitize_version('%s-%s' % (src.upstream_version, src.debian_version)))
+ tagger(build_tag(options.debian_tag, '%s-%s' % (src.upstream_version, src.debian_version)))
except git_buildpackage.CommandExecFailed:
print >>sys.stderr,"Failed to import Debian package"
return False
@@ -153,6 +154,10 @@ def main(argv):
help="sign git tags", action="store_true")
parser.add_config_file_option(option_name="keyid", dest="keyid",
help="GPG keyid to sign tags with")
+ parser.add_config_file_option(option_name="debian-tag", dest="debian_tag",
+ help="Format string for debian tags, default is '%(debian-tag)s'")
+ parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
+ help="Format string for upstream tags, default is '%(upstream-tag)s'")
(options, args) = parser.parse_args(argv[1:])
if options.verbose:
@@ -169,7 +174,7 @@ def main(argv):
return 1
dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='.'))
- if not import_upstream(src, dirs, options.upstream_branch, gitTag):
+ if not import_upstream(src, dirs, options, gitTag):
return 1
os.chdir(dirs['top'])
if not src.native:
@@ -177,7 +182,7 @@ def main(argv):
os.mkdir(dirs['unpack'])
dirs['dpkg-src'] = os.path.join(dirs['unpack'],
"%s-%s-%s" % (src.pkg, src.upstream_version, src.debian_version))
- if not apply_debian_patch(src, dirs, gitTag):
+ if not apply_debian_patch(src, dirs, options, gitTag):
return 1
os.chdir(dirs['top'])
if not move_tree(src, dirs):
diff --git a/git-import-orig b/git-import-orig
index 3df66392..62935ef2 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -26,7 +26,7 @@ import glob
import git_buildpackage
from git_buildpackage.git_utils import (GitRepositoryError,
GitRepository,
- sanitize_version)
+ build_tag)
from git_buildpackage.config import GBPOptionParser
@@ -72,6 +72,8 @@ def main(argv):
help="sign git tags", action="store_true")
parser.add_config_file_option(option_name="keyid", dest="keyid",
help="GPG keyid to sign tags with")
+ parser.add_config_file_option(option_name="upstream-tag", dest="upstream_tag",
+ help="Format string for upstream tags, default is '%(upstream-tag)s'")
(options, args) = parser.parse_args(argv[1:])
gitCheckoutUpstream = git_buildpackage.GitCheckoutBranch(options.upstream)
@@ -89,7 +91,7 @@ def main(argv):
tgz = args[0]
try:
- repo=GitRepository('.')
+ repo = GitRepository('.')
except GitRepositoryError:
print >>sys.stderr,"%s is not a git repository" % (os.path.abspath('.'))
return 1
@@ -125,14 +127,14 @@ create it otherwise use --upstream-branch to specify it.
else:
if options.verbose:
print "Unpacked orig to %s" % tmpdir
- origdir=glob.glob(tmpdir+'/*')[0]
+ origdir = glob.glob(tmpdir+'/*')[0]
try:
print "Importing %s to upstream branch..." % tgz
gitCheckoutUpstream()
gitShowBranch()
git_buildpackage.GitLoadDirs()(origdir)
- git_buildpackage.GitTag(options.sign_tags, options.keyid)(sanitize_version(version))
+ git_buildpackage.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version))
if options.merge:
print "Merging to %s" % (options.debian,)
diff --git a/git_buildpackage/__init__.py b/git_buildpackage/__init__.py
index 4cac9cf5..99251094 100644
--- a/git_buildpackage/__init__.py
+++ b/git_buildpackage/__init__.py
@@ -98,7 +98,7 @@ class GitLoadDirs(Command):
def __call__(self, dir, log=''):
self.dir = dir
self.run_error = "Couldn't import %s" % self.dir
- args =[ [],['-L', log] ] [len(log) > 0]
+ args = [ [], ['-L', log] ] [len(log) > 0]
Command.__call__(self, args+[dir])
diff --git a/git_buildpackage/config.py b/git_buildpackage/config.py
index 67b2be15..3f71817f 100644
--- a/git_buildpackage/config.py
+++ b/git_buildpackage/config.py
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
-#
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
-"""handles command line and config file option parsing for the git-buildpackage"""
+"""handles command line and config file option parsing for the gbp commands"""
from optparse import OptionParser
from ConfigParser import SafeConfigParser
@@ -26,10 +25,11 @@ class GBPOptionParser(OptionParser):
'cleaner' : 'debuild clean',
'debian-branch' : 'master',
'upstream-branch' : 'upstream',
- 'upstream-branch' : 'upstream',
'sign-tags' : '', # empty means False
'keyid' : '',
'posttag' : '',
+ 'debian-tag' : 'debian/%(version)s',
+ 'upstream-tag' : 'upstream/%(version)s',
}
config_files=['/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),
@@ -41,7 +41,7 @@ class GBPOptionParser(OptionParser):
parser.read(self.config_files)
self.config=dict(parser.defaults())
if parser.has_section(self.command):
- self.config=dict(parser.items(self.command))
+ self.config=dict(parser.items(self.command, raw=True))
def __init__(self, command, prefix='', usage=None):
self.command=command
diff --git a/git_buildpackage/deb_utils.py b/git_buildpackage/deb_utils.py
index cdcad487..8121ca70 100644
--- a/git_buildpackage/deb_utils.py
+++ b/git_buildpackage/deb_utils.py
@@ -8,14 +8,14 @@ import os
# When trying to parse a version-number from a dsc or changes file, these are
# the valid characters.
-debian_version_chars='a-zA-Z\d.~+-'
+debian_version_chars = 'a-zA-Z\d.~+-'
def parse_changelog(changelog):
"""parse changelog file changelog"""
status, output = commands.getstatusoutput('dpkg-parsechangelog -l%s' % (changelog, ))
if status:
return None
- cp=email.message_from_string(output)
+ cp = email.message_from_string(output)
if '-' in cp['Version']:
cp['Upstream-Version'], cp['Debian-Version'] = cp['Version'].rsplit('-', 1)
else:
diff --git a/git_buildpackage/git_utils.py b/git_buildpackage/git_utils.py
index 0c561958..4859a71d 100644
--- a/git_buildpackage/git_utils.py
+++ b/git_buildpackage/git_utils.py
@@ -7,6 +7,7 @@ import subprocess
import os.path
class GitRepositoryError(Exception):
+ """Exception thrown by GitRepository"""
pass
@@ -64,10 +65,15 @@ class GitRepository(object):
return (ret, "".join(out))
+def build_tag(format, version):
+ """Generate a tag from a given format and a version"""
+ return format % dict(version=sanitize_version(version))
+
+
def sanitize_version(version):
"""sanitize a version so git accepts it as a tag"""
if ':' in version: # strip of any epochs
- version=version.split(':', 1)[1]
+ version = version.split(':', 1)[1]
return version.replace('~', '.')
# vim:et:ts=4:sw=4: