diff options
author | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 23:32:42 +0000 |
---|---|---|
committer | garykac@chromium.org <garykac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-20 23:32:42 +0000 |
commit | 4a6cb8ba225aa2b0a50618142909faed1cb58f91 (patch) | |
tree | a20f9767e93b938d2d7fbe30f5176755a3397cd4 /remoting | |
parent | cf988f0ea873f575519ae551c5db5f426b06cc6d (diff) | |
download | chromium_src-4a6cb8ba225aa2b0a50618142909faed1cb58f91.zip chromium_src-4a6cb8ba225aa2b0a50618142909faed1cb58f91.tar.gz chromium_src-4a6cb8ba225aa2b0a50618142909faed1cb58f91.tar.bz2 |
[Chromoting] Unpack .zip files when building installer archive.
Review URL: https://chromiumcodereview.appspot.com/10086017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@133303 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/host/installer/build-installer-archive.py | 48 | ||||
-rw-r--r-- | remoting/remoting.gyp | 4 |
2 files changed, 41 insertions, 11 deletions
diff --git a/remoting/host/installer/build-installer-archive.py b/remoting/host/installer/build-installer-archive.py index 61442b0..3a4ede6 100644 --- a/remoting/host/installer/build-installer-archive.py +++ b/remoting/host/installer/build-installer-archive.py @@ -61,18 +61,51 @@ def copyFileIntoArchive(src_file, out_dir, files_root, dst_file): src_file: Full or relative path to source file to copy. out_dir: Target directory where files are copied. files_root: Path prefix which is stripped of dst_file before appending - it to the temp_dir. + it to the out_dir. dst_file: Relative path (and filename) where src_file should be copied. """ root_len = len(files_root) - local_path = dst_file[root_len:] - full_dst_file = os.path.join(out_dir, local_path) + local_file_path = dst_file[root_len:] + full_dst_file = os.path.join(out_dir, local_file_path) dst_dir = os.path.dirname(full_dst_file) if not os.path.exists(dst_dir): os.makedirs(dst_dir, 0775) shutil.copy2(src_file, full_dst_file) +def copyZipIntoArchive(out_dir, files_root, zip_file): + """Expands the zip_file into the out_dir, preserving the directory structure. + + Args: + out_dir: Target directory where unzipped files are copied. + files_root: Path prefix which is stripped of zip_file before appending + it to the out_dir. + zip_file: Relative path (and filename) to the zip file. + """ + # Unzip into correct dir in out_dir. + zip_archive = zipfile.ZipFile(zip_file, 'r') + root_len = len(files_root) + relative_zip_path = zip_file[root_len:] + out_zip_path = os.path.join(out_dir, relative_zip_path) + out_zip_dir = os.path.dirname(out_zip_path) + if not os.path.exists(out_zip_dir): + os.makedirs(out_zip_dir, 0775) + + # Ideally, we'd simply do: + # zip_archive.extractall(out_zip_dir) + # but http://bugs.python.org/issue4710 bites us because the some 'bots (like + # mac_rel) are still running Python 2.6. + # See http://stackoverflow.com/questions/639962/unzipping-directory-structure-with-python + # for workarounds. + # TODO(garykac): Remove this once all bots are > 2.6. + for f in zip_archive.namelist(): + if f.endswith('/'): + if not os.path.exists(f): + os.makedirs(os.path.join(out_zip_dir, f)) + else: + zip_archive.extract(f, out_zip_dir) + + def buildHostArchive(temp_dir, zip_path, source_files_root, source_files, gen_files, gen_files_dst): """Builds a zip archive with the files needed to build the installer. @@ -91,12 +124,9 @@ def buildHostArchive(temp_dir, zip_path, source_files_root, source_files, for file in source_files: base_file = os.path.basename(file) - if base_file == '*': - # Copy entire directory tree. - for (root, dirs, files) in os.walk(os.path.dirname(file)): - for f in files: - full_path = os.path.join(root, f) - copyFileIntoArchive(full_path, temp_dir, files_root, full_path) + (base, ext) = os.path.splitext(file) + if ext == '.zip': + copyZipIntoArchive(temp_dir, source_files_root, file) else: copyFileIntoArchive(file, temp_dir, source_files_root, file) diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index fb410aa..9519abd 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -167,14 +167,14 @@ ], 'remoting_host_installer_mac_root': 'host/installer/mac/', 'remoting_host_installer_mac_files': [ - #'host/installer/mac/ChromeRemoteDesktop.packproj', + 'host/installer/mac/ChromeRemoteDesktop.packproj', 'host/installer/mac/Chromoting.packproj', 'host/installer/mac/LaunchAgents/org.chromium.chromoting.plist', 'host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.json', 'host/installer/mac/PrivilegedHelperTools/org.chromium.chromoting.me2me.sh', 'host/installer/mac/Scripts/keystone_install.sh', 'host/installer/mac/Scripts/remoting_postflight.sh', - #'host/installer/mac/Keystone/GoogleSoftwareUpdate.pkg.zip', + 'host/installer/mac/Keystone/GoogleSoftwareUpdate.pkg.zip', ], }, |