diff options
author | Lars Wirzenius <liw@liw.fi> | 2011-10-17 20:25:59 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2011-10-17 20:25:59 +0100 |
commit | 7cba0a33cee244379cb2078b7c286c4de5c4f341 (patch) | |
tree | a8e9e7d264336f5adc495e3de0e7d665ccfe0ed0 /morphlib/bins.py | |
parent | 0d62665119d13a113f92de18f918e850f4596f69 (diff) | |
download | morph-7cba0a33cee244379cb2078b7c286c4de5c4f341.tar.gz |
Add functions for creating and unpacking strata.
Diffstat (limited to 'morphlib/bins.py')
-rw-r--r-- | morphlib/bins.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/morphlib/bins.py b/morphlib/bins.py index de946020..06956cd3 100644 --- a/morphlib/bins.py +++ b/morphlib/bins.py @@ -47,3 +47,25 @@ def unpack_chunk(chunk_filename, dirname): tar.extractall(path=dirname) tar.close() + +def create_stratum(rootdir, stratum_filename): + '''Create a stratum from the contents of a directory.''' + logging.debug('Creating stratum file %s from %s' % + (stratum_filename, rootdir)) + tar = tarfile.open(name=stratum_filename, mode='w:gz') + tar.add(rootdir, arcname='.') + tar.close() + + +def unpack_stratum(stratum_filename, dirname): + '''Unpack a stratum into a directory. + + The directory must exist already. + + ''' + + logging.debug('Unpacking stratum %s into %s' % (stratum_filename, dirname)) + tar = tarfile.open(name=stratum_filename) + tar.extractall(path=dirname) + tar.close() + |