[Python-checkins] CVS: distutils/distutils archive_util.py,1.2,1.3
Greg Ward
python-dev@python.org
Mon, 24 Apr 2000 21:38:22 -0400 (EDT)
Update of /projects/cvsroot/distutils/distutils
In directory newcnri:/tmp/cvs-serv10857
Modified Files:
archive_util.py
Log Message:
Harry Henry Gebel:
Adds bztar format to generate .tar.bz2 tarballs
Uses the -f argument to overright old tarballs automatically, I am
assuming that if the old tarball was wanted it would have been moved or
else the version number would have been changed.
Uses the -9 argument to bzip2 and gzip to use maximum
compression. Compress uses the maximum compression by default.
Tests for correct value for the 'compress' argument of make_tarball. This
is one less place for someone adding new compression programs to forget to
change.
Index: archive_util.py
===================================================================
RCS file: /projects/cvsroot/distutils/distutils/archive_util.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** archive_util.py 2000/04/22 03:09:56 1.2
--- archive_util.py 2000/04/25 01:38:18 1.3
***************
*** 6,10 ****
# created 2000/04/03, Greg Ward (extracted from util.py)
! __revision__ = "$Id: archive_util.py,v 1.2 2000/04/22 03:09:56 gward Exp $"
import os
--- 6,10 ----
# created 2000/04/03, Greg Ward (extracted from util.py)
! __revision__ = "$Id: archive_util.py,v 1.3 2000/04/25 01:38:18 gward Exp $"
import os
***************
*** 16,25 ****
verbose=0, dry_run=0):
"""Create a (possibly compressed) tar file from all the files under
! 'base_dir'. 'compress' must be "gzip" (the default), "compress", or
! None. Both "tar" and the compression utility named by 'compress'
! must be on the default program search path, so this is probably
! Unix-specific. The output tar file will be named 'base_dir' +
! ".tar", possibly plus the appropriate compression extension
! (".gz" or ".Z"). Return the output filename."""
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
--- 16,25 ----
verbose=0, dry_run=0):
"""Create a (possibly compressed) tar file from all the files under
! 'base_dir'. 'compress' must be "gzip" (the default), "compress",
! "bzip2", or None. Both "tar" and the compression utility named by
! 'compress' must be on the default program search path, so this is
! probably Unix-specific. The output tar file will be named 'base_dir'
! + ".tar", possibly plus the appropriate compression extension (".gz",
! ".bz2" or ".Z"). Return the output filename."""
# XXX GNU tar 1.13 has a nifty option to add a prefix directory.
***************
*** 30,36 ****
compress_ext = { 'gzip': ".gz",
'compress': ".Z" }
! if compress is not None and compress not in ('gzip', 'compress'):
raise ValueError, \
"bad value for 'compress': must be None, 'gzip', or 'compress'"
--- 30,42 ----
compress_ext = { 'gzip': ".gz",
+ 'bzip2': '.bz2',
'compress': ".Z" }
+
+ # flags for compression program, each element of list will be an argument
+ compress_flags = {'gzip': ["-f9"],
+ 'compress': ["-f"],
+ 'bzip2': ['-f9']}
! if compress is not None and compress not in compress_ext.keys():
raise ValueError, \
"bad value for 'compress': must be None, 'gzip', or 'compress'"
***************
*** 41,45 ****
if compress:
! spawn ([compress, archive_name], verbose=verbose, dry_run=dry_run)
return archive_name + compress_ext[compress]
else:
--- 47,52 ----
if compress:
! spawn ([compress] + compress_flags[compress] + [archive_name],
! verbose=verbose, dry_run=dry_run)
return archive_name + compress_ext[compress]
else:
***************
*** 105,108 ****
--- 112,116 ----
ARCHIVE_FORMATS = {
'gztar': (make_tarball, [('compress', 'gzip')]),
+ 'bztar': (make_tarball, [('compress', 'bzip2')]),
'ztar': (make_tarball, [('compress', 'compress')]),
'tar': (make_tarball, [('compress', None)]),