aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog30
-rw-r--r--docs/chapters/import.sgml3
-rw-r--r--docs/chapters/releases.sgml18
-rw-r--r--docs/manpages/git-dch.sgml13
-rwxr-xr-xgbp-clone6
-rwxr-xr-xgbp-pull8
-rw-r--r--gbp.conf6
-rw-r--r--gbp/command_wrappers.py4
-rw-r--r--gbp/config.py3
-rw-r--r--gbp/deb.py29
-rwxr-xr-xgit-buildpackage57
-rwxr-xr-xgit-dch71
-rwxr-xr-xgit-import-dsc14
-rwxr-xr-xgit-import-orig5
-rw-r--r--tests/01_test_help.py9
-rw-r--r--tests/02_import.py41
16 files changed, 247 insertions, 70 deletions
diff --git a/debian/changelog b/debian/changelog
index 26f3272..fa99a1e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,33 @@
+git-buildpackage (0.4.63) unstable; urgency=low
+
+ [ Guido Günther ]
+ * [a0c7a91] docs: fix git-init call - thanks to Pietro Battiston
+ * [02ab603] docs: Drop superfluous upstream branch creation
+ * [e339c70] gbp: Make sure we drop the generated custom index file
+ (Closes: #561454)
+ * [d436612] git-dch: Add body regex filter (Closes: #544238)
+ * [cf45595] gbp-{pull,clone}: Don't hardcode pristine-tar branch
+ * [0eb4580] gbp: Allow to set compression type (Closes: #554520)
+ * [7ad35fb] tests: Add other gbp-* commands
+ * [f1f3d8e] tests: Add unpack test
+
+ [ Matthijs Kooijman ]
+ * [725b9d3] git-dch: Add support for a Git-Dch: Ignore metaheader.
+ (Closes: #561346)
+ * [e54b7bf] git-dch: There was a second use of parse_commit. Both uses of
+ parse_commit now support the None return value. The shortlog_to_dch
+ function is now superfluous and was removed.
+
+ -- Guido Günther <agx@sigxcpu.org> Sat, 26 Dec 2009 18:17:39 +0100
+
+git-buildpackage (0.4.62) unstable; urgency=low
+
+ * [dce995d] Improve error handling on broken dsc files. (Closes: #560689)
+ * [bcdd6b5] Improve error message when trying to import 3.0 source format
+ packages until we properly support them.
+
+ -- Guido Günther <agx@sigxcpu.org> Mon, 14 Dec 2009 09:15:49 +0100
+
git-buildpackage (0.4.61~bpo50+1) lenny-backports; urgency=low
* Rebuild for lenny-backports.
diff --git a/docs/chapters/import.sgml b/docs/chapters/import.sgml
index 429f9f1..3da7bd3 100644
--- a/docs/chapters/import.sgml
+++ b/docs/chapters/import.sgml
@@ -153,13 +153,12 @@ EOF
<screen>
<command>mkdir</command> package-0.1
<command>cd</command> package-0.1
-<command>git-init</command>
+<command>git init</command>
</screen>
<para>Then you import the upstream sources, branch off the
<option>upstream-branch</option> branch and add the debian files (e.g. via dh_make):
<screen>
&git-import-orig; <option>-u</option> <replaceable>0.1</replaceable> <filename>../package-0.1.tar.gz</filename>
-&gitcmd; branch upstream
<command>dh_make</command>
</screen>
That's it, you're done.
diff --git a/docs/chapters/releases.sgml b/docs/chapters/releases.sgml
index 95c2335..00fb76f 100644
--- a/docs/chapters/releases.sgml
+++ b/docs/chapters/releases.sgml
@@ -115,5 +115,23 @@ via &git-dch;'s <option>--id-length</option> option. Using
</screen>
This makes it much easier to see which commit actually fixed bug #1000.
</para>
+<para>
+Finally, there is the <option>Git-Dch:</option> header that can
+currently only be set to <option>Ignore</option> (or omitted). When this
+header is set to <option>Ignore</option>, the commit message is
+completely ignored and will not be included in the changelog at all.
+This is useful for janitorial commits or other commits that really don't
+need to end up in the changelog.
+
+</para><para>
+For example, the following git commit message
+<screen>
+Set correct branchnames in debian/gbp.conf
+
+Git-Dch: Ignore
+</screen>
+will not show up in the generated changelog in any way.
+</para>
+
</sect1>
</chapter>
diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml
index 890df67..c45b5ac 100644
--- a/docs/manpages/git-dch.sgml
+++ b/docs/manpages/git-dch.sgml
@@ -107,8 +107,8 @@
<varlistentry>
<term><option>--[no-]meta</option></term>
<listitem>
- <para>Parse meta tags like <option>Closes:</option> and
- <option>Thanks:</option>. </para>
+ <para>Parse meta tags like <option>Closes:</option>,
+ <option>Thanks:</option> and <option>Git-Dch:</option>. </para>
</listitem>
</varlistentry>
<varlistentry>
@@ -180,6 +180,15 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--ignore-regex=</option><replaceable>regex</replaceable>
+ </term>
+ <listitem>
+ <para>Ignore commit lines matching <replaceable>regex</replaceable>
+ when generating the changelog.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--git-author</option>
</term>
<listitem>
diff --git a/gbp-clone b/gbp-clone
index 552108c..73cfabf 100755
--- a/gbp-clone
+++ b/gbp-clone
@@ -24,13 +24,13 @@ import sys
import os, os.path
from gbp.config import (GbpOptionParser, GbpOptionGroup)
from gbp.git import (GitRepositoryError, GitRepository)
-from gbp.command_wrappers import (GitClone, Command, CommandExecFailed, GitBranch)
+from gbp.command_wrappers import (GitClone, Command, CommandExecFailed,
+ GitBranch, PristineTar)
from gbp.errors import GbpError
def main(argv):
retval = 0
- pristine_tar_branch = 'pristine-tar'
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] repository - clone a remote repository')
@@ -73,7 +73,7 @@ def main(argv):
repo = GitRepository(os.path.curdir)
if options.pristine_tar:
- branches += [ pristine_tar_branch ]
+ branches += [ PristineTar.branch ]
for branch in branches:
remote = 'origin/%s' % branch
diff --git a/gbp-pull b/gbp-pull
index a12de88..0352d7c 100755
--- a/gbp-pull
+++ b/gbp-pull
@@ -22,7 +22,8 @@
import sys
import os, os.path
-from gbp.command_wrappers import (GitFetch, GitMerge, Command, CommandExecFailed)
+from gbp.command_wrappers import (GitFetch, GitMerge, Command,
+ CommandExecFailed, PristineTar)
from gbp.config import (GbpOptionParser, GbpOptionGroup)
from gbp.errors import GbpError
from gbp.git import (GitRepositoryError, GitRepository)
@@ -46,7 +47,6 @@ def fast_forward_branch(branch, repo, options):
def main(argv):
changelog = 'debian/changelog'
retval = 0
- pristine_tar = 'pristine-tar'
parser = GbpOptionParser(command=os.path.basename(argv[0]), prefix='',
usage='%prog [options] - safely update a repository from remote')
@@ -81,8 +81,8 @@ def main(argv):
if repo.has_branch(branch):
branches += [ branch ]
- if repo.has_branch(pristine_tar) and options.pristine_tar:
- branches += [ pristine_tar ]
+ if repo.has_branch(PristineTar.branch) and options.pristine_tar:
+ branches += [ PristineTar.branch ]
(ret, out) = repo.is_clean()
if not ret:
diff --git a/gbp.conf b/gbp.conf
index f68b043..765f6ca 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -31,6 +31,10 @@
#tarball-dir = ../tarballs/
#ignore-new = True
#export = HEAD
+# Compress with bzip2
+#compression = bzip2
+# Use best compression
+#compression-level = best
# Options only affecting git-import-orig
[git-import-orig]
@@ -60,4 +64,6 @@
# what tags to look for to generate bug-closing changelog entries
#meta-closes = Closes|LP
#full = False
+#Ignore Signed-off-by: lines:
+#ignore-regex=(Signed-off|Acked)-by:
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index cd36bf5..6a0edc8 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -37,7 +37,7 @@ class Command(object):
self.env = None
def __call(self, args):
- """simply wraps subprocess.call so we can be verbose"""
+ """wraps subprocess.call so we can be verbose and fix python's SIGPIPE handling"""
def default_sigpipe():
"restore default signal handler (http://bugs.python.org/issue1652)"
signal.signal(signal.SIGPIPE, signal.SIG_DFL)
@@ -54,7 +54,7 @@ class Command(object):
run self.cmd adding args as additional arguments
be verbose about errors and encode them in the return value, don't pass
- on exceptons
+ on exceptions
"""
try:
retcode = self.__call(args)
diff --git a/gbp/config.py b/gbp/config.py
index 8df9d35..b72b129 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -52,6 +52,9 @@ class GbpOptionParser(OptionParser):
'full' : 'False',
'id-length' : '0',
'git-author' : 'False',
+ 'ignore-regex' : '',
+ 'compression' : 'gzip',
+ 'compression-level': '9',
}
help = {
'debian-branch':
diff --git a/gbp/deb.py b/gbp/deb.py
index 6a60f9b..ac33119 100644
--- a/gbp/deb.py
+++ b/gbp/deb.py
@@ -18,6 +18,12 @@ from errors import GbpError
# the valid characters.
debian_version_chars = 'a-zA-Z\d.~+-'
+# compression types, extra options and extensions
+compressor_opts = { 'gzip' : [ '-n', 'gz' ],
+ 'bzip2' : [ '', 'bz2' ],
+ 'lzma' : [ '', 'lzma' ],
+ 'xz' : [ '', 'xz' ] }
+
class NoChangelogError(Exception):
"""no changelog found"""
pass
@@ -32,11 +38,13 @@ class DscFile(object):
version_re = re.compile("Version:\s((?P<epoch>\d+)\:)?(?P<version>[%s]+)\s*$" % debian_version_chars)
tar_re = re.compile('^\s\w+\s\d+\s+(?P<tar>[^_]+_[^_]+(\.orig)?\.tar\.(gz|bz2))')
diff_re = re.compile('^\s\w+\s\d+\s+(?P<diff>[^_]+_[^_]+\.diff.(gz|bz2))')
+ format_re = re.compile('Format:\s+(?P<format>[0-9.]+)\s*')
def __init__(self, dscfile):
self.pkg = ""
self.tgz = ""
self.diff = ""
+ self.pkgformat = "1.0"
self.debian_version = ""
self.upstream_version = ""
self.native = False
@@ -71,6 +79,10 @@ class DscFile(object):
if m:
self.diff = os.path.join(fromdir, m.group('diff'))
continue
+ m = self.format_re.match(line)
+ if m:
+ self.pkgformat = m.group('format')
+ continue
f.close()
if not self.pkg:
@@ -134,11 +146,12 @@ def parse_changelog(changelog):
except TypeError:
raise ParseChangeLogError, output.split('\n')[0]
return cp
-
-def orig_file(cp):
+
+def orig_file(cp, compression):
"The name of the orig.tar.gz belonging to changelog cp"
- return "%s_%s.orig.tar.gz" % (cp['Source'], cp['Upstream-Version'])
+ ext = compressor_opts[compression][1]
+ return "%s_%s.orig.tar.%s" % (cp['Source'], cp['Upstream-Version'], ext)
def is_native(cp):
@@ -154,15 +167,15 @@ def has_epoch(cp):
except KeyError:
return False
-def has_orig(cp, dir):
+def has_orig(cp, compression, dir):
"Check if orig.tar.gz exists in dir"
try:
- os.stat( os.path.join(dir, orig_file(cp)) )
+ os.stat( os.path.join(dir, orig_file(cp, compression)) )
except OSError:
return False
return True
-def symlink_orig(cp, orig_dir, output_dir, force=False):
+def symlink_orig(cp, compression, orig_dir, output_dir, force=False):
"""
symlink orig.tar.gz from orig_dir to output_dir
@return: True if link was created or src == dst
@@ -174,8 +187,8 @@ def symlink_orig(cp, orig_dir, output_dir, force=False):
if orig_dir == output_dir:
return True
- src = os.path.join(orig_dir, orig_file(cp))
- dst = os.path.join(output_dir, orig_file(cp))
+ src = os.path.join(orig_dir, orig_file(cp, compression))
+ dst = os.path.join(output_dir, orig_file(cp, compression))
if not os.access(src, os.F_OK):
return False
try:
diff --git a/git-buildpackage b/git-buildpackage
index 7ca276c..7f2b2d4 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -36,6 +36,8 @@ from glob import glob
index_name = "INDEX"
# when we want to reference the working copy in treeish context we call it:
wc_name = "WC"
+# index file name used to export working copy
+wc_index = ".git/gbp_index"
def git_archive_pipe(prefix, pipe, output, treeish):
"""run the git_archive pipe"""
@@ -54,14 +56,19 @@ def git_archive_pipe(prefix, pipe, output, treeish):
return True
-def git_archive(cp, output_dir, treeish):
- "create an orig.tar.gz in output_dir using git_archive"
- output = os.path.join(output_dir, du.orig_file(cp))
+def git_archive(cp, output_dir, treeish, comp_type, comp_level):
+ "create a compressed orig tarball in output_dir using git_archive"
+
+ try:
+ comp_opts = du.compressor_opts[comp_type][0]
+ except KeyError:
+ raise GbpError, "Unsupported compression type '%s'" % comp_type
+
+ output = os.path.join(output_dir, du.orig_file(cp, comp_type))
prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])
- gzip_opts = "-9 -n"
pipe = pipes.Template()
- pipe.append('gzip -c %s' % gzip_opts, '--')
+ pipe.append('%s -c -%s %s' % (comp_type, comp_level, comp_opts), '--')
return git_archive_pipe(prefix, pipe, output, treeish)
@@ -105,7 +112,7 @@ def pristine_tar_build_orig(repo, cp, output_dir, options):
pt = PristineTar()
if not repo.has_branch(pt.branch):
print >>sys.stderr, 'Pristine-tar branch "%s" not found' % pt.branch
- pt.checkout(os.path.join(output_dir, du.orig_file(cp)))
+ pt.checkout(os.path.join(output_dir, du.orig_file(cp, options.comp_type)))
return True
else:
return False
@@ -121,22 +128,32 @@ def git_archive_build_orig(repo, cp, output_dir, options):
# fall back to the upstream-branch tip if the tag doesn't exist
if not repo.has_treeish(upstream_tree):
upstream_tree = GbpOptionParser.defaults['upstream-branch']
- print "%s does not exist, creating from '%s'" % (du.orig_file(cp), upstream_tree)
+ print "%s does not exist, creating from '%s'" % (du.orig_file(cp,
+ options.comp_type),
+ upstream_tree)
if not repo.has_treeish(upstream_tree):
raise GbpError # git-ls-tree printed an error message already
- if not git_archive(cp, output_dir, upstream_tree):
+ if options.verbose:
+ print "Building upstream tarball with compression '%s -%s'" % (options.comp_type,
+ options.comp_level)
+ if not git_archive(cp, output_dir, upstream_tree,
+ options.comp_type, options.comp_level):
raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
def write_wc(repo):
"""write out the current working copy as a treeish object"""
tree = None
- os.putenv("GIT_INDEX_FILE", ".git/gbp_index")
+ os.putenv("GIT_INDEX_FILE", wc_index)
GitAdd()(['-f', '.'])
tree = repo.write_tree()
os.unsetenv("GIT_INDEX_FILE")
return tree
+def drop_index(repo):
+ """drop our custom index"""
+ if os.path.exists(wc_index):
+ os.unlink(wc_index)
def extract_orig(orig_tarball, dest_dir):
"""extract orig tarball to export dir before exporting from git"""
@@ -165,6 +182,7 @@ def main(argv):
args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == 0 ]
dpkg_args = [ arg for arg in argv[1:] if arg.find('--%s' % prefix) == -1 ]
+ # We handle these although they don't have a --git- prefix
for arg in [ "--help", "-h", "--version" ]:
if arg in dpkg_args:
args.append(arg)
@@ -204,6 +222,10 @@ def main(argv):
help="don't create orig.tar.gz", action="store_true")
orig_group.add_config_file_option(option_name="tarball-dir", dest="tarball_dir",
help="location to look for external tarballs")
+ orig_group.add_config_file_option(option_name="compression", dest="comp_type",
+ help="Compression type, default is '%(compression)s'")
+ orig_group.add_config_file_option(option_name="compression-level", dest="comp_level",
+ help="Compression level, default is '%(compression-level)s'")
branch_group.add_config_file_option(option_name="upstream-branch", dest="upstream_branch")
branch_group.add_config_file_option(option_name="debian-branch", dest="debian_branch")
cmd_group.add_config_file_option(option_name="builder", dest="builder",
@@ -272,7 +294,6 @@ def main(argv):
raise GbpError, "Can't parse version from changelog"
if not options.tag_only:
-
output_dir = prepare_output_dir(options.export_dir)
if options.tarball_dir:
tarball_dir = options.tarball_dir
@@ -281,15 +302,17 @@ def main(argv):
# Get/build the orig.tar.gz if necessary:
if not du.is_native(cp):
+ orig_file = du.orig_file(cp, options.comp_type)
+
# look in tarball_dir first, if found force a symlink to it
if options.tarball_dir:
- print "Looking for orig tarball '%s' at '%s'" % (du.orig_file(cp), tarball_dir)
- if not du.symlink_orig(cp, tarball_dir, output_dir, force=True):
- print "Orig tarball '%s' not found at '%s'" % (du.orig_file(cp), tarball_dir)
+ print "Looking for orig tarball '%s' at '%s'" % (orig_file, tarball_dir)
+ if not du.symlink_orig(cp, options.comp_type, tarball_dir, output_dir, force=True):
+ print "Orig tarball '%s' not found at '%s'" % (orig_file, tarball_dir)
else:
- print "Orig tarball '%s' found at '%s'" % (du.orig_file(cp), tarball_dir)
+ print "Orig tarball '%s' found at '%s'" % (orig_file, tarball_dir)
# build an orig unless the user forbidds it
- if not options.no_create_orig and not du.has_orig(cp, output_dir):
+ if not options.no_create_orig and not du.has_orig(cp, options.comp_type, output_dir):
if not pristine_tar_build_orig(repo, cp, output_dir, options):
git_archive_build_orig(repo, cp, output_dir, options)
@@ -310,7 +333,7 @@ def main(argv):
if options.overlay:
if du.is_native(cp):
raise GbpError, "Cannot overlay Debian native package"
- extract_orig(os.path.join(output_dir, du.orig_file(cp)) , tmp_dir)
+ extract_orig(os.path.join(output_dir, du.orig_file(cp, options.comp_type)), tmp_dir)
print "Exporting '%s' to '%s'" % (options.export, tmp_dir)
dump_tree(tmp_dir, tree)
@@ -354,6 +377,8 @@ def main(argv):
if len(err.__str__()):
print >>sys.stderr, err
retval = 1
+ finally:
+ drop_index(repo)
if not options.tag_only:
if options.export_dir and options.purge and not retval:
diff --git a/git-dch b/git-dch
index 9f0f0d4..637e1dd 100755
--- a/git-dch
+++ b/git-dch
@@ -198,9 +198,15 @@ def parse_commit(repo, commitid, options):
msg = ''
thanks = ''
closes = ''
+ git_dch = ''
bugs = {}
bts_closes = re.compile(r'(?P<bts>%s):\s+%s' % (options.meta_closes, bug_r), re.I)
+ if options.ignore_regex: # Ignore r'' since it matches everything
+ ignore_re = re.compile(options.ignore_regex)
+ else:
+ ignore_re = None
+
commit = repo.show(commitid)
author, email = get_author(commit)
if not author:
@@ -217,15 +223,21 @@ def parse_commit(repo, commitid, options):
bugs[m.group('bts')] = bug_nums
elif line.startswith('Thanks: '):
thanks = line.split(' ', 1)[1].strip()
+ elif line.startswith('Git-Dch: '):
+ git_dch = line.split(' ', 1)[1].strip()
else: # normal commit message
if msg and not options.full:
continue
- elif line.strip(): # don't add all whitespace lines
+ if ignore_re and ignore_re.match(line):
+ continue
+ if line.strip(): # don't add all whitespace lines
msg += line
# start of diff output:
elif line.startswith('diff '):
break
if options.meta:
+ if git_dch == 'Ignore':
+ return None
for bts in bugs:
closes += '(%s: %s) ' % (bts, ', '.join(bugs[bts]))
if thanks:
@@ -236,15 +248,6 @@ def parse_commit(repo, commitid, options):
return msg, (author, email)
-def shortlog_to_dch(repo, commits, options):
- """convert the changes in git shortlog format to debian changelog format"""
- author = 'Unknown'
-
- for commit in commits:
- msg, (author, email) = parse_commit(repo, commit, options)
- add_changelog_entry(msg, author, email)
-
-
def guess_snapshot_commit(cp, repo, options):
"""
guess the last commit documented in the changelog from the snapshot banner
@@ -316,6 +319,8 @@ def main(argv):
commit_group.add_config_file_option(option_name="id-length", dest="idlen",
help="include N digits of the commit id in the changelog entry, default is '%(id-length)s'",
type="int", metavar="N")
+ commit_group.add_config_file_option(option_name="ignore-regex", dest="ignore_regex",
+ help="Ignore commit lines matching regex, default is '%(ignore-regex)s'")
(options, args) = parser.parse_args(argv[1:])
if options.snapshot and options.release:
@@ -371,25 +376,39 @@ def main(argv):
else:
add_section = False
- if add_section:
- if commits:
- first_commit = commits[0]
- commits = commits[1:]
- commit_msg, (commit_author, commit_email) = parse_commit(repo, first_commit, options)
+ for c in commits:
+ parsed = parse_commit(repo, c, options)
+ if not parsed:
+ # Some commits can be ignored
+ continue
+
+ commit_msg, (commit_author, commit_email) = parsed
+ if add_section:
+ # Add a section containing just this message (we can't
+ # add an empty section with dch).
+ add_changelog_section(distribution="UNRELEASED", msg=commit_msg,
+ version=options.new_version, author=commit_author,
+ email=commit_email)
+ # Adding a section only needs to happen once.
+ add_section = False
else:
- commit_msg = "UNRELEASED"
- commit_author = None
- commit_email = None
- add_changelog_section(distribution="UNRELEASED", msg=commit_msg,
- version=options.new_version, author=commit_author,
- email=commit_email)
-
- if commits:
- shortlog_to_dch(repo, commits, options)
- fixup_trailer(repo, git_author=options.git_author)
- elif not first_commit:
+ add_changelog_entry(commit_msg, commit_author, commit_email)
+
+
+ # Show a message if there were no commits (not even ignored
+ # commits).
+ if not commits:
print "No changes detected from %s to %s." % (since, until)
+ if add_section:
+ # If we end up here, then there were no commits to include,
+ # so we put a dummy message in the new section.
+ commit_msg = "UNRELEASED"
+ add_changelog_section(distribution="UNRELEASED", msg="UNRELEASED",
+ version=options.new_version)
+
+ fixup_trailer(repo, git_author=options.git_author)
+
if options.release:
do_release(changelog, cp)
elif options.snapshot:
diff --git a/git-import-dsc b/git-import-dsc
index a5a12a6..37e6d51 100755
--- a/git-import-dsc
+++ b/git-import-dsc
@@ -55,7 +55,9 @@ def apply_debian_patch(repo, src, options):
version = "%s-%s" % (src.upstream_version, src.debian_version)
gitTag = gbpc.GitTag(options.sign_tags, options.keyid)
try:
- if src.diff and not git_apply_patch(src.diff):
+ if not src.diff:
+ raise GbpError, "No diff to apply."
+ if not git_apply_patch(src.diff):
raise GbpError
os.chmod('debian/rules', 0755)
if not repo.is_clean()[0]:
@@ -82,9 +84,12 @@ def print_dsc(dsc):
if dsc.native:
print "Debian Native Package"
print "Version:", dsc.upstream_version
+ print "Debian tarball:", dsc.tgz
else:
print "Upstream version:", dsc.upstream_version
print "Debian version:", dsc.debian_version
+ print "Upstream tarball:", dsc.tgz
+ print "Debian diff:", dsc.diff
if dsc.epoch:
print "Epoch: %s" % dsc.epoch
@@ -147,6 +152,8 @@ def main(argv):
raise GbpError
else:
src = parse_dsc(args[0])
+ if src.pkgformat != '1.0':
+ raise GbpError, "Importing %s source format not yet supported." % src.pkgformat
if options.verbose:
print_dsc(src)
@@ -203,7 +210,10 @@ def main(argv):
except gbpc.CommandExecFailed:
raise GbpError, """Merge of %s failed, please resolve manually""" % options.upstream_branch
repo.replace_tree(unpack_dir, options.filters)
- apply_debian_patch(repo, src, options)
+ if src.diff:
+ apply_debian_patch(repo, src, options)
+ else:
+ print >>sys.stderr, "Warning: Didn't find a diff to apply."
except gbpc.CommandExecFailed:
os.chdir(dirs['top'])
ret = 1
diff --git a/git-import-orig b/git-import-orig
index 6f7f896..8cc7865 100755
--- a/git-import-orig
+++ b/git-import-orig
@@ -53,7 +53,7 @@ def is_link_target(target, link):
def symlink_orig(archive, pkg, version):
"""
- create a symlink <pkg>_<version>.orig.tar.gz so pristine-tar will see the
+ create a symlink <pkg>_<version>.orig.tar.<ext> so pristine-tar will see the
correct basename
@return: archive path to be used by pristine tar
"""
@@ -261,7 +261,6 @@ on howto create it otherwise use --upstream-branch to specify it.
if os.path.isdir(archive):
orig_dir = archive
turn_off_fastimport(options, "Fastimport only supported for tar achives.")
-
else:
if not options.fast_import:
tmpdir = tempfile.mkdtemp(dir='../')
@@ -281,7 +280,7 @@ on howto create it otherwise use --upstream-branch to specify it.
cp = parse_changelog('debian/changelog')
pristine_orig = symlink_orig(archive, cp['Source'], version)
except NoChangelogError:
- print "Warning: Can't symlink orig.tar.gz due to missing debian/changelog"
+ print "Warning: Can't symlink orig tarball due to missing debian/changelog"
pristine_orig = archive
try:
diff --git a/tests/01_test_help.py b/tests/01_test_help.py
index 413b237..eba64c1 100644
--- a/tests/01_test_help.py
+++ b/tests/01_test_help.py
@@ -6,10 +6,15 @@ import os
import unittest
class TestHelp(unittest.TestCase):
-
- def testhelp(self):
+ """Test help output of gbp commands"""
+ def testHelp(self):
for prog in [ "buildpackage", "import-orig", "import-dsc", "dch" ]:
ret = os.system("./git-%s --help >/dev/null" % prog)
self.assertEqual(ret, 0)
+ def testHelpGbp(self):
+ for prog in [ "pull", "clone" ]:
+ ret = os.system("./gbp-%s --help >/dev/null" % prog)
+ self.assertEqual(ret, 0)
+
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
diff --git a/tests/02_import.py b/tests/02_import.py
new file mode 100644
index 0000000..d31533f
--- /dev/null
+++ b/tests/02_import.py
@@ -0,0 +1,41 @@
+# vim: set fileencoding=utf-8 :
+
+import glob
+import os
+import shutil
+import tarfile
+import tempfile
+
+import gbp.deb
+
+class TestUnpack:
+ """Make sure we unpack gzip and bzip2 archives correctly"""
+ def _createArchive(self, comp):
+ archive = "archive"
+ name = "%s_0.1.tar.%s" % (archive, comp)
+ t = tarfile.open(name= name, mode='w:%s' % comp)
+ for f in glob.glob(os.path.join(self.top, "*.py")):
+ t.add(os.path.join(self.top,f),
+ os.path.join("%s-%s" % (archive, comp),
+ os.path.basename(f)))
+ t.close()
+ return name
+
+ def setUp(self):
+ self.dir = tempfile.mkdtemp(prefix='gbp_%s_' % __name__, dir='.')
+ self.top = os.path.abspath(os.curdir)
+ os.chdir(self.dir)
+ self.archives = {}
+ for ext in [ "gz", "bz2" ]:
+ self.archives[ext] = self._createArchive(ext)
+
+ def tearDown(self):
+ os.chdir(self.top)
+ if not os.getenv("GBP_TESTS_NOCLEAN"):
+ shutil.rmtree(self.dir)
+
+ def testUnpack(self):
+ for (comp, archive) in self.archives.iteritems():
+ gbp.deb.unpack_orig(archive, ".", [])
+
+# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: