Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1212)

Unified Diff: remoting/host/installer/build-installer-archive.py

Issue 10221027: [Chromoting] Update installer archive to check file extensions in one location. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/installer/build-installer-archive.py
===================================================================
--- remoting/host/installer/build-installer-archive.py (revision 134542)
+++ remoting/host/installer/build-installer-archive.py (working copy)
@@ -71,38 +71,43 @@
zip.close()
-def copyFileIntoArchive(src_file, out_dir, files_root, dst_file, defs):
- """Copies the src_file into the out_dir, preserving the directory structure.
+def remapSrcFile(dst_root, src_root, src_file):
+ """Calculates destination file path and creates directory.
+ The |src_root| prefix is stripped from |src_file| before
+ appending to |dst_root|.
+
+ For example, given:
+ dst_root = /output
+ src_root = host/installer/mac
+ src_file = host/installer/mac/Scripts/keystone_install.sh
+ The final calculated path is:
+ /output/Scripts/keystone_install.sh
+
Args:
- 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 out_dir.
- dst_file: Relative path (and filename) where src_file should be copied.
- defs: Dictionary of variable definitions.
+ dst_root: Target directory where files are copied.
+ src_root: Path prefix which is stripped of |src_file| before appending
+ it to the |dst_root|.
+ src_file: Source file to be copied.
+ Returns:
+ Full path to destination file in |dst_root|.
"""
- root_len = len(files_root)
- 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)
+ # Strip of directory prefix.
+ if src_file.startswith(src_root):
+ src_file = src_file[len(src_root):]
+ dst_file = os.path.join(dst_root, src_file)
+ # Make sure target directory exists.
+ dst_dir = os.path.dirname(dst_file)
if not os.path.exists(dst_dir):
os.makedirs(dst_dir, 0775)
+ return dst_file
- (base, ext) = os.path.splitext(src_file)
- if ext == '.app':
- shutil.copytree(src_file, full_dst_file)
- elif ext in ['.sh', '.packproj', '.plist']:
- copyFileWithDefs(src_file, full_dst_file, defs)
- else:
- shutil.copy2(src_file, full_dst_file)
-
def copyFileWithDefs(src_file, dst_file, defs):
"""Copies from src_file to dst_file, performing variable substitution.
- Any @@variables@@ in the source are replaced with
- file with the out_dir, preserving the directory structure.
+ Any @@VARIABLE@@ in the source is replaced with the value of VARIABLE
+ in the |defs| dictionary when written to the destination file.
Args:
src_file: Full or relative path to source file to copy.
@@ -138,9 +143,7 @@
os.chdir(old_dir)
# Unzip into correct dir in out_dir.
- 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_path = remapSrcFile(out_dir, files_root, zip_file)
out_zip_dir = os.path.dirname(out_zip_path)
(src_dir, ignore1) = os.path.splitext(zip_file)
@@ -165,16 +168,23 @@
"""
cleanDir(temp_dir)
- for file in source_files:
- base_file = os.path.basename(file)
- (base, ext) = os.path.splitext(file)
+ for f in source_files:
+ dst_file = remapSrcFile(temp_dir, source_files_root, f)
+ base_file = os.path.basename(f)
+ (base, ext) = os.path.splitext(f)
if ext == '.zip':
- copyZipIntoArchive(temp_dir, source_files_root, file)
+ copyZipIntoArchive(temp_dir, source_files_root, f)
+ elif ext in ['.sh', '.packproj', '.plist']:
+ copyFileWithDefs(f, dst_file, defs)
else:
- copyFileIntoArchive(file, temp_dir, source_files_root, file, defs)
+ shutil.copy2(src_file, dst_file)
for bs, bd in zip(gen_files, gen_files_dst):
- copyFileIntoArchive(bs, temp_dir, '', bd, {})
+ dst_file = remapSrcFile(temp_dir, source_files_root, bd)
+ if os.path.isdir(bs):
+ shutil.copytree(bs, dst_file)
+ else:
+ shutil.copy2(bs, dst_file)
createZip(zip_path, temp_dir)
@@ -183,6 +193,7 @@
sys.stderr.write('ERROR: %s' % msg)
sys.exit(1)
+
def usage():
"""Display basic usage information."""
print ('Usage: %s\n'
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698