1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
#!/usr/bin/perl -w
# $Id: x11config15.pl $
## @file
# Guest Additions X11 config update script for X.org 1.5
#
#
# Copyright (C) 2006-2019 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
# What this script does: X.org 1.5 introduces full hardware autodetection
# and no longer requires the user to provide an X.org configuration file.
# However, if such a file is provided, it will override autodetection of
# the graphics card (not of vboxmouse as far as I can see). Although this
# would normally be the user's business, at least Fedora 9 still generates
# a configuration file by default, so we have to rewrite it if we want
# the additions to work on a default guest installation. So we simply go
# through any configuration files we may find on the system and replace
# references to VESA or framebuffer drivers (which might be autodetected
# for use on a VirtualBox guest) and replace them with vboxvideo.
use File::Copy;
my $temp="/tmp/xorg.conf";
# The list of possible names of X.org configuration files
my @cfg_files = ("/etc/X11/xorg.conf-4", "/etc/X11/xorg.conf", "/etc/X11/.xorg.conf", "/etc/xorg.conf",
"/usr/etc/X11/xorg.conf-4", "/usr/etc/X11/xorg.conf", "/usr/lib/X11/xorg.conf-4",
"/usr/lib/X11/xorg.conf");
my $CFG;
my $TMP;
# Subroutine to roll back after a partial installation
sub do_fail {
foreach $cfg (@cfg_files) {
move $cfg.".vbox", $cfg;
unlink $cfg.".vbox";
}
die $1;
}
# Perform the substitution on any configuration file we may find.
foreach $cfg (@cfg_files) {
if (open(CFG, $cfg)) {
open(TMP, ">$temp")
or &do_fail("Can't create $TMP: $!\n");
while (defined ($line = <CFG>)) {
if ($line =~ /^\s*Section\s*"([a-zA-Z]+)"/i) {
my $section = lc($1);
if ($section eq "device") {
$in_section = 1;
}
} else {
if ($line =~ /^\s*EndSection/i) {
$in_section = 0;
}
}
if ($in_section) {
if ($line =~ /^\s*driver\s+\"(fbdev|vga|vesa|vboxvideo|ChangeMe)\"/i) {
$line =~ s/(fbdev|vga|vesa|vboxvideo|ChangeMe)/vboxvideo/i;
}
}
print TMP $line;
}
close(TMP);
# We do not overwrite existing $cfg.".vbox" files because that will
# likely ruin any future attempts to uninstall the additions
copy $cfg, $cfg.".bak";
if (! -e $cfg.".vbox") {
rename $cfg, $cfg.".vbox";
}
copy $temp, $cfg
or &do_fail("Could not overwrite configuration file $cfg! Exiting...");
unlink $temp;
}
}
|