summaryrefslogtreecommitdiffstats
path: root/Lib/distutils/archive_util.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/distutils/archive_util.py')
-rw-r--r--Lib/distutils/archive_util.py71
1 files changed, 5 insertions, 66 deletions
diff --git a/Lib/distutils/archive_util.py b/Lib/distutils/archive_util.py
index 28e93fe..16164c7 100644
--- a/Lib/distutils/archive_util.py
+++ b/Lib/distutils/archive_util.py
@@ -14,55 +14,15 @@ from distutils.spawn import spawn
from distutils.dir_util import mkpath
from distutils import log
-try:
- from pwd import getpwnam
-except ImportError:
- getpwnam = None
-
-try:
- from grp import getgrnam
-except ImportError:
- getgrnam = None
-
-def _get_gid(name):
- """Returns a gid, given a group name."""
- if getgrnam is None or name is None:
- return None
- try:
- result = getgrnam(name)
- except KeyError:
- result = None
- if result is not None:
- return result[2]
- return None
-
-def _get_uid(name):
- """Returns an uid, given a user name."""
- if getpwnam is None or name is None:
- return None
- try:
- result = getpwnam(name)
- except KeyError:
- result = None
- if result is not None:
- return result[2]
- return None
-
-def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
- owner=None, group=None):
+def make_tarball(base_name, base_dir, compress="gzip", 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.
- (compress will be deprecated in Python 3.2)
-
- 'owner' and 'group' can be used to define an owner and a group for the
- archive that is being built. If not provided, the current owner and group
- will be used.
-
+ 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").
-
Returns the output filename.
"""
tar_compression = {'gzip': 'gz', 'bzip2': 'bz2', None: '', 'compress': ''}
@@ -84,23 +44,10 @@ def make_tarball(base_name, base_dir, compress="gzip", verbose=0, dry_run=0,
import tarfile # late import so Python build itself doesn't break
log.info('Creating tar archive')
-
- uid = _get_uid(owner)
- gid = _get_gid(group)
-
- def _set_uid_gid(tarinfo):
- if gid is not None:
- tarinfo.gid = gid
- tarinfo.gname = group
- if uid is not None:
- tarinfo.uid = uid
- tarinfo.uname = owner
- return tarinfo
-
if not dry_run:
tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
try:
- tar.add(base_dir, filter=_set_uid_gid)
+ tar.add(base_dir)
finally:
tar.close()
@@ -190,7 +137,7 @@ def check_archive_formats(formats):
return None
def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
- dry_run=0, owner=None, group=None):
+ dry_run=0):
"""Create an archive file (eg. zip or tar).
'base_name' is the name of the file to create, minus any format-specific
@@ -203,9 +150,6 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
ie. 'base_dir' will be the common prefix of all files and
directories in the archive. 'root_dir' and 'base_dir' both default
to the current directory. Returns the name of the archive file.
-
- 'owner' and 'group' are used when creating a tar archive. By default,
- uses the current owner and group.
"""
save_cwd = os.getcwd()
if root_dir is not None:
@@ -227,11 +171,6 @@ def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,
func = format_info[0]
for arg, val in format_info[1]:
kwargs[arg] = val
-
- if format != 'zip':
- kwargs['owner'] = owner
- kwargs['group'] = group
-
try:
filename = func(base_name, base_dir, **kwargs)
finally: