diff options
Diffstat (limited to 'pkgs/applications/virtualization/virtualbox')
5 files changed, 158 insertions, 58 deletions
diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix index 8bcf122132e3..14a87151e97e 100644 --- a/pkgs/applications/virtualization/virtualbox/default.nix +++ b/pkgs/applications/virtualization/virtualbox/default.nix @@ -1,52 +1,29 @@ { stdenv, fetchurl, lib, iasl, dev86, pam, libxslt, libxml2, libX11, xproto, libXext -, libXcursor, libXmu, qt4, libIDL, SDL, libcap, zlib, libpng, glib, kernel, lvm2 -, libXrandr +, libXcursor, libXmu, qt5, libIDL, SDL, libcap, zlib, libpng, glib, lvm2 +, libXrandr, libXinerama , which, alsaLib, curl, libvpx, gawk, nettools, dbus -, xorriso, makeself, perl, pkgconfig, nukeReferences +, xorriso, makeself, perl, pkgconfig , javaBindings ? false, jdk ? null -, pythonBindings ? false, python ? null +, pythonBindings ? false, python2 ? null , enableExtensionPack ? false, requireFile ? null, patchelf ? null, fakeroot ? null , pulseSupport ? false, libpulseaudio ? null , enableHardening ? false , headless ? false +, patchelfUnstable # needed until 0.10 is released }: with stdenv.lib; let + python = python2; buildType = "release"; - # When changing this, update ./guest-additions and the extpack - # revision/hash as well. See - # http://download.virtualbox.org/virtualbox/${version}/SHA256SUMS - # for hashes. - version = "5.0.26"; - - forEachModule = action: '' - for mod in \ - out/linux.*/${buildType}/bin/src/vboxdrv \ - out/linux.*/${buildType}/bin/src/vboxpci \ - out/linux.*/${buildType}/bin/src/vboxnetadp \ - out/linux.*/${buildType}/bin/src/vboxnetflt - do - if [ "x$(basename "$mod")" != xvboxdrv -a ! -e "$mod/Module.symvers" ] - then - cp -v out/linux.*/${buildType}/bin/src/vboxdrv/Module.symvers \ - "$mod/Module.symvers" - fi - INSTALL_MOD_PATH="$out" INSTALL_MOD_DIR=misc \ - make -j $NIX_BUILD_CORES -C "$MODULES_BUILD_DIR" DEPMOD=/do_not_use_depmod \ - "M=\$(PWD)/$mod" BUILD_TYPE="${buildType}" ${action} - done - ''; + inherit (importJSON ./upstream-info.json) version extpackRev extpack main; # See https://github.com/NixOS/nixpkgs/issues/672 for details - extpackRevision = "108824"; extensionPack = requireFile rec { - name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${extpackRevision}.vbox-extpack"; - # IMPORTANT: Hash must be base16 encoded because it's used as an input to - # VBoxExtPackHelperApp! - sha256 = "2f2302c7ba3d00a1258fe8e7767a6eb08dccdc3c31f6e3eeb74063c2c268b104"; + name = "Oracle_VM_VirtualBox_Extension_Pack-${version}-${extpackRev}.vbox-extpack"; + sha256 = extpack; message = '' In order to use the extension pack, you need to comply with the VirtualBox Personal Use and Evaluation License (PUEL) available at: @@ -61,35 +38,36 @@ let }; in stdenv.mkDerivation { - name = "virtualbox-${version}-${kernel.version}"; + name = "virtualbox-${version}"; src = fetchurl { url = "http://download.virtualbox.org/virtualbox/${version}/VirtualBox-${version}.tar.bz2"; - sha256 = "78dec1369d2c8feefea3c682d95e76c0e99414c56626388035cf4061d4dad62e"; + sha256 = main; }; + outputs = [ "out" "modsrc" ]; + buildInputs = [ iasl dev86 libxslt libxml2 xproto libX11 libXext libXcursor libIDL - libcap glib lvm2 python alsaLib curl libvpx pam xorriso makeself perl - pkgconfig which libXmu nukeReferences ] + libcap glib lvm2 alsaLib curl libvpx pam xorriso makeself perl + pkgconfig which libXmu libpng patchelfUnstable python ] ++ optional javaBindings jdk - ++ optional pythonBindings python + ++ optional pythonBindings python # Python is needed even when not building bindings ++ optional pulseSupport libpulseaudio - ++ optionals (headless) [ libXrandr libpng ] - ++ optionals (!headless) [ qt4 SDL ]; + ++ optionals (headless) [ libXrandr ] + ++ optionals (!headless) [ qt5.qtbase qt5.qtx11extras libXinerama SDL ]; hardeningDisable = [ "fortify" "pic" "stackprotector" ]; prePatch = '' set -x - MODULES_BUILD_DIR=`echo ${kernel.dev}/lib/modules/*/build` - sed -e 's@/lib/modules/`uname -r`/build@'$MODULES_BUILD_DIR@ \ - -e 's@MKISOFS --version@MKISOFS -version@' \ + sed -e 's@MKISOFS --version@MKISOFS -version@' \ -e 's@PYTHONDIR=.*@PYTHONDIR=${if pythonBindings then python else ""}@' \ - -i configure + ${optionalString (!headless) '' + -e 's@TOOLQT5BIN=.*@TOOLQT5BIN="${getDev qt5.qtbase}/bin"@' \ + ''} -i configure ls kBuild/bin/linux.x86/k* tools/linux.x86/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux.so.2 ls kBuild/bin/linux.amd64/k* tools/linux.amd64/bin/* | xargs -n 1 patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux-x86-64.so.2 - find . -type f -iname '*makefile*' -exec sed -i -e 's/depmod -a/:/g' {} + sed -i -e ' s@"libdbus-1\.so\.3"@"${dbus.lib}/lib/libdbus-1.so.3"@g s@"libasound\.so\.2"@"${alsaLib.out}/lib/libasound.so.2"@g @@ -103,11 +81,12 @@ in stdenv.mkDerivation { set +x ''; - patches = optional enableHardening ./hardened.patch; + patches = optional enableHardening ./hardened.patch + ++ [ ./qtx11extras.patch ]; postPatch = '' sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \ - src/apps/adpctl/VBoxNetAdpCtl.cpp + src/VBox/HostDrivers/adpctl/VBoxNetAdpCtl.cpp ''; # first line: ugly hack, and it isn't yet clear why it's a problem @@ -131,11 +110,15 @@ in stdenv.mkDerivation { ${optionalString javaBindings '' VBOX_JAVA_HOME := ${jdk} ''} + ${optionalString (!headless) '' + PATH_QT5_X11_EXTRAS_LIB := ${getLib qt5.qtx11extras}/lib + PATH_QT5_X11_EXTRAS_INC := ${getDev qt5.qtx11extras}/include + TOOL_QT5_LRC := ${getDev qt5.qttools}/bin/lrelease + ''} LOCAL_CONFIG ./configure \ ${optionalString headless "--build-headless"} \ - ${optionalString (!headless) "--with-qt4-dir=${qt4}"} \ ${optionalString (!javaBindings) "--disable-java"} \ ${optionalString (!pythonBindings) "--disable-python"} \ ${optionalString (!pulseSupport) "--disable-pulse"} \ @@ -153,7 +136,6 @@ in stdenv.mkDerivation { buildPhase = '' source env.sh kmk -j $NIX_BUILD_CORES BUILD_TYPE="${buildType}" - ${forEachModule "modules"} ''; installPhase = '' @@ -165,9 +147,6 @@ in stdenv.mkDerivation { find out/linux.*/${buildType}/bin -mindepth 1 -maxdepth 1 \ -name src -o -exec cp -avt "$libexec" {} + - # Install kernel modules - ${forEachModule "modules_install"} - # Create wrapper script mkdir -p $out/bin for file in VirtualBox VBoxManage VBoxSDL VBoxBalloonCtrl VBoxBFE VBoxHeadless; do @@ -199,15 +178,11 @@ in stdenv.mkDerivation { done ''} - # Get rid of a reference to linux.dev. - nuke-refs $out/lib/modules/*/misc/*.ko + cp -rv out/linux.*/${buildType}/bin/src "$modsrc" ''; passthru = { inherit version; /* for guest additions */ }; - # Workaround for https://github.com/NixOS/patchelf/issues/93 (can be removed once this issue is addressed) - dontPatchELF = true; - meta = { description = "PC emulator"; homepage = http://www.virtualbox.org/; diff --git a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix index 56e025197925..5a97d2a8efd0 100644 --- a/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix +++ b/pkgs/applications/virtualization/virtualbox/guest-additions/default.nix @@ -12,19 +12,20 @@ stdenv.mkDerivation { src = fetchurl { url = "http://download.virtualbox.org/virtualbox/${version}/VBoxGuestAdditions_${version}.iso"; - sha256 = "7458ee5a7121a7d243fd6a7528ba427945d9120c5efc7cd75b3951fb01f09c59"; + sha256 = (lib.importJSON ../upstream-info.json).guest; }; KERN_DIR = "${kernel.dev}/lib/modules/*/build"; hardeningDisable = [ "pic" ]; + NIX_CFLAGS_COMPILE = "-Wno-error=incompatible-pointer-types"; + buildInputs = [ patchelf cdrkit makeWrapper dbus ]; installPhase = '' mkdir -p $out cp -r install/* $out - ''; buildCommand = with xorg; '' diff --git a/pkgs/applications/virtualization/virtualbox/qtx11extras.patch b/pkgs/applications/virtualization/virtualbox/qtx11extras.patch new file mode 100644 index 000000000000..f5decc211c75 --- /dev/null +++ b/pkgs/applications/virtualization/virtualbox/qtx11extras.patch @@ -0,0 +1,31 @@ +diff --git a/kBuild/units/qt5.kmk b/kBuild/units/qt5.kmk +index 71b96a3..73391f0 100644 +--- a/kBuild/units/qt5.kmk ++++ b/kBuild/units/qt5.kmk +@@ -994,9 +994,10 @@ else + $(eval $(target)_LIBS += $(PATH_SDK_QT5_LIB)/$(qt_prefix)qtmain$(qt_infix)$(SUFF_LIB) ) + endif + else +- $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) ) ++ $(eval $(target)_LIBS += $(foreach module,$(qt_modules), $(PATH_SDK_QT5_LIB)/lib$(qt_prefix)Qt5$(module)$(qt_infix)$(SUFF_DLL)) \ ++ $(PATH_QT5_X11_EXTRAS_LIB)/lib$(qt_prefix)Qt5X11Extras$(qt_infix)$(SUFF_DLL)) + endif +- $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) ) ++ $(eval $(target)_INCS += $(addprefix $(PATH_SDK_QT5_INC)/Qt,$(qt_modules)) $(PATH_SDK_QT5_INC) $(PATH_QT5_X11_EXTRAS_INC)/QtX11Extras ) + endif + $(eval $(target)_DEFS += $(foreach module,$(toupper $(qt_modules)), QT_$(module)_LIB) ) + +diff --git a/src/VBox/Frontends/VirtualBox/Makefile.kmk b/src/VBox/Frontends/VirtualBox/Makefile.kmk +index 38db6b0..7dd446b 100644 +--- a/src/VBox/Frontends/VirtualBox/Makefile.kmk ++++ b/src/VBox/Frontends/VirtualBox/Makefile.kmk +@@ -912,9 +912,6 @@ VirtualBox_QT_MODULES = Core Gui + ifdef VBOX_WITH_QTGUI_V5 + # Qt5 requires additional modules: + VirtualBox_QT_MODULES += Widgets PrintSupport +- VirtualBox_QT_MODULES.linux += X11Extras +- VirtualBox_QT_MODULES.solaris += X11Extras +- VirtualBox_QT_MODULES.freebsd += X11Extras + VirtualBox_QT_MODULES.darwin += MacExtras + VirtualBox_QT_MODULES.win += WinExtras + endif # VBOX_WITH_QTGUI_V5 diff --git a/pkgs/applications/virtualization/virtualbox/update.py b/pkgs/applications/virtualization/virtualbox/update.py new file mode 100755 index 000000000000..6e8bfd5c8250 --- /dev/null +++ b/pkgs/applications/virtualization/virtualbox/update.py @@ -0,0 +1,85 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i python3 -p python3 + +import os +import re +import json +import urllib.request + +from distutils.version import LooseVersion + +UPSTREAM_INFO_FILE = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "upstream-info.json" +) + + +def fetch_latest_version(): + url = "http://download.virtualbox.org/virtualbox/LATEST.TXT" + return urllib.request.urlopen(url).read().strip().decode() + + +def load_upstream_info(): + try: + with open(UPSTREAM_INFO_FILE, 'r') as fp: + return json.load(fp) + except FileNotFoundError: + return {'version': "0"} + + +def save_upstream_info(contents): + remark = "Generated using update.py from the same directory." + contents['__NOTE'] = remark + data = json.dumps(contents, indent=2, sort_keys=True) + with open(UPSTREAM_INFO_FILE, 'w') as fp: + fp.write(data + "\n") + + +def fetch_file_table(version): + url = "http://download.virtualbox.org/virtualbox/{}/SHA256SUMS" + url = url.format(version) + result = {} + for line in urllib.request.urlopen(url): + sha, name = line.rstrip().split() + result[name.lstrip(b'*').decode()] = sha.decode() + return result + + +def update_to_version(version): + extpack_start = 'Oracle_VM_VirtualBox_Extension_Pack-' + version_re = version.replace('.', '\\.') + attribute_map = { + 'extpack': r'^' + extpack_start + r'[^-]+-[^.]+.vbox-extpack$', + 'extpackRev': r'^' + extpack_start + r'[^-]+-([^.]+).vbox-extpack$', + 'main': r'^VirtualBox-' + version_re + r'.tar.bz2$', + 'guest': r'^VBoxGuestAdditions_' + version_re + r'.iso$', + } + table = fetch_file_table(version) + new_attrs = {'version': version} + for attr, searchexpr in attribute_map.items(): + result = [re.search(searchexpr, key) for key in table.keys()] + filtered = filter(lambda m: m is not None, result) + found = [m.groups()[0] if len(m.groups()) > 0 else table[m.group(0)] + for m in filtered if m is not None] + + if len(found) == 0: + msg = "No package found for attribute {}".format(attr) + raise AssertionError(msg) + elif len(found) != 1: + msg = "More than one package found for attribute {}: ".format(attr) + msg += ', '.join(found) + raise AssertionError(msg) + else: + new_attrs[attr] = found[0] + return new_attrs + + +info = load_upstream_info() +latest = fetch_latest_version() +if LooseVersion(info['version']) < LooseVersion(latest): + print("Updating to version {}...".format(latest), end="", flush=True) + new_attrs = update_to_version(latest) + save_upstream_info(new_attrs) + print(" done.") +else: + print("Version {} is already the latest one.".format(info['version'])) diff --git a/pkgs/applications/virtualization/virtualbox/upstream-info.json b/pkgs/applications/virtualization/virtualbox/upstream-info.json new file mode 100644 index 000000000000..1b85d2b8847e --- /dev/null +++ b/pkgs/applications/virtualization/virtualbox/upstream-info.json @@ -0,0 +1,8 @@ +{ + "__NOTE": "Generated using update.py from the same directory.", + "extpack": "3982657fd4853bcbc79b9162e618545a479b65aca08e9ced43a904aeeba3ffa5", + "extpackRev": "112026", + "guest": "29fa0af66a3dd273b0c383c4adee31a52061d52f57d176b67f444698300b8c41", + "main": "98073b1b2adee4e6553df73cb5bb6ea8ed7c3a41a475757716fd9400393bea40", + "version": "5.1.10" +} |