OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Run 'dark', 'candle', and 'light', to confirm that an msi can be unpacked | |
7 repacked successfully.""" | |
8 | |
9 from optparse import OptionParser | |
10 import os | |
11 import subprocess | |
12 import sys | |
13 | |
14 def run(command, filter=None): | |
15 popen = subprocess.Popen( | |
16 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
17 out, _ = popen.communicate() | |
18 for line in out.splitlines(): | |
19 if filter and line.strip() != filter: | |
20 print line | |
21 return popen.returncode | |
22 | |
23 def main(): | |
24 parser = OptionParser() | |
25 parser.add_option('--wix_path', dest='wix_path') | |
26 parser.add_option('--input', dest='input') | |
27 parser.add_option('--intermediate_dir', dest='intermediate_dir') | |
28 parser.add_option('--output', dest='output') | |
29 options, args = parser.parse_args() | |
30 if args: | |
31 parser.error("no positional arguments expected") | |
32 parameters = dict(options.__dict__) | |
33 | |
34 parameters['basename'] = os.path.splitext(os.path.basename(options.output))[0] | |
35 | |
36 dark_template = ('"%(wix_path)s\\dark" ' + | |
37 '-nologo ' + | |
38 '"%(input)s" ' + | |
39 '-o "%(intermediate_dir)s/%(basename)s.wxs" ' + | |
40 '-x "%(intermediate_dir)s"') | |
41 rc = run(dark_template % parameters) | |
42 if rc: | |
43 return rc | |
44 | |
45 candle_template = ('"%(wix_path)s\\candle" ' + | |
46 '-nologo ' + | |
47 '"%(intermediate_dir)s/%(basename)s.wxs" ' + | |
48 '-o "%(intermediate_dir)s/%(basename)s.wixobj" ' + | |
49 '-ext "%(wix_path)s\\WixFirewallExtension.dll"') | |
50 rc = run(candle_template % parameters, parameters['basename'] + '.wxs') | |
51 if rc: | |
52 return rc | |
53 | |
54 light_template = ('"%(wix_path)s\\light" ' + | |
55 '-nologo ' + | |
56 '"%(intermediate_dir)s/%(basename)s.wixobj" ' + | |
57 '-o "%(output)s" ' + | |
58 '-ext "%(wix_path)s\\WixFirewallExtension.dll" ' + | |
59 '-sw1076 ') | |
60 rc = run(light_template % parameters) | |
61 if rc: | |
62 return rc | |
63 | |
64 return 0 | |
65 | |
66 if __name__ == "__main__": | |
67 sys.exit(main()) | |
OLD | NEW |