diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2011-12-14 13:54:36 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2011-12-14 14:32:21 +0000 |
commit | faa3bf4f433a85a5f8e6840f1d4c2752f051e5fc (patch) | |
tree | d6a1a1d43eca2eb10b466a98a1f54cb64e7f9ab1 /morphlib | |
parent | f6bcb363aad315e710a90f810c33341a9d502da2 (diff) | |
download | morph-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')
-rw-r--r-- | morphlib/bins.py | 15 |
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): |