diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 14:19:18 +0000 |
commit | 4035b1bfb1e5843a539a8b624d21952b756974d1 (patch) | |
tree | f1e9cd5bf548cbc57ff2fddfb2b4aa9ae95587e2 /src/VBox/Additions/x11/Installer/x11config15.pl | |
parent | Initial commit. (diff) | |
download | virtualbox-4035b1bfb1e5843a539a8b624d21952b756974d1.tar.xz virtualbox-4035b1bfb1e5843a539a8b624d21952b756974d1.zip |
Adding upstream version 6.1.22-dfsg.upstream/6.1.22-dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Additions/x11/Installer/x11config15.pl')
-rwxr-xr-x | src/VBox/Additions/x11/Installer/x11config15.pl | 87 |
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..60de3d3e --- /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-2020 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; + } +} |