OLD | NEW |
| (Empty) |
1 #!/usr/bin/python2.4 | |
2 # Copyright 2009-2010 Google Inc. | |
3 # | |
4 # Licensed under the Apache License, Version 2.0 (the "License"); | |
5 # you may not use this file except in compliance with the License. | |
6 # You may obtain a copy of the License at | |
7 # | |
8 # http://www.apache.org/licenses/LICENSE-2.0 | |
9 # | |
10 # Unless required by applicable law or agreed to in writing, software | |
11 # distributed under the License is distributed on an "AS IS" BASIS, | |
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 # See the License for the specific language governing permissions and | |
14 # limitations under the License. | |
15 # ======================================================================== | |
16 | |
17 import os | |
18 import re | |
19 | |
20 from installers import tag_meta_installers | |
21 | |
22 | |
23 def TagOneBundle(env, bundle, untagged_binary_path, output_dir): | |
24 tag_str = tag_meta_installers.BuildTagStringForBundle(bundle) | |
25 | |
26 # Need to find relative path to output file under source dir, to allow | |
27 # it to be redirected under the output directory. | |
28 indx = bundle.output_file_name.find('installers') | |
29 relative_filepath = bundle.output_file_name[indx+len('installers')+1:] | |
30 | |
31 tag_exe = '$TESTS_DIR/ApplyTag.exe' | |
32 | |
33 tag_output = env.Command( | |
34 target='%s/%s' % (output_dir, relative_filepath), | |
35 source=untagged_binary_path, | |
36 action='%s $SOURCES $TARGET %s' % ( | |
37 env.File(tag_exe).abspath, tag_str) | |
38 ) | |
39 | |
40 # Add extra (hidden) dependency plus a dependency on the tag executable. | |
41 env.Depends(tag_output, [bundle.installers_txt_filename, tag_exe]) | |
42 | |
43 return tag_output | |
44 | |
45 | |
46 def _ReadAllBundleInstallerFiles(installers_txt_files_path): | |
47 """Enumerates all the .*_installers.txt files in the installers_txt_files_path | |
48 directory, and creates bundles corresponding to the info in each line in | |
49 the *_installers.txt file. | |
50 Returns: | |
51 Returns a dictionary of Bundles with key=lang. | |
52 """ | |
53 bundles = {} | |
54 files = os.listdir(installers_txt_files_path) | |
55 for file in files: | |
56 regex = re.compile('^(.*)_installers.txt$') | |
57 if not regex.match(file): | |
58 continue | |
59 | |
60 installer_file = os.path.join(installers_txt_files_path, file) | |
61 | |
62 # Read in the installer file. | |
63 read_bundles = tag_meta_installers.ReadBundleInstallerFile(installer_file) | |
64 | |
65 for (key, bundle_list) in read_bundles.items(): | |
66 if not bundle_list or not key: | |
67 continue | |
68 if not bundles.has_key(key): | |
69 bundles[key] = bundle_list | |
70 else: | |
71 new_bundles_list = bundles[key] + bundle_list | |
72 bundles[key] = new_bundles_list | |
73 return bundles | |
74 | |
75 | |
76 def CreateTaggedInstallers(env, installers_txt_files_path, product_name, | |
77 prefix = ''): | |
78 """For each application with an installers.txt file in installer_files_path, | |
79 create tagged metainstaller(s). | |
80 """ | |
81 bundles = _ReadAllBundleInstallerFiles(installers_txt_files_path) | |
82 | |
83 untagged_binary = '%s%sSetup.exe' % (prefix, product_name) | |
84 | |
85 tag_meta_installers.SetOutputFileNames(untagged_binary, bundles, '') | |
86 for bundles_lang in bundles.itervalues(): | |
87 for bundle in bundles_lang: | |
88 TagOneBundle( | |
89 env=env, | |
90 bundle=bundle, | |
91 untagged_binary_path='$STAGING_DIR/%s' % (untagged_binary), | |
92 output_dir='$TARGET_ROOT/Tagged_Installers', | |
93 ) | |
94 | |
OLD | NEW |