VirtualBox

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

Last change on this file since 91999 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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