summaryrefslogtreecommitdiff
path: root/morphlib/bins.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-12-14 13:54:36 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-12-14 14:32:21 +0000
commitfaa3bf4f433a85a5f8e6840f1d4c2752f051e5fc (patch)
treed6a1a1d43eca2eb10b466a98a1f54cb64e7f9ab1 /morphlib/bins.py
parentf6bcb363aad315e710a90f810c33341a9d502da2 (diff)
downloadmorph-faa3bf4f433a85a5f8e6840f1d4c2752f051e5fc.tar.gz
use tarfile again
Busybox tar is incapable of doing this, so we have to use Python's tarlib, at least for now.
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):