diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | docs/manpages/git-buildpackage.sgml | 8 | ||||
-rw-r--r-- | gbp.conf | 1 | ||||
-rw-r--r-- | gbp/config.py | 1 | ||||
-rw-r--r-- | gbp/deb_utils.py | 18 | ||||
-rwxr-xr-x | git-buildpackage | 44 |
6 files changed, 57 insertions, 16 deletions
@@ -1,5 +1,6 @@ - git-buildpackage: - allow to fetch and build from a signed tag even when it's in a remote repo + - add --git-overlay as discussed in #448357 - git-import-orig: - show untracked files using 'git-ls-files -o' after import - git-import-dsc: diff --git a/docs/manpages/git-buildpackage.sgml b/docs/manpages/git-buildpackage.sgml index 473ca1e0..2f1d998f 100644 --- a/docs/manpages/git-buildpackage.sgml +++ b/docs/manpages/git-buildpackage.sgml @@ -31,6 +31,7 @@ <arg><option>--git-posttag=</option><replaceable>command</replaceable></arg> <arg><option>--git-debian-tag=</option><replaceable>tag-format</replaceable></arg> <arg><option>--git-no-create-orig</option></arg> + <arg><option>--git-tarball-dir=</option><replaceable>directory</replaceable></arg> <arg><option>--git-export-dir=</option><replaceable>directory</replaceable></arg> <arg><option>--git-export=</option><replaceable>treeish</replaceable></arg> </cmdsynopsis> @@ -177,6 +178,13 @@ </listitem> </varlistentry> <varlistentry> + <term><option>--git-tarball-dir=</option><replaceable>directory</replaceable> + </term> + <listitem> + <para>Search for original tarballs in <replaceable>directory</replaceable> instead of generating them</para> + </listitem> + </varlistentry> + <varlistentry> <term><option>--git-export=</option><replaceable>treeish</replaceable> </term> <listitem> <para>Instead of exporting the current branch head export at @@ -24,6 +24,7 @@ #posttag = git-push git.example.com # use this for more svn-buildpackage like bahaviour: #export-dir = ../build-area/ +#tarball-dir = ../tarballs/ # Options only affecting git-import-orig [git-import-orig] diff --git a/gbp/config.py b/gbp/config.py index 21d5f215..e1e11a2e 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -37,6 +37,7 @@ class GbpOptionParser(OptionParser): 'snapshot-number' : 'snapshot + 1', 'git-log' : '--no-merges', 'export-dir' : '', + 'tarball-dir' : '', } config_files = [ '/etc/git-buildpackage/gbp.conf', os.path.expanduser('~/.gbp.conf'), diff --git a/gbp/deb_utils.py b/gbp/deb_utils.py index 1ae8d105..e62de26b 100644 --- a/gbp/deb_utils.py +++ b/gbp/deb_utils.py @@ -6,6 +6,7 @@ import email import commands import os +import shutil # When trying to parse a version-number from a dsc or changes file, these are # the valid characters. @@ -46,4 +47,19 @@ def has_orig(cp, dir): return False return True -# vim:et:ts=4:sw=4: +def copy_orig(cp, orig_dir, output_dir): + """copy orig.tar.gz from orig_dir to output_dir""" + orig_dir = os.path.abspath(orig_dir) + output_dir = os.path.abspath(output_dir) + + if orig_dir == output_dir: + return True + + try: + shutil.copyfile(os.path.join(orig_dir, orig_file(cp)), + os.path.join(output_dir, orig_file(cp))) + except IOError: + return False + return True + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/git-buildpackage b/git-buildpackage index 10291291..036d9f8d 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -24,7 +24,7 @@ import errno import pipes import time from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag) -from gbp.deb_utils import (parse_changelog, is_native, orig_file, has_orig) +from gbp.deb_utils import (parse_changelog, is_native, orig_file, has_orig, copy_orig) from gbp.command_wrappers import (GitTag, Command, CommandExecFailed, RemoveTree) from gbp.config import GbpOptionParser from gbp.errors import GbpError @@ -133,6 +133,8 @@ def main(argv): help="format string for upstream tags, default is '%(upstream-tag)s'") parser.add_config_file_option(option_name="export-dir", dest="export_dir", help="before building export into EXPORT_DIR") + parser.add_config_file_option(option_name="tarball-dir", dest="tarball_dir", + help="location to look for external tarballs") parser.add_option("--git-export", dest="treeish", default=default_tree, help="export treeish object TREEISH, default is '%s'" % default_tree) (options, args) = parser.parse_args(args) @@ -167,6 +169,11 @@ def main(argv): raise GbpError,"'%s' does not exist, not a debian package" % changelog output_dir = prepare_output_dir(options.export_dir) + if options.tarball_dir: + tarball_dir = options.tarball_dir + else: + tarball_dir = output_dir + if not repo.has_treeish(options.treeish): raise GbpError # git-ls-tree printed an error message already # Export to another build dir if requested: @@ -184,21 +191,28 @@ def main(argv): move_old_export(export_dir) os.rename(tmp_dir, export_dir) - # Build the orig.tar.gz if necessary: - if not is_native(cp) and not has_orig(cp, output_dir) and not options.no_create_orig: - # --upstream-branch was given on the command line, so use this: - if options.upstream_branch != GbpOptionParser.defaults['upstream-branch']: - upstream_tree = options.upstream_branch - else: - upstream_tree = build_tag(options.upstream_tag, cp['Upstream-Version']) - # fall back to the upstream-branch tip if the tag doesn't exist + # Get the orig.tar.gz if necessary: + if not is_native(cp): + if has_orig(cp, output_dir): + pass + elif options.tarball_dir: # separate tarball dir specified + print "Getting orig tarbball from %s" % tarball_dir + if not copy_orig(cp, tarball_dir, output_dir): + raise GbpError, "Cannot copy orig tarball from %s" % tarball_dir + elif not options.no_create_orig: + # --upstream-branch was given on the command line, so use this: + if options.upstream_branch != GbpOptionParser.defaults['upstream-branch']: + upstream_tree = options.upstream_branch + else: + upstream_tree = build_tag(options.upstream_tag, cp['Upstream-Version']) + # 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'" % (orig_file(cp), upstream_tree) if not repo.has_treeish(upstream_tree): - upstream_tree = GbpOptionParser.defaults['upstream-branch'] - print "%s does not exist, creating from '%s'" % (orig_file(cp), upstream_tree) - if not repo.has_treeish(upstream_tree): - raise GbpError # git-ls-tree printed an error message already - if not create_orig(cp, output_dir, upstream_tree): - raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir + raise GbpError # git-ls-tree printed an error message already + if not create_orig(cp, output_dir, upstream_tree): + raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir if options.export_dir: os.chdir(export_dir) |