1 | #!/usr/bin/perl -w
|
---|
2 | #
|
---|
3 | # Guest Additions X11 config update script
|
---|
4 | #
|
---|
5 | # Copyright (C) 2006-2010 Oracle Corporation
|
---|
6 | #
|
---|
7 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
8 | # available from http://www.virtualbox.org. This file is free software;
|
---|
9 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | # General Public License (GPL) as published by the Free Software
|
---|
11 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | #
|
---|
15 |
|
---|
16 | my $temp="/tmp/xorg.conf";
|
---|
17 | my $os_type=`uname -s`;
|
---|
18 | my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
|
---|
19 | "/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
|
---|
20 | "/usr/lib/X11/xorg.conf", "/etc/X11/XF86Config-4", "/etc/X11/XF86Config",
|
---|
21 | "/etc/XF86Config", "/usr/X11R6/etc/X11/XF86Config-4", "/usr/X11R6/etc/X11/XF86Config",
|
---|
22 | "/usr/X11R6/lib/X11/XF86Config-4", "/usr/X11R6/lib/X11/XF86Config");
|
---|
23 | my $CFG;
|
---|
24 | my $TMP;
|
---|
25 |
|
---|
26 | my $config_count = 0;
|
---|
27 |
|
---|
28 | foreach $cfg (@cfg_files)
|
---|
29 | {
|
---|
30 |
|
---|
31 | if (open(CFG, $cfg))
|
---|
32 | {
|
---|
33 | open(TMP, ">$temp") or die "Can't create $TMP: $!\n";
|
---|
34 |
|
---|
35 | my $in_section = 0;
|
---|
36 |
|
---|
37 | while (defined ($line = <CFG>))
|
---|
38 | {
|
---|
39 | if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i)
|
---|
40 | {
|
---|
41 | my $section = lc($1);
|
---|
42 | if ($section eq "device")
|
---|
43 | {
|
---|
44 | $in_section = 1;
|
---|
45 | }
|
---|
46 | } else {
|
---|
47 | if ($line =~ /^\s*EndSection/i)
|
---|
48 | {
|
---|
49 | $in_section = 0;
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | if ($in_section)
|
---|
54 | {
|
---|
55 | if ($line =~ /^\s*driver\s+\"(?:fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i)
|
---|
56 | {
|
---|
57 | $line = " Driver \"vboxvideo\"\n";
|
---|
58 | }
|
---|
59 | }
|
---|
60 | print TMP $line;
|
---|
61 | }
|
---|
62 |
|
---|
63 | close(TMP);
|
---|
64 |
|
---|
65 | rename $cfg, $cfg.".bak";
|
---|
66 | system("cp $temp $cfg");
|
---|
67 | unlink $temp;
|
---|
68 |
|
---|
69 | # Solaris specific: Rename our modified .xorg.conf to xorg.conf for it to be used
|
---|
70 | if (($os_type =~ 'SunOS') && ($cfg =~ '/etc/X11/.xorg.conf'))
|
---|
71 | {
|
---|
72 | system("mv -f $cfg /etc/X11/xorg.conf");
|
---|
73 | }
|
---|
74 |
|
---|
75 | $config_count++;
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 | $config_count != 0 or die "Could not find any X11 configuration files";
|
---|