[Pkg-xen-changes] [xen] 01/01: Directly generate tar in genorig

Bastian Blank waldi at moszumanska.debian.org
Tue Jan 20 20:17:34 UTC 2015


This is an automated email from the git hooks/post-receive script.

waldi pushed a commit to branch develop
in repository xen.

commit 8c2d6f0c5a8c99085389ca44dd78cddca5bf925b
Author: Bastian Blank <waldi at debian.org>
Date:   Tue Jan 20 20:10:47 2015 +0100

    Directly generate tar in genorig
---
 debian/bin/genorig.py | 41 ++++++++++-------------------------------
 1 file changed, 10 insertions(+), 31 deletions(-)

diff --git a/debian/bin/genorig.py b/debian/bin/genorig.py
index 5f4e8f7..4b6eb9a 100755
--- a/debian/bin/genorig.py
+++ b/debian/bin/genorig.py
@@ -12,18 +12,6 @@ from debian_xen.debian import VersionXen
 from debian_linux.debian import Changelog
 
 
-class RepoGit(object):
-    def __init__(self, repo, options):
-        self.repo = repo
-        self.tag = options.tag or 'HEAD'
-
-    def do_archive(self, info):
-        temp_tar = os.path.join(info.temp_dir, 'orig.tar')
-        args = ('git', 'archive', '--prefix', '%s/' % info.orig_dir, '-o', os.path.realpath(temp_tar), self.tag)
-        subprocess.check_call(args, cwd=self.repo)
-        subprocess.check_call(('tar', '-C', info.temp_dir, '-xf', temp_tar))
-
-
 class Main(object):
     log = sys.stdout.write
 
@@ -46,25 +34,7 @@ class Main(object):
             if options.tag is None:
                 options.tag = 'RELEASE-' + self.version.upstream
 
-        if os.path.exists(os.path.join(repo, '.git')):
-            self.repo = RepoGit(repo, options)
-        else:
-            raise NotImplementedError
-
     def __call__(self):
-        import tempfile
-        self.temp_dir = tempfile.mkdtemp(prefix='genorig', dir='debian')
-        try:
-            self.do_archive()
-            self.do_tar()
-        finally:
-            shutil.rmtree(self.temp_dir)
-
-    def do_archive(self):
-        self.log("Create archive.\n")
-        self.repo.do_archive(self)
-
-    def do_tar(self):
         out = "../orig/%s" % self.orig_tar
         self.log("Generate tarball %s\n" % out)
 
@@ -73,7 +43,16 @@ class Main(object):
             raise RuntimeError("Destination already exists")
         except OSError: pass
 
-        subprocess.check_call(('tar', '-C', self.temp_dir, '-caf', out, self.orig_dir))
+        try:
+            with open(out, 'wb') as f:
+                tag = self.options.tag or 'HEAD'
+                p1 = subprocess.Popen(('git', 'archive', '--prefix', '%s/' % self.orig_dir, tag), stdout=subprocess.PIPE)
+                subprocess.check_call(('xz', ), stdin=p1.stdout, stdout=f)
+                if p1.wait():
+                    raise RuntimeError
+        except:
+            os.unlink(out)
+            raise
 
         try:
             os.symlink(os.path.join('orig', self.orig_tar), os.path.join('..', self.orig_tar))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-xen/xen.git



More information about the Pkg-xen-changes mailing list