Commit 1570e3f5 authored by prasadv@chromium.org's avatar prasadv@chromium.org

Use python fallback for unzipping in extracting build on mac if file is greater than 4GB

BUG=379195

Review URL: https://codereview.chromium.org/306023008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273929 0039d316-1c4b-4281-b951-d872f2087c98
parent cf70d8a8
...@@ -522,10 +522,15 @@ def ExtractZip(filename, output_dir, verbose=True): ...@@ -522,10 +522,15 @@ def ExtractZip(filename, output_dir, verbose=True):
# handle links and file bits (executable), which is much # handle links and file bits (executable), which is much
# easier then trying to do that with ZipInfo options. # easier then trying to do that with ZipInfo options.
# #
# The Mac Version of unzip unfortunately does not support Zip64, whereas
# the python module does, so we have to fallback to the python zip module
# on Mac if the filesize is greater than 4GB.
#
# On Windows, try to use 7z if it is installed, otherwise fall back to python # On Windows, try to use 7z if it is installed, otherwise fall back to python
# zip module and pray we don't have files larger than 512MB to unzip. # zip module and pray we don't have files larger than 512MB to unzip.
unzip_cmd = None unzip_cmd = None
if IsMac() or IsLinux(): if ((IsMac() and os.path.getsize(filename) < 4 * 1024 * 1024 * 1024)
or IsLinux()):
unzip_cmd = ['unzip', '-o'] unzip_cmd = ['unzip', '-o']
elif IsWindows() and os.path.exists('C:\\Program Files\\7-Zip\\7z.exe'): elif IsWindows() and os.path.exists('C:\\Program Files\\7-Zip\\7z.exe'):
unzip_cmd = ['C:\\Program Files\\7-Zip\\7z.exe', 'x', '-y'] unzip_cmd = ['C:\\Program Files\\7-Zip\\7z.exe', 'x', '-y']
...@@ -541,12 +546,16 @@ def ExtractZip(filename, output_dir, verbose=True): ...@@ -541,12 +546,16 @@ def ExtractZip(filename, output_dir, verbose=True):
if result: if result:
raise IOError('unzip failed: %s => %s' % (str(command), result)) raise IOError('unzip failed: %s => %s' % (str(command), result))
else: else:
assert IsWindows() assert IsWindows() or IsMac()
zf = zipfile.ZipFile(filename) zf = zipfile.ZipFile(filename)
for name in zf.namelist(): for name in zf.namelist():
if verbose: if verbose:
print 'Extracting %s' % name print 'Extracting %s' % name
zf.extract(name, output_dir) zf.extract(name, output_dir)
if IsMac():
# Restore permission bits.
os.chmod(os.path.join(output_dir, name),
zf.getinfo(name).external_attr >> 16L)
def RunProcess(command): def RunProcess(command):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment