diff options
author | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 22:00:01 +0000 |
---|---|---|
committer | binji@chromium.org <binji@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-30 22:00:01 +0000 |
commit | 33493a5e530a213fd6aeb3cac72ffa9052c19854 (patch) | |
tree | 8f9c46c5655da6fba679ba25b86b44b7eed54c86 /native_client_sdk | |
parent | d8962b98690f35a6fe5e2b0e25a405aeee6b24cc (diff) | |
download | chromium_src-33493a5e530a213fd6aeb3cac72ffa9052c19854.zip chromium_src-33493a5e530a213fd6aeb3cac72ffa9052c19854.tar.gz chromium_src-33493a5e530a213fd6aeb3cac72ffa9052c19854.tar.bz2 |
[NaCl SDK] Fix zip_test failure on mac buildbots.
The mac buildbots use an older version of python 2.6 that doesn't support
adding directories to zipfiles. Work around it by adding an empty file with the
same zip path (which is basically what later versions do anyway).
BUG=none
R=sbc@chromium.org
TBR=noelallen@chromium.org
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/11428111
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170564 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rwxr-xr-x | native_client_sdk/src/tools/oshelpers.py | 20 | ||||
-rwxr-xr-x | native_client_sdk/src/tools/zip_test.py | 2 |
2 files changed, 21 insertions, 1 deletions
diff --git a/native_client_sdk/src/tools/oshelpers.py b/native_client_sdk/src/tools/oshelpers.py index 041e9aa..66fef14 100755 --- a/native_client_sdk/src/tools/oshelpers.py +++ b/native_client_sdk/src/tools/oshelpers.py @@ -9,6 +9,7 @@ import optparse import os import posixpath import shutil +import stat import sys import time import zipfile @@ -425,7 +426,24 @@ def Zip(args): zip_path = file_info_or_zip_path if os_path: - zip_stream.write(os_path, zip_path) + st = os.stat(os_path) + if stat.S_ISDIR(st.st_mode): + # Python 2.6 on the buildbots doesn't support writing directories to + # zip files. This was resolved in a later version of Python 2.6. + # We'll work around it by writing an empty file with the correct + # path. (This is basically what later versions do anyway.) + zip_info = zipfile.ZipInfo() + zip_info.filename = zip_path + zip_info.date_time = time.localtime(st.st_mtime)[0:6] + zip_info.compress_type = zip_stream.compression + zip_info.flag_bits = 0x00 + zip_info.external_attr = (st[0] & 0xFFFF) << 16L + zip_info.CRC = 0 + zip_info.compress_size = 0 + zip_info.file_size = 0 + zip_stream.writestr(zip_info, '') + else: + zip_stream.write(os_path, zip_path) else: zip_stream.writestr(file_info_or_zip_path, file_bytes) diff --git a/native_client_sdk/src/tools/zip_test.py b/native_client_sdk/src/tools/zip_test.py index 66f61bc..6c09cde 100755 --- a/native_client_sdk/src/tools/zip_test.py +++ b/native_client_sdk/src/tools/zip_test.py @@ -104,6 +104,8 @@ class TestZip(unittest.TestCase): self.RunZip([self.zipname, 'dir1']) self.OpenZipFile() self.assertEqual(len(self.zipfile.namelist()), 1) + self.assertRaises(KeyError, self.zipfile.getinfo, 'dir1') + self.zipfile.getinfo('dir1/') def testAddRecursive(self): os.mkdir(self.GetTempPath('dir1')) |