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): | |
15 popen = subprocess.Popen( | |
16 command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | |
17 out, _ = popen.communicate() | |
18 return popen.returncode, out | |
19 | |
20 def main(): | |
21 parser = OptionParser() | |
22 parser.add_option('--wix_path', dest='wix_path') | |
23 parser.add_option('--input', dest='input') | |
24 parser.add_option('--intermediate_dir', dest='intermediate_dir') | |
25 parser.add_option('--output', dest='output') | |
26 options, args = parser.parse_args() | |
27 if args: | |
28 parser.error("no positional arguments expected") | |
29 parameters = dict(options.__dict__) | |
30 | |
31 parameters['basename'] = os.path.splitext(os.path.basename(options.output))[0] | |
32 | |
33 dark_template = ('"%(wix_path)s\\dark" ' + | |
34 '-nologo ' + | |
35 '"%(input)s" ' + | |
36 '-o "%(intermediate_dir)s/%(basename)s.wxs" ' + | |
37 '-x "%(intermediate_dir)s"') | |
38 (rc, out) = run(dark_template % parameters) | |
39 if rc: | |
40 for line in out.splitlines(): | |
41 print line | |
42 print 'dark.exe returned %d' % 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, out) = run(candle_template % parameters) | |
51 if rc: | |
52 for line in out.splitlines(): | |
53 print line | |
54 print 'candle.exe returned %d' % rc | |
55 return rc | |
56 | |
57 light_template = ('"%(wix_path)s\\light" ' + | |
58 '-nologo ' + | |
59 '"%(intermediate_dir)s/%(basename)s.wixobj" ' + | |
60 '-o "%(output)s" ' + | |
61 '-ext "%(wix_path)s\\WixFirewallExtension.dll" ' + | |
62 '-sw1076 ') | |
63 (rc, out) = run(light_template % parameters) | |
64 if rc: | |
65 for line in out.splitlines(): | |
66 print line | |
67 print 'candle.exe returned %d' % rc | |
68 return rc | |
69 | |
70 return 0 | |
71 | |
72 if __name__ == "__main__": | |
73 sys.exit(main()) | |
OLD | NEW |