Skip to content

Commit

Permalink
- added source tarball decompression
Browse files Browse the repository at this point in the history
  • Loading branch information
blep committed Feb 24, 2010
1 parent e94d2f4 commit 35bdc07
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
32 changes: 22 additions & 10 deletions devtools/tarball.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,25 @@ def visit(tar, dirname, names):
path_in_tar = archive_name(path)
tar.add(path, path_in_tar )
compression = TARGZ_DEFAULT_COMPRESSION_LEVEL
fileobj = gzip.GzipFile( tarball_path, 'wb', compression )
tar = tarfile.TarFile(os.path.splitext(tarball_path)[0], 'w', fileobj)
for source in sources:
source_path = source
if os.path.isdir( source ):
os.path.walk(source_path, visit, tar)
else:
path_in_tar = archive_name(source_path)
tar.add(source_path, path_in_tar ) # filename, arcname
tar.close()
tar = tarfile.TarFile.gzopen( tarball_path, 'w', compresslevel=compression )
try:
for source in sources:
source_path = source
if os.path.isdir( source ):
os.path.walk(source_path, visit, tar)
else:
path_in_tar = archive_name(source_path)
tar.add(source_path, path_in_tar ) # filename, arcname
finally:
tar.close()

def decompress( tarball_path, base_dir ):
"""Decompress the gzipped tarball into directory base_dir.
"""
# !!! This class method is not documented in the online doc
# nor is bz2open!
tar = tarfile.TarFile.gzopen(tarball_path, mode='r')
try:
tar.extractall( base_dir )
finally:
tar.close()
5 changes: 4 additions & 1 deletion makerelease.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,11 @@ def main():
source_tarball_path = 'dist/%s.tar.gz' % source_dir
print 'Generating source tarball to', source_tarball_path
tarball.make_tarball( source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir )

distcheck_dir = 'dist/distcheck'
print 'Decompressing source tarball to', distcheck_dir
tarball.decompress( source_tarball_path, distcheck_dir )
#@todo:
# decompress source tarball
# ?compile & run & check
# ?upload documentation
else:
Expand Down

0 comments on commit 35bdc07

Please sign in to comment.