VirtualBox

source: vbox/trunk/src/VBox/Additions/x11/Installer/x11config15.pl@ 28063

Last change on this file since 28063 was 18265, checked in by vboxsync, 16 years ago

config file cleanup + small copyright year update

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette