summaryrefslogtreecommitdiff
path: root/morphlib/bins.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/bins.py')
-rw-r--r--morphlib/bins.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py
index 0f628210..90d96d82 100644
--- a/morphlib/bins.py
+++ b/morphlib/bins.py
@@ -24,6 +24,7 @@ Binaries are chunks, strata, and system images.
import logging
import os
import re
+import tarfile
import tempfile
import morphlib
@@ -81,16 +82,10 @@ def create_chunk(rootdir, chunk_filename, regexps, ex,
dump_memory_profile('after walking')
include = sorted(include) # get dirs before contents
- fd, include_filename = tempfile.mkstemp()
- os.close(fd)
- with open(include_filename, 'w') as f:
- for name in include:
- f.write('%s\0' % mkrel(name))
- ex.runv(['tar', '-C', rootdir, '-caf', chunk_filename,
- '--null', '-T', include_filename, '--no-recursion'],
- as_fakeroot=True)
- os.remove(include_filename)
- dump_memory_profile('after creating tarball')
+ tar = tarfile.open(name=chunk_filename, mode='w:gz')
+ for filename in include:
+ tar.add(filename, arcname=mkrel(filename), recursive=False)
+ tar.close()
include.remove(rootdir)
for filename in reversed(include):