Skip to content

Commit e45dea3

Browse files
author
blep
committed
- added source tarball decompression
git-svn-id: https://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/jsoncpp@116 1f120ed1-78a5-a849-adca-83f0a9e25bb6
1 parent 3afda5d commit e45dea3

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

devtools/tarball.py

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ def visit(tar, dirname, names):
2929
path_in_tar = archive_name(path)
3030
tar.add(path, path_in_tar )
3131
compression = TARGZ_DEFAULT_COMPRESSION_LEVEL
32-
fileobj = gzip.GzipFile( tarball_path, 'wb', compression )
33-
tar = tarfile.TarFile(os.path.splitext(tarball_path)[0], 'w', fileobj)
34-
for source in sources:
35-
source_path = source
36-
if os.path.isdir( source ):
37-
os.path.walk(source_path, visit, tar)
38-
else:
39-
path_in_tar = archive_name(source_path)
40-
tar.add(source_path, path_in_tar ) # filename, arcname
41-
tar.close()
32+
tar = tarfile.TarFile.gzopen( tarball_path, 'w', compresslevel=compression )
33+
try:
34+
for source in sources:
35+
source_path = source
36+
if os.path.isdir( source ):
37+
os.path.walk(source_path, visit, tar)
38+
else:
39+
path_in_tar = archive_name(source_path)
40+
tar.add(source_path, path_in_tar ) # filename, arcname
41+
finally:
42+
tar.close()
43+
44+
def decompress( tarball_path, base_dir ):
45+
"""Decompress the gzipped tarball into directory base_dir.
46+
"""
47+
# !!! This class method is not documented in the online doc
48+
# nor is bz2open!
49+
tar = tarfile.TarFile.gzopen(tarball_path, mode='r')
50+
try:
51+
tar.extractall( base_dir )
52+
finally:
53+
tar.close()

makerelease.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,11 @@ def main():
167167
source_tarball_path = 'dist/%s.tar.gz' % source_dir
168168
print 'Generating source tarball to', source_tarball_path
169169
tarball.make_tarball( source_tarball_path, [export_dir], export_dir, prefix_dir=source_dir )
170+
171+
distcheck_dir = 'dist/distcheck'
172+
print 'Decompressing source tarball to', distcheck_dir
173+
tarball.decompress( source_tarball_path, distcheck_dir )
170174
#@todo:
171-
# decompress source tarball
172175
# ?compile & run & check
173176
# ?upload documentation
174177
else:

0 commit comments

Comments
 (0)