summaryrefslogtreecommitdiffstats
path: root/src/VBox/Additions/x11/Installer/x11config15.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 03:01:46 +0000
commitf8fe689a81f906d1b91bb3220acde2a4ecb14c5b (patch)
tree26484e9d7e2c67806c2d1760196ff01aaa858e8c /src/VBox/Additions/x11/Installer/x11config15.pl
parentInitial commit. (diff)
downloadvirtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.tar.xz
virtualbox-f8fe689a81f906d1b91bb3220acde2a4ecb14c5b.zip
Adding upstream version 6.0.4-dfsg.upstream/6.0.4-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Additions/x11/Installer/x11config15.pl')
-rwxr-xr-xsrc/VBox/Additions/x11/Installer/x11config15.pl87
1 files changed, 87 insertions, 0 deletions
diff --git a/src/VBox/Additions/x11/Installer/x11config15.pl b/src/VBox/Additions/x11/Installer/x11config15.pl
new file mode 100755
index 00000000..92dd8dde
--- /dev/null
+++ b/src/VBox/Additions/x11/Installer/x11config15.pl
@@ -0,0 +1,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;
+ }
+}