aboutsummaryrefslogtreecommitdiffhomepage
path: root/gbp/command_wrappers.py
diff options
context:
space:
mode:
authorGuido Guenther <agx@sigxcpu.org>2007-05-28 03:17:37 +0200
committerGuido Guenther <agx@bogon.sigxcpu.org>2007-05-28 03:17:37 +0200
commit44330a25a71415334516e3e00443dcb0434189b9 (patch)
tree85d13b3083d89d2231a186bc1005be83ef4cdf80 /gbp/command_wrappers.py
parentf63599a3fe0924c6545587c0a2450fbd9ee4113b (diff)
don't use git_load_dirs for imports
Diffstat (limited to 'gbp/command_wrappers.py')
-rw-r--r--gbp/command_wrappers.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/gbp/command_wrappers.py b/gbp/command_wrappers.py
index a08470a8..8853f18d 100644
--- a/gbp/command_wrappers.py
+++ b/gbp/command_wrappers.py
@@ -8,6 +8,7 @@ git-buildpackage and friends
import subprocess
import sys
+import os.path
class CommandExecFailed(Exception):
"""Exception raised by the Command class"""
@@ -54,14 +55,17 @@ class Command(object):
class UnpackTarArchive(Command):
"""Wrap tar to Unpack a gzipped tar archive"""
- def __init__(self, archive, dir):
+ def __init__(self, archive, dir, filter=""):
self.archive = archive
self.dir = dir
+ exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0]
+
if archive.lower().endswith(".bz2"):
decompress = "--bzip2"
else:
decompress = "--gzip"
- Command.__init__(self, 'tar', [ '-C', dir, decompress, '-xf', archive ])
+
+ Command.__init__(self, 'tar', [ exclude, '-C', dir, decompress, '-xf', archive ])
self.run_error = "Couldn't unpack %s" % self.archive
@@ -178,10 +182,17 @@ class GitTag(GitCommand):
class GitAdd(GitCommand):
"""Wrap git-add to add new files"""
def __init__(self):
- GitCommand.__init__(self,'add')
+ GitCommand.__init__(self, 'add')
self.run_error = "Couldn't add files"
+class GitRm(GitCommand):
+ """Wrap git-rm to remove files"""
+ def __init__(self):
+ GitCommand.__init__(self, 'rm')
+ self.run_error = "Couldn't remove files"
+
+
class GitCommitAll(GitCommand):
"""Wrap git-commit to commit all changes"""
def __init__(self):
@@ -193,4 +204,26 @@ class GitCommitAll(GitCommand):
GitCommand.__call__(self, args)
+def copy_from(orig_dir, filter=""):
+ """
+ copy a source tree over via tar
+ @param orig_dir: where to copy from
+ @param exclude: tar exclude pattern
+ @return: list of copied files
+ @rtype: list
+ """
+ exclude = [ "", "--exclude=%s" % filter ][len(filter) > 0]
+
+ try:
+ p1 = subprocess.Popen(["tar", exclude, "-cSpf", "-", "." ], stdout=subprocess.PIPE, cwd=orig_dir)
+ p2 = subprocess.Popen(["tar", "-xvSpf", "-" ], stdin=p1.stdout, stdout=subprocess.PIPE)
+ files = p2.communicate()[0].split('\n')
+ except OSError, err:
+ raise GbpError, "Cannot copy files: %s" % err
+ except ValueError, err:
+ raise GbpError, "Cannot copy files: %s" % err
+ if p1.wait() or p2.wait():
+ raise GbpError, "Cannot copy files, pipe failed."
+ return [ os.path.normpath(f) for f in files if files ]
+
# vim:et:ts=4:sw=4: