summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README1
-rw-r--r--TODO3
-rw-r--r--debian/changelog6
-rw-r--r--docs/manpages/git-buildpackage.sgml35
-rw-r--r--docs/manpages/git-import-dsc.sgml26
-rw-r--r--docs/manpages/git-import-orig.sgml25
-rw-r--r--gbp.conf23
-rwxr-xr-xgit-buildpackage18
-rwxr-xr-xgit-import-dsc16
-rwxr-xr-xgit-import-orig19
-rw-r--r--git_buildpackage/__init__.py28
-rw-r--r--git_buildpackage/config.py61
-rw-r--r--git_buildpackage/deb_utils.py2
-rw-r--r--git_buildpackage/git_utils.py2
-rw-r--r--setup.py3
15 files changed, 233 insertions, 35 deletions
diff --git a/README b/README
index a5da6053..91b7a795 100644
--- a/README
+++ b/README
@@ -14,3 +14,4 @@ This is a bunch of scripts to ease the development of Debian packages with git:
--git-ignore-new: ignore uncommited changes
--git-tag: tag after building (version number is fetched from the changelog)
+See the manpages for more details.
diff --git a/TODO b/TODO
index 61706286..2c885d59 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,7 @@
-- (global/per user/per repository) config files
- git-buildpackage:
- allow to export the hole source tree to tmpdir before building
- easy push/pull to/from remote repositories (like alioth) after a
- successful build/for getting the sources
+ successful build/for getting the sources (--git-post-tag-hook)
- git-import-orig:
- allow to import from an unpacked source tree
- git-import-dsc:
diff --git a/debian/changelog b/debian/changelog
index 13f91399..b4c3b594 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+git-buildpackage (0.2.14) experimental; urgency=low
+
+ * config file parsing to set default branches and build commands
+
+ -- Guido Guenther <agx@sigxcpu.org> Thu, 23 Nov 2006 20:43:03 +0100
+
git-buildpackage (0.2.13) experimental; urgency=low
* fix typos in 'git-buildpackage -v'
diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml
index 913b6297..0a151e0f 100644
--- a/docs/manpages/git-buildpackage.sgml
+++ b/docs/manpages/git-buildpackage.sgml
@@ -28,6 +28,7 @@
<arg><option>--git-ignore-new</option></arg>
<arg><option>--git-tag</option></arg>
<arg><option>--git-verbose</option></arg>
+ <arg><option>--upstream-branch=<replaceable>branch_name</replaceable></option></arg>
<arg><option>--git-builder=<replaceable>BUILD_CMD</replaceable></option></arg>
</cmdsynopsis>
</refsynopsisdiv>
@@ -43,6 +44,8 @@
<listitem><para>Verify that it is being executed from the
proper location.</para>
</listitem>
+ <listitem><para>Build an orig.tar.gz if it doesn't exist.</para>
+ </listitem>
<listitem><para>Call <application>debuild</application> (1)
(or the application specified via --git-builder)
with arguments instructing it to ignore Git meta-data in
@@ -86,7 +89,39 @@
<para>Verbose execution</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--git-upstream-branch</option>=<replaceable>branch_name</replaceable>
+ </term>
+ <listitem>
+ <para>Branch to build the orig.tar.gz from. Default is 'upstream'</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+ </refsect1>
+ <refsect1>
+ <title>CONFIGURATION FILES</title>
+ Three configuration files are parsed:
+ <variablelist>
+ <varlistentry>
+ <term>/etc/git-buildpacakge/gbp.conf</term>
+ </varlistentry>
+ <varlistitem>- system wide configuraton</varlistitem>
+ <varlistentry>
+ <term>~/.gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per user configuration
+ </varlistentry>
+ <varlistentry>
+ <term>\.git/gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per repository configuration
+ </varlistentry>
</variablelist>
+ <para>
+ See /etc/git-buildpacakge/gbp.conf for an example.
+ </para>
</refsect1>
<refsect1>
<title>SEE ALSO</title>
diff --git a/docs/manpages/git-import-dsc.sgml b/docs/manpages/git-import-dsc.sgml
index 22a5f6ea..7dec2f61 100644
--- a/docs/manpages/git-import-dsc.sgml
+++ b/docs/manpages/git-import-dsc.sgml
@@ -61,10 +61,34 @@
</variablelist>
</refsect1>
<refsect1>
+ <title>CONFIGURATION FILES</title>
+ Three configuration files are parsed:
+ <variablelist>
+ <varlistentry>
+ <term>/etc/git-buildpacakge/gbp.conf</term>
+ </varlistentry>
+ <varlistitem>- system wide configuraton</varlistitem>
+ <varlistentry>
+ <term>~/.gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per user configuration
+ </varlistentry>
+ <varlistentry>
+ <term>\.git/gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per repository configuration
+ </varlistentry>
+ </variablelist>
+ <para>
+ See /etc/git-buildpacakge/gbp.conf for an example.
+ </para>
+ </refsect1>
+ <refsect1>
<title>SEE ALSO</title>
<para>git-buildpackage (1), git-import-orig (1), git (1), git_load_dirs (1)</para>
-
</refsect1>
<refsect1>
<title>AUTHOR</title>
diff --git a/docs/manpages/git-import-orig.sgml b/docs/manpages/git-import-orig.sgml
index 01068dfe..0e507398 100644
--- a/docs/manpages/git-import-orig.sgml
+++ b/docs/manpages/git-import-orig.sgml
@@ -85,6 +85,31 @@
</variablelist>
</refsect1>
<refsect1>
+ <title>CONFIGURATION FILES</title>
+ Three configuration files are parsed:
+ <variablelist>
+ <varlistentry>
+ <term>/etc/git-buildpacakge/gbp.conf</term>
+ </varlistentry>
+ <varlistitem>- system wide configuraton</varlistitem>
+ <varlistentry>
+ <term>~/.gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per user configuration
+ </varlistentry>
+ <varlistentry>
+ <term>\.git/gbp.conf</term>
+ </varlistentry>
+ <varlistentry>
+ - per repository configuration
+ </varlistentry>
+ </variablelist>
+ <para>
+ See /etc/git-buildpacakge/gbp.conf for an example.
+ </para>
+ </refsect1>
+ <refsect1>
<title>SEE ALSO</title>
<para>git-buildpackage (1), git-import-dsc (1), git (1), git_load_dirs (1)</para>
diff --git a/gbp.conf b/gbp.conf
new file mode 100644
index 00000000..d7ee6210
--- /dev/null
+++ b/gbp.conf
@@ -0,0 +1,23 @@
+# 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=debian
+
+# Special options for git-buildpackage
+[git-buildpackage]
+#upstream-branch=dfsgclean
+
+# Special options for git-import-orig
+[git-import-orig]
+#upstream-branch=newupstream
+#debian-branch=dfsgclean
+
+# Special options for git-import-dsc
+[git-import-dsc]
+#upstream-branch=svn-upstream
+
diff --git a/git-buildpackage b/git-buildpackage
index 9cf16d93..f7a5663c 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -1,8 +1,6 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
-# run debuild in a git repository
-#
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -17,17 +15,18 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# run commands to build a debian package out of a git repository
import sys,os,commands,re,pipes
import optparse
from git_buildpackage import GitTag, Command, CommandExecFailed
from git_buildpackage.git_utils import *
from git_buildpackage.deb_utils import *
+from git_buildpackage.config import GBPOptionParser
-build_cmd='debuild'
output_dir='../'
-
def create_orig(cp, dir, branch):
"create an orig.tar.gz"
output='%s%s' % (dir, orig_file(cp))
@@ -52,17 +51,18 @@ def main(argv):
if "--help" in dpkg_args:
args.append('--help')
- parser=optparse.OptionParser()
+ parser=GBPOptionParser(command=os.path.basename(argv[0]), prefix='git-')
+
parser.add_option("--git-ignore-new", action="store_true", dest="ignore_new", default=False,
help="build with uncommited changes in the source tree")
parser.add_option("--git-tag", action="store_true", dest="tag", default=False,
help="tag after a successful build")
- parser.add_option("--git-builder", dest="build_cmd", default=build_cmd,
- help="command to build the package with, default is 'debuild'")
parser.add_option("--git-verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
- parser.add_option("--git-upstream-branch", dest="upstream_branch", default='upstream',
- help="name of the upstream branch, default is 'upstream'")
+ parser.add_config_file_option(option_name="builder", dest="build_cmd",
+ help="command to build the package e.g. default is '%(builder)s'")
+ parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
+ help="upstream branch, default is '%(upstream-branch)s'")
(options, args) = parser.parse_args(args)
if options.verbose:
diff --git a/git-import-dsc b/git-import-dsc
index add19da3..6c979521 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -27,6 +27,7 @@ from optparse import OptionParser
from git_buildpackage import *
from git_buildpackage.git_utils import *
from git_buildpackage.deb_utils import *
+from git_buildpackage.config import GBPOptionParser
gitAdd=GitAdd()
gitCommitAll=GitCommitAll()
@@ -112,16 +113,17 @@ def move_tree(src, dirs):
RemoveTree(dirs['tmp'])()
-def main():
- dirs={'top': os.path.abspath(os.curdir)}
+def main(argv):
+ dirs = {'top': os.path.abspath(os.curdir)}
- parser = OptionParser('%prog [options] /path/to/package.dsc')
+ parser = GBPOptionParser(command=os.path.basename(argv[0]), prefix='',
+ usage='%prog [options] /path/to/package.dsc')
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
- parser.add_option("--upstream-branch", dest="upstream_branch", default='upstream',
- help="name of the upstream branch, default is 'upstream'")
- (options, args) = parser.parse_args()
+ parser.add_config_file_option(option_name="upstream-branch", dest="upstream_branch",
+ help="upstream branch, default is '%(upstream-branch)s'")
+ (options, args) = parser.parse_args(argv[1:])
if options.verbose:
Command.verbose = True
@@ -147,6 +149,6 @@ def main():
print 'Everything imported under %s' % (src.pkg, )
if __name__ == '__main__':
- sys.exit(main())
+ sys.exit(main(sys.argv))
# vim:et:ts=4:sw=4:
diff --git a/git-import-orig b/git-import-orig
index c7f6a8d2..e28d17d9 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -23,9 +23,9 @@ import os
import tempfile
import re
import glob
-from optparse import OptionParser
from git_buildpackage import *
from git_buildpackage.git_utils import *
+from git_buildpackage.config import GBPOptionParser
def cleanupTmpTree(tree):
@@ -49,20 +49,21 @@ def get_version(tgz):
if m:
return m.group('version')
-def main():
- parser = OptionParser('%prog [-u version] /path/to/upstream-version.tar.gz')
+def main(argv):
+ parser=GBPOptionParser(command=os.path.basename(argv[0]), prefix='',
+ usage='%prog [-u version] /path/to/upstream-version.tar.gz')
parser.add_option("-u", "--upstreamversion", dest="version",
help="Upstream Version")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
help="verbose command execution")
- parser.add_option("--upstream-branch", dest="upstream", default='upstream',
- help="name of the upstream branch, default is 'upstream'")
- parser.add_option("--debian-branch", dest='debian', default='master',
- help="name of the branch the debian package is being developed on, default is 'master'")
parser.add_option("--no-merge", dest='merge', action="store_false", default=True,
help="after import dont do any merging to another branch")
- (options, args) = parser.parse_args()
+ parser.add_config_file_option(option_name="debian-branch", dest='debian',
+ help="branch the debian patch is being developed on, default is '%(debian-branch)s'")
+ parser.add_config_file_option(option_name="upstream-branch", dest="upstream",
+ help="upstream branch, default is '%(upstream-branch)s'")
+ (options, args) = parser.parse_args(argv[1:])
gitCheckoutUpstream=GitCheckoutBranch(options.upstream)
gitCheckoutMaster=GitCheckoutBranch(options.debian)
@@ -129,6 +130,6 @@ def main():
return 0
if __name__ == "__main__":
- sys.exit(main())
+ sys.exit(main(sys.argv))
# vim:et:ts=4:sw=4:
diff --git a/git_buildpackage/__init__.py b/git_buildpackage/__init__.py
index 1f3d66f4..29fe7b27 100644
--- a/git_buildpackage/__init__.py
+++ b/git_buildpackage/__init__.py
@@ -1,14 +1,21 @@
# -*- coding: utf-8 -*-
-# helper classes for git-buildpackge and friends
+#
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
+"""Simple class wrappers for the various commands needed by git-buildpackage"""
import subprocess
import sys
+
class CommandExecFailed(Exception):
+ """Exception raised by the Command class"""
pass
class Command(object):
+ """
+ Wraps a shell command, so we don't have to store any kind of command line options in
+ one of the git-buildpackage commands
+ """
verbose=False
def __init__(self, cmd, args=[]):
@@ -38,6 +45,7 @@ class Command(object):
class UnpackTGZ(Command):
+ """Wrap tar to Unpack a gzipped tar archive"""
def __init__(self, tgz, dir):
self.tgz=tgz
self.dir=dir
@@ -46,7 +54,7 @@ class UnpackTGZ(Command):
class RemoveTree(Command):
- "Remove a whole directory tree"
+ "Wrap rm to remove a whole directory tree"
def __init__(self, tree):
self.tree=tree
Command.__init__(self, 'rm', [ '-rf', tree ])
@@ -54,6 +62,7 @@ class RemoveTree(Command):
class Dch(Command):
+ """Wrap dch and set a specific version"""
def __init__(self, version, msg):
args=['-v', version]
if msg:
@@ -63,6 +72,10 @@ class Dch(Command):
class DpkgSourceExtract(Command):
+ """
+ Wrap dpkg-source to extract a Debian source package into a certain
+ directory, this needs
+ """
def __init__(self):
Command.__init__(self, 'dpkg-source', ['-x'])
@@ -72,6 +85,7 @@ class DpkgSourceExtract(Command):
class GitLoadDirs(Command):
+ """Wrap git_load_dirs"""
def __init__(self):
Command.__init__(self, 'git_load_dirs')
@@ -89,18 +103,21 @@ class GitCommand(Command):
class GitInitDB(GitCommand):
+ """Wrap git-init-db"""
def __init__(self):
GitCommand.__init__(self,'init-db')
self.run_error="Couldn't init git repository"
class GitShowBranch(GitCommand):
+ """Wrap git-show-branch"""
def __init__(self):
GitCommand.__init__(self,'branch')
self.run_error="Couldn't list branches"
class GitBranch(GitCommand):
+ """Wrap git-branch"""
def __init__(self):
GitCommand.__init__(self,'branch')
@@ -110,6 +127,7 @@ class GitBranch(GitCommand):
class GitCheckoutBranch(GitCommand):
+ """Wrap git-checkout in order tos switch to a certain branch"""
def __init__(self, branch):
GitCommand.__init__(self,'checkout', [branch])
self.branch=branch
@@ -117,12 +135,14 @@ class GitCheckoutBranch(GitCommand):
class GitPull(GitCommand):
+ """Wrap git-pull"""
def __init__(self, repo, branch):
GitCommand.__init__(self,'pull', [repo, branch])
self.run_error="Couldn't pull %s to %s" % (branch, repo)
class GitTag(GitCommand):
+ """Wrap git-tag"""
def __init__(self):
GitCommand.__init__(self,'tag')
@@ -132,14 +152,14 @@ class GitTag(GitCommand):
class GitAdd(GitCommand):
- """add a lists of files"""
+ """Wrap git-add to add new files"""
def __init__(self):
GitCommand.__init__(self,'add')
self.run_error="Couldn't add files"
class GitCommitAll(GitCommand):
- """Commit files to the repository"""
+ """Wrap git-commit to commit all changes"""
def __init__(self):
GitCommand.__init__(self,'commit', ['-a'])
diff --git a/git_buildpackage/config.py b/git_buildpackage/config.py
new file mode 100644
index 00000000..3a2c69d3
--- /dev/null
+++ b/git_buildpackage/config.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+#
+# (C) 2006 Guido Guenther <agx@sigxcpu.org>
+"""handles command line and config file option parsing for the git-buildpackage"""
+
+from optparse import OptionParser
+from ConfigParser import SafeConfigParser
+import os.path
+
+class GBPOptionParser(OptionParser):
+ """
+ Handles commandline options and parsing of config files
+ @ivar command: the gbp command we store the options for
+ @type command: string
+ @ivar prefix: prefix to prepend to all commandline options
+ @type prefix: string
+ @ivar config: current configuration parameters
+ @type config: dict
+ @cvar defaults: defaults value of an option if not in the config file or
+ given on the command line
+ @type defaults: dict
+ @cvar config_files: list of config files we parse
+ @type config_files: list
+ """
+ defaults={ 'builder': 'debuild',
+ 'debian-branch' : 'debian',
+ 'upstream-branch' : 'upstream',
+ }
+ config_files=['/etc/git-buildpackage/gbp.conf',
+ os.path.expanduser('~/.gbp.conf'),
+ '.git/gbp.conf' ]
+
+ def __parse_config_files(self):
+ """parse the possible config files and set appropriate values default values"""
+ parser=SafeConfigParser(self.defaults)
+ parser.read(self.config_files)
+ self.config=dict(parser.defaults())
+ if parser.has_section(self.command):
+ self.config=dict(parser.items(self.command))
+
+ def __init__(self, command, prefix='', usage=None):
+ self.command=command
+ self.prefix=prefix
+ self.__parse_config_files()
+ OptionParser.__init__(self, usage=usage)
+
+
+ def add_config_file_option(self, option_name, dest, help):
+ """
+ set a option for the command line parser, the default is read from the config file
+ @var option_name: name of the option
+ @type option_name: string
+ @var dest: where to store this option
+ @type dest: string
+ @var help: help text
+ @type help: string
+ """
+ OptionParser.add_option(self,"--%s%s" % (self.prefix, option_name), dest=dest,
+ default=self.config[option_name], help=help % self.config)
+
+
diff --git a/git_buildpackage/deb_utils.py b/git_buildpackage/deb_utils.py
index f060c9dc..f2ae405f 100644
--- a/git_buildpackage/deb_utils.py
+++ b/git_buildpackage/deb_utils.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# utility functions for git-buildpackge and friends
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
+"""provides some debian source package related helpers"""
import email
import commands
diff --git a/git_buildpackage/git_utils.py b/git_buildpackage/git_utils.py
index d18ead2e..59f80f25 100644
--- a/git_buildpackage/git_utils.py
+++ b/git_buildpackage/git_utils.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# utility functions for git-buildpackge and friends
# (C) 2006 Guido Guenther <agx@sigxcpu.org>
+"""provides some git repository related helpers"""
import subprocess
import os.path
diff --git a/setup.py b/setup.py
index f40115ca..fa60981c 100644
--- a/setup.py
+++ b/setup.py
@@ -22,6 +22,7 @@ setup(name = "git_build_package",
author = 'Guido Guenther',
author_email = 'agx@sigxcpu.org',
scripts = [ 'git-buildpackage', 'git-import-dsc', 'git-import-orig'],
- packages = [ 'git_buildpackage' ]
+ packages = [ 'git_buildpackage' ],
+ data_files = [("/etc/git-buildpackage/", ["gbp.conf" ]),],
)