diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions')
-rw-r--r-- | nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix | 41 | ||||
-rw-r--r-- | nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/kernel-5.3-fix.patch | 50 |
2 files changed, 77 insertions, 14 deletions
diff --git a/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix index ad860b07bdf..af247af0051 100644 --- a/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix +++ b/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix @@ -1,9 +1,9 @@ { stdenv, fetchurl, lib, patchelf, cdrkit, kernel, which, makeWrapper -, zlib, xorg, dbus, virtualbox }: +, zlib, xorg, dbus, virtualbox, dos2unix }: let version = virtualbox.version; - xserverVListFunc = builtins.elemAt (stdenv.lib.splitString "." xorg.xorgserver.version); + xserverVListFunc = builtins.elemAt (stdenv.lib.splitVersion xorg.xorgserver.version); # Forced to 1.18 in <nixpkgs/nixos/modules/services/x11/xserver.nix> # as it even fails to build otherwise. Still, override this even here, @@ -12,22 +12,26 @@ let # It's likely to work again in some future update. xserverABI = let abi = xserverVListFunc 0 + xserverVListFunc 1; in if abi == "119" || abi == "120" then "118" else abi; -in -stdenv.mkDerivation { + # Specifies how to patch binaries to make sure that libraries loaded using + # dlopen are found. We grep binaries for specific library names and patch + # RUNPATH in matching binaries to contain the needed library paths. + dlopenLibs = [ + { name = "libdbus-1.so"; pkg = dbus; } + { name = "libXfixes.so"; pkg = xorg.libXfixes; } + ]; + +in stdenv.mkDerivation { name = "VirtualBox-GuestAdditions-${version}-${kernel.version}"; src = fetchurl { url = "http://download.virtualbox.org/virtualbox/${version}/VBoxGuestAdditions_${version}.iso"; - sha256 = "098kibz8dkiqd8shm44n4h6iyszcbj0ikav1b4vsi75dqzw8d9n8"; + sha256 = "0hflsbx70dli34mpx94vd33p55ycfs3ahzwcdzqxdiwiiskjpykq"; }; KERN_DIR = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"; KERN_INCL = "${kernel.dev}/lib/modules/${kernel.modDirVersion}/source/include"; - # If you add a patch you probably need this. - #patchFlags = [ "-p1" "-d" "install/src/vboxguest-${version}" ]; - hardeningDisable = [ "pic" ]; NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration"; @@ -35,15 +39,24 @@ stdenv.mkDerivation { nativeBuildInputs = [ patchelf makeWrapper ]; buildInputs = [ cdrkit ] ++ kernel.moduleBuildDependencies; - postPatch = '' + + prePatch = '' substituteInPlace src/vboxguest-${version}/vboxvideo/vbox_ttm.c \ --replace "<ttm/" "<drm/ttm/" + ${dos2unix}/bin/dos2unix src/vboxguest-${version}/vboxguest/r0drv/linux/mp-r0drv-linux.c ''; + patchFlags = [ "-p1" "-d" "src/vboxguest-${version}" ]; + # Kernel 5.3 fix, should be fixed with VirtualBox 6.0.14 + # https://www.virtualbox.org/ticket/18911 + patches = [ ./kernel-5.3-fix.patch ]; + unpackPhase = '' ${if stdenv.hostPlatform.system == "i686-linux" || stdenv.hostPlatform.system == "x86_64-linux" then '' isoinfo -J -i $src -x /VBoxLinuxAdditions.run > ./VBoxLinuxAdditions.run chmod 755 ./VBoxLinuxAdditions.run + # An overflow leads the is-there-enough-space check to fail when there's too much space available, so fake how much space there is + sed -i 's/\$leftspace/16383/' VBoxLinuxAdditions.run ./VBoxLinuxAdditions.run --noexec --keep '' else throw ("Architecture: "+stdenv.hostPlatform.system+" not supported for VirtualBox guest additions") @@ -134,13 +147,13 @@ stdenv.mkDerivation { # Stripping breaks these binaries for some reason. dontStrip = true; - # Some code dlopen() libdbus, patch RUNPATH in fixupPhase so it isn't stripped. - postFixup = '' - for i in $(grep -F libdbus-1.so -l -r $out/{lib,bin}); do + # Patch RUNPATH according to dlopenLibs (see the comment there). + postFixup = lib.concatMapStrings (library: '' + for i in $(grep -F ${lib.escapeShellArg library.name} -l -r $out/{lib,bin}); do origRpath=$(patchelf --print-rpath "$i") - patchelf --set-rpath "$origRpath:${lib.makeLibraryPath [ dbus ]}" "$i" + patchelf --set-rpath "$origRpath:${lib.makeLibraryPath [ library.pkg ]}" "$i" done - ''; + '') dlopenLibs; meta = { description = "Guest additions for VirtualBox"; diff --git a/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/kernel-5.3-fix.patch b/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/kernel-5.3-fix.patch new file mode 100644 index 00000000000..0bdd9ec1056 --- /dev/null +++ b/nixpkgs/pkgs/applications/virtualization/virtualbox/guest-additions/kernel-5.3-fix.patch @@ -0,0 +1,50 @@ +--- a/vboxguest/r0drv/linux/mp-r0drv-linux.c ++++ a/vboxguest/r0drv/linux/mp-r0drv-linux.c +@@ -283,12 +283,15 @@ + if (RTCpuSetCount(&OnlineSet) > 1) + { + /* Fire the function on all other CPUs without waiting for completion. */ +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) ++ smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); ++# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) + int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* wait */); ++ Assert(!rc); NOREF(rc); + # else + int rc = smp_call_function(rtmpLinuxAllWrapper, &Args, 0 /* retry */, 0 /* wait */); +-# endif + Assert(!rc); NOREF(rc); ++# endif + } + #endif + +@@ -326,7 +329,6 @@ + { + #ifdef CONFIG_SMP + IPRT_LINUX_SAVE_EFL_AC(); +- int rc; + RTMPARGS Args; + + RTTHREADPREEMPTSTATE PreemptState = RTTHREADPREEMPTSTATE_INITIALIZER; +@@ -337,14 +339,17 @@ + Args.cHits = 0; + + RTThreadPreemptDisable(&PreemptState); +-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) +- rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); ++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 3, 0) ++ smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); ++# elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) ++ int rc = smp_call_function(rtmpLinuxWrapper, &Args, 1 /* wait */); ++ Assert(rc == 0); NOREF(rc); + # else /* older kernels */ +- rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); ++ int rc = smp_call_function(rtmpLinuxWrapper, &Args, 0 /* retry */, 1 /* wait */); ++ Assert(rc == 0); NOREF(rc); + # endif /* older kernels */ + RTThreadPreemptRestore(&PreemptState); + +- Assert(rc == 0); NOREF(rc); + IPRT_LINUX_RESTORE_EFL_AC(); + #else + RT_NOREF(pfnWorker, pvUser1, pvUser2); |