Source code file content
17178428 pkg history is not capturing release notes
Size: 4691 bytes, 1 line
# CDDL HEADER START
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
# CDDL HEADER END
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
# Without the below statements, tarfile will trigger calls to getpwuid
# and getgrgid for every file extracted. This in turn leads to nscd
# usage which slows down the install phase. Setting these attributes
# to undefined causes tarfile to skip these calls in
# tarfile.gettarinfo(). This information is unnecesary as it will not
# be used by the client.
tarfile.pwd = None
tarfile.grp = None
"""PkgTarFile is a subclass of TarFile. It implements
a small number of additional instance methods to improve
the functionality of the TarFile class for the packaging classes.
XXX - Push these changes upstream to Python maintainers?
def __init__(self, *args, **kwargs):
tarfile.TarFile.__init__(self, *args, **kwargs)
def extract_to(self, member, path="", filename=""):
"""Extract a member from the TarFile archive. This
method allows you to specify a new filename and path, using
the filename and path arguments, where the file will be
extracted. This method is similar to extract().
Extract() only allows the caller to prepend a directory path
to the filename specified in the TarInfo object,
whereas this method allows the caller to additionally
specify a file name.
if isinstance(member, tarfile.TarInfo):
tarinfo = member
tarinfo = self.getmember(member)
tarinfo._link_target = \
if not filename:
filename = tarinfo.name
upperdirs = os.path.dirname(os.path.join(path, filename))
if upperdirs and not os.path.exists(upperdirs):
# The tarfile we receive contains only files, and none
# of the containing directories. The tarfile code will
# create the directories as necessary, but with mode
# 777, which is insuffficiently secure. Thus we create
# these directories in advance with tighter permissions;
# they'll be fixed up later, when the action execute
# methods run. If proper directory actions
# don't exist for these directories, the permissions
# will be wrong.
except EnvironmentError, e:
if self.errorlevel > 0:
if e.filename is None:
self._dbg(1, "tarfile %s" % e.strerror)
self._dbg(1, "tarfile: %s %r" % (
except tarfile.ExtractError, e:
if self.errorlevel > 1:
self._dbg(1, "tarfile: %s" % e)