OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
2 | |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
rkc
2011/03/29 01:57:30
Nit: 2011 now
| |
4 # Use of this source code is governed by a BSD-style license that can be | |
5 # found in the LICENSE file. | |
6 | |
7 """Makes changes to mounted Chromium OS image to allow it to run with VMs | |
8 | |
9 This script changes two files within the Chromium OS image to let the image | |
10 work with VMs, particularly QEMU | |
11 | |
12 Currently this script does the following, | |
13 1.) Modify xorg.conf to advertize a screen which can do 1280x1024 | |
14 """ | |
15 | |
16 from optparse import OptionParser | |
17 import os | |
18 import stat | |
19 import sys | |
20 | |
21 USAGE = "usage: %prog --mounted_dir=directory" | |
22 | |
23 REPLACE_SCREEN_PAIR = ('Identifier "DefaultMonitor"', | |
24 'Identifier "DefaultMonitor"\n HorizSync 28-51\n VertRefresh 43-60') | |
25 XORG_CONF_FILENAME = os.path.join('etc', 'X11', 'xorg.conf') | |
26 | |
27 | |
28 # Modify the xorg.conf file to change all screen sections | |
29 def FixXorgConf(mount_point): | |
30 xorg_conf_filename = os.path.join(mount_point, XORG_CONF_FILENAME) | |
31 f = open(xorg_conf_filename, 'r') | |
32 xorg_conf = f.read() | |
33 f.close() | |
34 | |
35 # Add refresh rates for the screen | |
36 xorg_conf = xorg_conf.replace(REPLACE_SCREEN_PAIR[0], | |
37 REPLACE_SCREEN_PAIR[1]) | |
38 | |
39 # Write the file back out. | |
40 f = open(xorg_conf_filename, 'w') | |
41 f.write(xorg_conf) | |
42 f.close() | |
43 | |
44 def main(): | |
45 parser = OptionParser(USAGE) | |
46 parser.add_option('--mounted_dir', dest='mounted_dir', | |
47 help='directory where the Chromium OS image is mounted') | |
48 (options, args) = parser.parse_args() | |
49 | |
50 if not options.mounted_dir: | |
51 parser.error("Please specify the mount point for the Chromium OS image"); | |
52 | |
53 FixXorgConf(options.mounted_dir) | |
54 | |
55 | |
56 if __name__ == '__main__': | |
57 main() | |
OLD | NEW |