summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp.conf2
-rw-r--r--gbp/config.py3
-rwxr-xr-xgit-buildpackage40
-rw-r--r--tests/04_test_gbp_submodules.py5
4 files changed, 29 insertions, 21 deletions
diff --git a/gbp.conf b/gbp.conf
index 573df42..22ac648 100644
--- a/gbp.conf
+++ b/gbp.conf
@@ -43,6 +43,8 @@
#compression-level = best
# Don't send notifications, alternatives: on/true, off/false or auto
#notify = off
+# Transparently handle submodules
+# submodules = True
# Options only affecting git-import-orig
[git-import-orig]
diff --git a/gbp/config.py b/gbp/config.py
index 103920e..9f3d169 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -106,6 +106,7 @@ class GbpOptionParser(OptionParser):
'author-is-committer': 'False',
'author-date-is-committer-date': 'False',
'create-missing-branches': 'False',
+ 'submodules' : 'True',
}
help = {
'debian-branch':
@@ -172,6 +173,8 @@ class GbpOptionParser(OptionParser):
"Use the authors's date as the comitter's date, default is '%(author-date-is-committer-date)s'",
'create-missing-branches':
"Create missing branches automatically, default is '%(create-missing-branches)s'",
+ 'submodules':
+ "Transparently handle submodules in the upstream tree"
}
config_files = [ '/etc/git-buildpackage/gbp.conf',
os.path.expanduser('~/.gbp.conf'),
diff --git a/git-buildpackage b/git-buildpackage
index 48e3fc1..6223213 100755
--- a/git-buildpackage
+++ b/git-buildpackage
@@ -94,7 +94,7 @@ def git_archive_single(repo, treeish, output, prefix, comp_type, comp_level, com
raise GbpError("Error creating %s: %d" % (output, ret))
-def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level):
+def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level, with_submodules):
"create a compressed orig tarball in output_dir using git_archive"
try:
comp_opts = du.compressor_opts[comp_type][0]
@@ -105,7 +105,7 @@ def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level):
prefix = "%s-%s" % (cp['Source'], cp['Upstream-Version'])
try:
- if repo.has_submodules():
+ if repo.has_submodules() and with_submodules:
repo.update_submodules()
git_archive_submodules(repo, treeish, output, prefix,
comp_type, comp_level, comp_opts)
@@ -127,7 +127,7 @@ def git_archive(repo, cp, output_dir, treeish, comp_type, comp_level):
return True
-def dump_tree(repo, export_dir, treeish):
+def dump_tree(repo, export_dir, treeish, with_submodules):
"dump a tree to output_dir"
output_dir = os.path.dirname(export_dir)
prefix = os.path.basename(export_dir)
@@ -141,20 +141,21 @@ def dump_tree(repo, export_dir, treeish):
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
+ if with_submodules:
+ 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
@@ -224,7 +225,7 @@ def git_archive_build_orig(repo, cp, output_dir, options):
gbp.log.debug("Building upstream tarball with compression '%s -%s'" % (options.comp_type,
options.comp_level))
if not git_archive(repo, cp, output_dir, upstream_tree,
- options.comp_type, options.comp_level):
+ options.comp_type, options.comp_level, options.with_submodules):
raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
@@ -357,6 +358,7 @@ def parse_args(argv, prefix):
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")
branch_group.add_boolean_config_file_option(option_name = "ignore-branch", dest="ignore_branch")
+ branch_group.add_boolean_config_file_option(option_name = "submodules", dest="with_submodules")
cmd_group.add_config_file_option(option_name="builder", dest="builder",
help="command to build the Debian package, default is '%(builder)s'")
cmd_group.add_config_file_option(option_name="cleaner", dest="cleaner",
@@ -484,7 +486,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))
- if not dump_tree(repo, tmp_dir, tree):
+ if not dump_tree(repo, tmp_dir, tree, options.with_submodules):
raise GbpError
cp = du.parse_changelog(filename=os.path.join(tmp_dir, 'debian', 'changelog'))
export_dir = os.path.join(output_dir, "%s-%s" % (cp['Source'], major))
diff --git a/tests/04_test_gbp_submodules.py b/tests/04_test_gbp_submodules.py
index 5fb5c29..ae9d59a 100644
--- a/tests/04_test_gbp_submodules.py
+++ b/tests/04_test_gbp_submodules.py
@@ -93,7 +93,7 @@ def test_dump_tree():
"""Dump the repository and check if files exist"""
dumpdir = os.path.join(tmpdir, "dump")
os.mkdir(dumpdir)
- assert git_buildpackage.dump_tree(repo, dumpdir, "master")
+ assert git_buildpackage.dump_tree(repo, dumpdir, "master", True)
assert os.path.exists(os.path.join(dumpdir, testfile_name))
assert os.path.exists(os.path.join(dumpdir, submodule_name, testfile_name))
@@ -106,7 +106,8 @@ def test_create_tarball():
tmpdir,
"HEAD",
"bzip2",
- "9")
+ "9",
+ True)
def test_chacke_tarfile():
"""Check the contents of the created tarfile"""