summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2011-11-22 22:56:26 +0100
committerGuido Günther <agx@sigxcpu.org>2011-11-22 22:57:43 +0100
commite219972a7b0ee1f5a995cb8ed051b7b0452b9f92 (patch)
treeb58d2911d6a0b51fc972d118b134d3f27e992e9d
parenta2a13ed17be28e3654c697acacdde1bc88ed7df8 (diff)
buildpackage: group functions needed for export-dir handling
-rw-r--r--gbp/scripts/buildpackage.py66
1 files changed, 35 insertions, 31 deletions
diff --git a/gbp/scripts/buildpackage.py b/gbp/scripts/buildpackage.py
index 96567f93..79ba029a 100644
--- a/gbp/scripts/buildpackage.py
+++ b/gbp/scripts/buildpackage.py
@@ -150,6 +150,7 @@ def prepare_upstream_tarball(repo, cp, options, tarball_dir, output_dir):
git_archive_build_orig(repo, cp, output_dir, options)
+#{ Functions to handle export-dir
def export_source(repo, cp, options, dest_dir, tarball_dir):
"""
Export a verion of the source tree when building in a separate directory
@@ -234,6 +235,40 @@ def move_old_export(target):
if e == errno.EEXIST:
os.rename(target, "%s.obsolete.%s" % (target, time.time()))
+
+def write_wc(repo):
+ """write out the current working copy as a treeish object"""
+ repo.add_files(repo.path, force=True, index_file=wc_index)
+ tree = repo.write_tree(index_file=wc_index)
+ return tree
+
+
+def drop_index():
+ """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"""
+ gbp.log.info("Extracting %s to '%s'" % (os.path.basename(orig_tarball), dest_dir))
+
+ move_old_export(dest_dir)
+ upstream = gbp.deb.UpstreamSource(orig_tarball)
+ upstream.unpack(dest_dir)
+
+ # Check if tarball extracts into a single folder or not:
+ if upstream.unpacked != dest_dir:
+ # If it extracts a single folder, move all of its contents to dest_dir:
+ r = glob("%s/*" % upstream.unpacked)
+ r.extend(glob("%s/.*" % upstream.unpacked)) # include hidden files and folders
+ for f in r:
+ os.rename(f, os.path.join(dest_dir, os.path.basename(f)))
+
+ # Remove that single folder:
+ os.rmdir(upstream.unpacked)
+#}
+
def prepare_output_dir(dir):
"""Prepare the directory where the build result will be put"""
output_dir = dir
@@ -283,37 +318,6 @@ def git_archive_build_orig(repo, cp, output_dir, options):
raise GbpError, "Cannot create upstream tarball at '%s'" % output_dir
-def write_wc(repo):
- """write out the current working copy as a treeish object"""
- repo.add_files(repo.path, force=True, index_file=wc_index)
- tree = repo.write_tree(index_file=wc_index)
- return tree
-
-def drop_index():
- """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"""
- gbp.log.info("Extracting %s to '%s'" % (os.path.basename(orig_tarball), dest_dir))
-
- move_old_export(dest_dir)
- upstream = gbp.deb.UpstreamSource(orig_tarball)
- upstream.unpack(dest_dir)
-
- # Check if tarball extracts into a single folder or not:
- if upstream.unpacked != dest_dir:
- # If it extracts a single folder, move all of its contents to dest_dir:
- r = glob("%s/*" % upstream.unpacked)
- r.extend(glob("%s/.*" % upstream.unpacked)) # include hidden files and folders
- for f in r:
- os.rename(f, os.path.join(dest_dir, os.path.basename(f)))
-
- # Remove that single folder:
- os.rmdir(upstream.unpacked)
-
-
def guess_comp_type(repo, comp_type, cp, tarball_dir):
"""Guess compression type"""