diff options
author | Guido Guenther <agx@sigxcpu.org> | 2008-02-21 16:23:23 +0100 |
---|---|---|
committer | Guido Guenther <agx@sigxcpu.org> | 2008-02-21 16:23:23 +0100 |
commit | 7cc19c1d1816b1831ac0d7a01535abd4dd894066 (patch) | |
tree | de3e719618548a17d326b2a0f87d417de74288cb | |
parent | ec9debd0184b5cc7a22f1e9c01bd6e2faf8fa5b4 (diff) |
add pristine-tar support based on a patch from Julian Andres Klode (Closes: #463580)
-rwxr-xr-x | git-buildpackage | 55 | ||||
-rwxr-xr-x | git-import-dsc | 10 | ||||
-rwxr-xr-x | git-import-orig | 4 |
3 files changed, 51 insertions, 18 deletions
diff --git a/git-buildpackage b/git-buildpackage index 01015506..a5b60251 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -25,7 +25,8 @@ import pipes import time import gbp.deb_utils as du from gbp.git_utils import (GitRepositoryError, GitRepository, build_tag) -from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed, RemoveTree) +from gbp.command_wrappers import (GitTag, Command, RunAtCommand, CommandExecFailed, + PristineTar, RemoveTree) from gbp.config import GbpOptionParser from gbp.errors import GbpError @@ -47,8 +48,8 @@ def git_archive_pipe(prefix, pipe, output, treeish): return True -def create_orig(cp, output_dir, treeish): - "create an orig.tar.gz in output_dir" +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)) prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version']) gzip_opts = "-9 -n" @@ -89,6 +90,35 @@ def prepare_output_dir(dir): raise GbpError, "Cannot create output dir %s" % output_dir return output_dir +def pristine_tar_build_orig(repo, cp, output_dir, options): + """ + build orig using pristine-tar + @return: True: orig.tar.gz build, False: noop + """ + if options.pristine_tar: + pt = PristineTar() + if not repo.has_branch(pt.branch): + raise GbpError, "Pristine-tar branch '%s' not found" % pt.branch + pt.checkout(os.path.join(output_dir, du.orig_file(cp))) + return True + else: + return False + +def git_archive_build_orig(repo, cp, output_dir, options): + """build orig using git-archive""" + # --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'" % (du.orig_file(cp), 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): + raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir def main(argv): changelog = 'debian/changelog' @@ -135,6 +165,8 @@ def main(argv): 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_config_file_option(option_name="pristine-tar", dest="pristine_tar", + help="Use pristine-tar to create .orig.tar.gz", action="store_true") 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) @@ -194,7 +226,7 @@ def main(argv): move_old_export(export_dir) os.rename(tmp_dir, export_dir) - # Get the orig.tar.gz if necessary: + # Get/build the orig.tar.gz if necessary: if not du.is_native(cp): if du.has_orig(cp, output_dir): pass @@ -203,19 +235,8 @@ def main(argv): if not du.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'" % (du.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 + if not pristine_tar_build_orig(repo, cp, output_dir, options): + git_archive_build_orig(repo, cp, output_dir, options) if options.export_dir: build_dir = export_dir diff --git a/git-import-dsc b/git-import-dsc index 37de62d7..cafa792b 100755 --- a/git-import-dsc +++ b/git-import-dsc @@ -106,8 +106,13 @@ def import_initial(src, dirs, options, tagger, filter): format = [options.upstream_tag, options.debian_tag][src.native] tagger(build_tag(format, src.upstream_version), msg="Upstream version %s" % src.upstream_version) + if not src.native: gbpc.GitBranch()(options.upstream_branch) + if options.pristine_tar: + gbpc.PristineTar().commit(os.path.join(dirs['top'], src.tgz), + options.upstream_branch) + except gbpc.CommandExecFailed: print >>sys.stderr, "Creation of git repository failed" gbpc.RemoveTree(unpackTGZ.dir)() @@ -189,6 +194,8 @@ def main(argv): help="Format string for upstream tags, default is '%(upstream-tag)s'") parser.add_config_file_option(option_name="filter", dest="filter", help="files to filter out during import") + parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar", + help="Use pristine-tar to import the tarball", action="store_true") (options, args) = parser.parse_args(argv[1:]) if options.verbose: @@ -200,7 +207,7 @@ def main(argv): if len(args) != 1: parser.print_help() raise GbpError - else: + else: src = parse_dsc(args[0]) if not src: raise GbpError @@ -208,6 +215,7 @@ def main(argv): dirs['tmp'] = os.path.abspath(tempfile.mkdtemp(dir='.')) if not import_initial(src, dirs, options, gitTag, options.filter): raise GbpError + os.chdir(dirs['top']) if not src.native: dirs['unpack'] = os.path.join(dirs['tmp'], 'unpack') diff --git a/git-import-orig b/git-import-orig index b2bb0351..6a1d5b23 100755 --- a/git-import-orig +++ b/git-import-orig @@ -112,6 +112,8 @@ def main(argv): help="format string for upstream tags, default is '%(upstream-tag)s'") parser.add_config_file_option(option_name="filter", dest="filter", help="files to filter out during import") + parser.add_config_file_option(option_name="pristine-tar", dest="pristine_tar", + help="run pristine-tar to import the tarball", action="store_true") (options, args) = parser.parse_args(argv[1:]) gitCheckoutMaster = gbpc.GitCheckoutBranch(options.debian_branch) @@ -187,6 +189,8 @@ on howto create it otherwise use --upstream-branch to specify it. print "Initial import of '%s'..." % archive import_source_tree(repo, orig_dir, version, options.filter, verbose=not is_empty) + if options.pristine_tar: + gbpc.PristineTar().commit(archive, options.upstream_branch) gbpc.GitTag(options.sign_tags, options.keyid)(build_tag(options.upstream_tag, version), msg="Upstream version %s" % version) |