diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-03-18 12:14:40 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-03-18 20:44:02 +0100 |
commit | 2353ab77c134743873a34455e29c610295af2dd7 (patch) | |
tree | 5e019d9e9c9b23d6db09b364c670dca20cdd9c3a /git-buildpackage | |
parent | fadcfcb35b264f9e9d8762b590512f9049ecff5e (diff) |
git-buildpackage: submodule support for dump_tree
Heavily based on work by Sean Finney and Chow Loong Jin
Diffstat (limited to 'git-buildpackage')
-rwxr-xr-x | git-buildpackage | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/git-buildpackage b/git-buildpackage index d9bdfdf..1a8c222 100755 --- a/git-buildpackage +++ b/git-buildpackage @@ -74,13 +74,46 @@ def git_archive(cp, output_dir, treeish, comp_type, comp_level): return git_archive_pipe(prefix, pipe, output, treeish) -def dump_tree(export_dir, treeish): +def dump_tree(repo, export_dir, treeish): "dump a tree to output_dir" output_dir = os.path.dirname(export_dir) prefix = os.path.basename(export_dir) + pipe = pipes.Template() + pipe.prepend('git archive --format=tar --prefix=%s/ %s' % (prefix, treeish), '.-') pipe.append('tar -C %s -xf -' % output_dir, '-.') - return git_archive_pipe(prefix, pipe, '', treeish) + top = os.path.abspath(os.path.curdir) + try: + ret = pipe.copy('', '') + if ret: + raise GbpError, "Error in dump_tree archive pipe" + + if repo.has_submodules(): + repo.update_submodules() + for (subdir, commit) in repo.get_submodules(treeish): + gbp.log.info("Processing submodule %s (%s)" % (subdir, commit[0:8])) + tarpath = [subdir, subdir[2:]][subdir.startswith("./")] + os.chdir(subdir) + pipe = pipes.Template() + pipe.prepend('git archive --format=tar --prefix=%s/%s/ %s' % + (prefix, tarpath, commit), '.-') + pipe.append('tar -C %s -xf -' % output_dir, '-.') + ret = pipe.copy('', '') + os.chdir(top) + if ret: + raise GbpError, "Error in dump_tree archive pipe in submodule %s" % subdir + except OSError, err: + gbp.log.err("Error dumping tree to %s: %s" % (output_dir, err[0])) + return False + except GbpError, err: + gbp.log.err(err) + return False + except Exception as e: + gbp.log.err("Error dumping tree to %s: %s" % (output_dir, e)) + return False + finally: + os.chdir(top) + return True def move_old_export(target): @@ -398,7 +431,7 @@ def main(argv): extract_orig(os.path.join(output_dir, du.orig_file(cp, options.comp_type)), tmp_dir) gbp.log.info("Exporting '%s' to '%s'" % (options.export, tmp_dir)) - dump_tree(tmp_dir, tree) + dump_tree(repo, tmp_dir, tree) cp = du.parse_changelog(filename=os.path.join(tmp_dir, 'debian', 'changelog')) export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major)) gbp.log.info("Moving '%s' to '%s'" % (tmp_dir, export_dir)) |