Package Details: virtualbox-kvm 20240828-1

Git Clone URL: https://aur.archlinux.org/virtualbox-kvm.git (read-only, click to copy)
Package Base: virtualbox-kvm
Description: Powerful x86 virtualization for enterprise as well as home use (KVM backend)
Upstream URL: https://github.com/cyberus-technology/virtualbox-kvm
Licenses: GPL, custom:CDDL
Conflicts: virtualbox, virtualbox-ose
Replaces: virtualbox-ose
Submitter: xyzzy
Maintainer: xyzzy (knoelli)
Last Packager: knoelli
Votes: 10
Popularity: 1.03
First Submitted: 2024-02-08 19:08 (UTC)
Last Updated: 2024-08-29 20:32 (UTC)

Latest Comments

1 2 3 Next › Last »

gbc921 commented on 2024-07-23 13:06 (UTC)

Regarding my last comment here, it is my bad as I was not aware that this is not supported upstream

Thanks.

gbc921 commented on 2024-07-22 20:42 (UTC) (edited on 2024-07-22 20:44 (UTC) by gbc921)

Hi all! Great package here.

I was wondering though, if anyone else is finding problems when managing the network attachment for the VMs (or under Tools -> Network too):

  • Under each VM, selecting Bridge network, does not provide the Host network adapter list.
  • And under Tools -> Network, it gives the error of VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: Permission denied.

I have checked Load the VirtualBox kernel modules wiki already:

  • recompiling this package with makedepends on linux-lts-headers
  • reinstalling virtualbox-host-dkms (as I am using linux-lts)
  • the device vboxnetctl exists
  • my user is under the group vboxusers

Using vboxmanage cli gives similar error as well.

Do you have the same problem? Thanks.

knoelli commented on 2024-05-20 20:21 (UTC)

@xyzzy Thank you for updating the package. I would be happy to co-maintain it and assist you in keeping it up-to-date with upstream development.

xyzzy commented on 2024-05-20 08:43 (UTC)

Thanks @knoelli, I just applied your suggestions (apart from changing linux-headers to linux-zen-headers). Would you be interested in co-maintaining this package?

knoelli commented on 2024-05-17 18:32 (UTC) (edited on 2024-05-17 19:52 (UTC) by knoelli)

Updated PKGBUILD for build 20240515 with all modules enabled. Note that you'll also need to change file 019-libxml-2-12.patch and remove lines 39-47 (the one starting with @@ -1856,7 +1856,7 @@ static void xmlParserBaseGenericError until EOF). Changed some compiler errors to warnings (stringop-truncation) in order to be compatible with gcc 14.x.

# Maintainer: xyzzy

# Adapted from the official virtualbox package by
# Contributor: Christian Hesse <eworm@archlinux.org>
# Contributor: Sébastien "Seblu" Luttringer
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=virtualbox-kvm
pkgdesc='Powerful x86 virtualization for enterprise as well as home use (KVM backend)'
pkgver=20240515
_pkgver=dev-${pkgver}
_vboxver='7.0.18'
pkgrel=1
conflicts=('virtualbox' 'virtualbox-ose')
depends=('curl' 'gcc-libs' 'glibc' 'liblzf' 'libpng' 'libtpms' 'libvpx' 'libx11' 'libxcursor'
            'libxext' 'libxinerama' 'libxml2' 'libxmu' 'libxt' 'openssl' 'procps-ng' 'python'
            'qt5-base' 'qt5-tools' 'qt5-x11extras' 'sdl' 'shared-mime-info' 'zlib')
optdepends=('vde2: Virtual Distributed Ethernet support'
            'virtualbox-guest-iso: Guest Additions CD image'
            'virtualbox-ext-vnc: VNC server support'
            'virtualbox-sdk: Developer kit')
backup=('etc/vbox/vbox.cfg')
replaces=('virtualbox-ose')
arch=('x86_64')
url='https://github.com/cyberus-technology/virtualbox-kvm'
license=('GPL' 'custom:CDDL')

makedepends=('alsa-lib' 'cdrkit' 'curl' 'device-mapper' 'git' 'glu' 'gsoap' 'glslang' 'iasl'
                'jdk8-openjdk' 'libidl2' 'liblzf' 'libpulse' 'libtpms' 'libvncserver' 'libvpx'
                'libxcomposite' 'libxcursor' 'libxinerama' 'libxml2' 'libxmu' 'libxrandr' 'libxslt'
                'libxtst' 'linux-zen-headers' 'mesa' 'python' 'qt5-base' 'qt5-tools' 'qt5-x11extras'
                'sdl' 'sdl_ttf' 'vde2' 'xorgproto' 'xorg-server-devel' 'yasm')

source=("https://download.virtualbox.org/virtualbox/${_vboxver}/VirtualBox-${_vboxver}.tar.bz2"
        "${url}/releases/download/${_pkgver}/kvm-backend-${_vboxver}-${_pkgver}.patch"
        'virtualbox-host-dkms.conf'
        'virtualbox.sysusers'
        'virtualbox-guest-utils.sysusers'
        '60-vboxdrv.rules'
        '60-vboxguest.rules'
        'LocalConfig.kmk'
        'vboxservice.service'
        'vboxservice-nox.service'
        'vboxdrmclient.path'
        'vboxdrmclient.service'
        'vboxweb.service'
        'vboxreload'
        '001-disable-update.patch'
        '004-drop-Wno-format.patch'
        '008-no-vboxvideo.patch'
        '009-properly-handle-i3wm.patch'
        '012-vbglR3GuestCtrlDetectPeekGetCancelSupport.patch'
        '013-support-building-from-dkms.patch'
        '018-upate-xclient-script.patch'
        '019-libxml-2-12.patch')
sha256sums=('d999513533631674a024762668de999411d8197060c51e68c5faf0a2c0eea1a5'
            '4839daa07fb470f09b365aacef3ce22e84c6633470f067fb62f2163bfff5cf6a'
            '76d98ea062fcad9e5e3fa981d046a6eb12a3e718a296544a68b66f4b65cb56db'
            '2101ebb58233bbfadf3aa74381f22f7e7e508559d2b46387114bc2d8e308554c'
            'da4c49f6ca94e047e196cdbcba2c321199f4760056ea66e0fbc659353e128c9e'
            'f876e9f55243eded423fda4fc2ffe3b174dca90380a6315f7c9b3cd1c9d07206'
            '033c597e0f5285d2ddb0490868e5b6f945f45c7b1b1152a02a9e6fea438b2c95'
            '0ae014c6bb778a1b079121064f17179c27b8dde9479a37d34ce071fb3b084e25'
            'c41a801fe344a4471a7b61a4764d1d857c403e4fb96e2ba6bc89c77a35f2be7a'
            '01dbb921bd57a852919cc78be5b73580a564f28ebab2fe8d6c9b8301265cbfce'
            '83d8f24bff25bb925083cf39b3195236c6136105e62417712cc3f25b92e14b47'
            '2beab8de525220fa418c9873f9e0d657ddbad4ff9e4a46d7053e6cd9bc4ce95e'
            'e6e875ef186578b53106d7f6af48e426cdaf1b4e86834f01696b8ef1c685787f'
            '4001b5927348fe669a541e80526d4f9ea91b883805f102f7d571edbb482a9b9d'
            '9ee947c9b5ec5b25f52d3e72340fc3a57ca6e65a604e15b669ac582a3fb0dc1b'
            '7675f87d31ad3137f057dc3ee3d4a2c5b2cfe8cd362adba130ddbf7a65069516'
            '053bfeee8863f3ffdf2f0e3f9f0d77dc61dd32764700a97a7635fd8611e20491'
            'ad0d7af1e4c94f9efbc60827abea9e605398549b3673c40f697d042bb6bfe88a'
            '81900e13d36630488accd8c0bfd2ceb69563fb2c4f0f171caba1cca59d438024'
            '00f68b86d32a1fada900c2da8dad2ab4215106cd58004f049bded99727cda2ff'
            '87dddfd9047480e4c2b73367facf5dd3702148418c2efcd606af17c07da90fe0'
            '7e5f1e386032dbe1042101d44bf454fddce8f7cbacea686816283840572b4201')

prepare() {
    cd "VirtualBox-${_vboxver}"

    # apply patches from the source array
    local filename
    for filename in "${source[@]}"; do
        if [[ "${filename}" =~ \.patch$ ]]; then
            echo "Applying patch ${filename##*/}"
            patch -p1 -N -i "${srcdir}/${filename##*/}"
        fi
    done

    sed -i '/cstring/a #include <cstdint>' src/libs/dxvk-native-1.9.2a/src/util/util_bit.h

    echo 'Applying local config'
    cp "${srcdir}/LocalConfig.kmk" .

    echo 'Use our CFLAGS'
    echo "VBOX_GCC_OPT=$CXXFLAGS -Wno-error=stringop-truncation" >> LocalConfig.kmk
}

build() {
    cd "VirtualBox-${_vboxver}"

    echo 'Build virtualbox-kvm'
    ./configure \
        --with-kvm \
        --disable-hardening \
        --disable-docs \
        --disable-kmods \
        --disable-vmmraw \
        --enable-vde \
        --enable-vnc \
        --enable-webservice \
        --with-makeself=/usr/bin/echo
    # fake makeself binary to compile without nofatal
    # makeself is used by linux installer. we don't need it.
    source ./env.sh
    kmk

    echo 'Build VNC extension pack'
    kmk -C src/VBox/ExtPacks/VNC packing
}

package() {
    source "VirtualBox-${_vboxver}/env.sh"
    cd "VirtualBox-${_vboxver}/out/linux.${BUILD_PLATFORM_ARCH}/release/bin"

    # libraries (and non-PATH executables)
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox"
    install -m0755 *.so -t "${pkgdir}/usr/lib/virtualbox"
    install -m0644 *.r0 VBoxEFI*.fd -t "${pkgdir}/usr/lib/virtualbox"

    # binaries (in /usr/lib/virtualbox)
    install -m0755 \
        VirtualBoxVM \
        VBoxSDL \
        VBoxHeadless \
        VBoxNetAdpCtl \
        VBoxNetDHCP \
        VBoxNetNAT \
        VirtualBox \
        VBoxManage \
        VBoxSVC \
        VBoxExtPackHelperApp \
        VBoxXPCOMIPCD \
        VBoxTestOGL \
        VBoxBalloonCtrl \
        vbox-img \
        vboximg-mount \
        vboxwebsrv \
        webtest \
        -t "${pkgdir}/usr/lib/virtualbox"

    # binaries (in /usr/bin)
    install -d -m0755 "${pkgdir}/usr/bin"
    install -m0755 VBox.sh "${pkgdir}/usr/bin/VBox"
    for i in VirtualBox VirtualBoxVM VBoxManage VBoxSDL VBoxHeadless VBoxBugReport VBoxBalloonCtrl VBoxAutostart vboxwebsrv; do
        ln -sf VBox "${pkgdir}/usr/bin/${i}"
        ln -sf VBox "${pkgdir}/usr/bin/${i,,}"
    done
    for i in vbox-img vboximg-mount; do
        ln -s ../lib/virtualbox/"${i}" "${pkgdir}/usr/bin/${i}"
    done

    # components
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/components"
    install -m0755 components/* -t "${pkgdir}/usr/lib/virtualbox/components"

    # extension packs
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/ExtensionPacks"

    # languages
    install -d -m0755 "${pkgdir}/usr/share/virtualbox/nls"
    install -m0755 nls/*.qm -t "${pkgdir}/usr/share/virtualbox/nls"

    # scripts
    install -m0755 VBoxCreateUSBNode.sh VBoxSysInfo.sh -t "${pkgdir}/usr/share/virtualbox"

    # icons
    install -D -m0644 VBox.png "${pkgdir}/usr/share/pixmaps/VBox.png"
    pushd icons >/dev/null
    for i in *; do
        install -d "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
        cp "${i}/"* "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
    done
    popd >/dev/null

    # desktop
    install -D -m0644 virtualbox.desktop "${pkgdir}/usr/share/applications/virtualbox.desktop"
    install -D -m0644 virtualbox.xml "${pkgdir}/usr/share/mime/packages/virtualbox.xml"

    # configuration
    install -d -m0755 "${pkgdir}/etc/vbox"
    echo 'INSTALL_DIR=/usr/lib/virtualbox' > "${pkgdir}/etc/vbox/vbox.cfg"

    cd "${srcdir}"

    # license
    install -D -m0644 VirtualBox-${_vboxver}/COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m0644 VirtualBox-${_vboxver}/COPYING.CDDL "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.CDDL"

    # systemd
    install -D -m0644 60-vboxdrv.rules "${pkgdir}/usr/lib/udev/rules.d/60-vboxdrv.rules"
    install -D -m0644 vboxweb.service "${pkgdir}/usr/lib/systemd/system/vboxweb.service"
    install -D -m0644 virtualbox.sysusers "${pkgdir}/usr/lib/sysusers.d/virtualbox.conf"

    # module reloading shortcut (with a symlink with default helper)
    install -D -m0755 vboxreload "${pkgdir}/usr/bin"
    ln -s vboxreload "${pkgdir}/usr/bin/rcvboxdrv"
}

agapito commented on 2024-05-03 19:06 (UTC)

For personal use I have cleaned up the PKGBUILD by removing references to modules and removing things I have no use for such as VNC, VDE, Webserver or Java. You may want to try it. Version: 20240502 / Virtualbox 7.0.18.

# Maintainer: xyzzy

# Adapted from the official virtualbox package by
# Contributor: Christian Hesse <eworm@archlinux.org>
# Contributor: Sébastien "Seblu" Luttringer
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=virtualbox-kvm
pkgdesc='Powerful x86 virtualization for enterprise as well as home use (KVM backend)'
pkgver=20240502
_pkgver=dev-${pkgver}
pkgrel=1
_vboxver='7.0.18'
conflicts=('virtualbox' 'virtualbox-ose')
depends=('curl' 'gcc-libs' 'glibc' 'liblzf' 'libpng' 'libtpms' 'libvpx' 'libx11' 'libxcursor'
            'libxext' 'libxinerama' 'libxml2' 'libxmu' 'libxt' 'openssl' 'procps-ng' 'python'
            'qt5-base' 'qt5-tools' 'qt5-x11extras' 'sdl' 'shared-mime-info' 'zlib')
optdepends=('virtualbox-guest-iso: Guest Additions CD image'
            'virtualbox-ext-oracle: Oracle VM VirtualBox Extension Pack')
backup=('etc/vbox/vbox.cfg')
replaces=('virtualbox-ose')
arch=('x86_64')
url='https://github.com/cyberus-technology/virtualbox-kvm'
vboxurl='https://download.virtualbox.org/virtualbox/'
license=('GPL' 'custom:CDDL')

makedepends=('alsa-lib'
             'curl'
             'device-mapper'
             'git'
             'glu'
             'glslang'
             'iasl'
             'libidl2'
             'liblzf'
             'libpulse'
             'libtpms'
             'libvpx'
             'libxcomposite'
             'libxcursor'
             'libxinerama'
             'libxml2'
             'libxmu'
             'libxrandr'
             'libxslt'
             'libxtst'
             'mesa'
             'python'
             'qt5-base'
             'qt5-tools'
             'qt5-x11extras'
             'sdl'
             'sdl_ttf'
             'xorgproto'
             'yasm')

source=("${vboxurl}${_vboxver}/VirtualBox-${_vboxver}.tar.bz2"
    "${url}/releases/download/${_pkgver}/kvm-backend-7.0.14-${_pkgver}.patch"
        'virtualbox.sysusers'
        'LocalConfig.kmk'
        '001-disable-update.patch'
        '004-drop-Wno-format.patch'
        '008-no-vboxvideo.patch')
sha256sums=('d999513533631674a024762668de999411d8197060c51e68c5faf0a2c0eea1a5'
            '9e9d1d9c4f02414686dc7dabeb8a757bde000ea0e0a445c151742734b882e056'
            '2101ebb58233bbfadf3aa74381f22f7e7e508559d2b46387114bc2d8e308554c'
            '0ae014c6bb778a1b079121064f17179c27b8dde9479a37d34ce071fb3b084e25'
            '9ee947c9b5ec5b25f52d3e72340fc3a57ca6e65a604e15b669ac582a3fb0dc1b'
            '7675f87d31ad3137f057dc3ee3d4a2c5b2cfe8cd362adba130ddbf7a65069516'
            '053bfeee8863f3ffdf2f0e3f9f0d77dc61dd32764700a97a7635fd8611e20491')

prepare() {
    cd "VirtualBox-${_vboxver}"

    # apply patches from the source array
    local filename
    for filename in "${source[@]}"; do
        if [[ "${filename}" =~ \.patch$ ]]; then
            echo "Applying patch ${filename##*/}"
            patch -p1 -N -i "${srcdir}/${filename##*/}"
        fi
    done

    sed -i '/cstring/a #include <cstdint>' src/libs/dxvk-native-1.9.2a/src/util/util_bit.h

    echo 'Applying local config'
    cp "${srcdir}/LocalConfig.kmk" .

    echo 'Use our CFLAGS'
    echo "VBOX_GCC_OPT=$CXXFLAGS" >> LocalConfig.kmk
}

build() {
    cd "VirtualBox-${_vboxver}"

    echo 'Build virtualbox-kvm'
    ./configure \
        --with-kvm \
        --disable-hardening \
        --disable-docs \
        --disable-kmods \
        --disable-java\
        --disable-vmmraw \
        --with-makeself=/usr/bin/echo
    # fake makeself binary to compile without nofatal
    # makeself is used by linux installer. we don't need it.
    source ./env.sh
    kmk
}

package() {
    source "VirtualBox-${_vboxver}/env.sh"
    cd "VirtualBox-${_vboxver}/out/linux.${BUILD_PLATFORM_ARCH}/release/bin"

    # libraries (and non-PATH executables)
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox"
    install -m0755 *.so -t "${pkgdir}/usr/lib/virtualbox"
    install -m0644 *.r0 VBoxEFI*.fd -t "${pkgdir}/usr/lib/virtualbox"

    ## binaries
    install -m0755 \
        VirtualBoxVM \
        VBoxSDL \
        VBoxHeadless \
        VBoxNetAdpCtl \
        VBoxNetDHCP \
        VBoxNetNAT \
        VirtualBox \
        VBoxManage \
        VBoxSVC \
        VBoxExtPackHelperApp \
        VBoxXPCOMIPCD \
        VBoxTestOGL \
        VBoxBalloonCtrl \
        vbox-img \
        vboximg-mount \
        -t "${pkgdir}/usr/lib/virtualbox"

    # binaries (in /usr/bin)
    install -d -m0755 "${pkgdir}/usr/bin"
    install -m0755 VBox.sh "${pkgdir}/usr/bin/VBox"
    for i in VirtualBox VirtualBoxVM VBoxManage VBoxSDL VBoxHeadless VBoxBalloonCtrl VBoxAutostart; do
        ln -sf VBox "${pkgdir}/usr/bin/${i}"
        ln -sf VBox "${pkgdir}/usr/bin/${i,,}"
    done
    for i in vbox-img vboximg-mount; do
        ln -s ../lib/virtualbox/"${i}" "${pkgdir}/usr/bin/${i}"
    done

    # components
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/components"
    install -m0755 components/* -t "${pkgdir}/usr/lib/virtualbox/components"

    # extensions packs
    ## as virtualbox install itself stuff in this directory, move it to /var and
    ## trick it with a symlink
    ## FIXME: trick is disabled for now
    #install -d -m0755 "${pkgdir}/var/lib/virtualbox/extensions"
    #install -d -m0755 "${pkgdir}/usr/share/virtualbox/extensions"
    #ln -s ../../../var/lib/virtualbox/extensions "${pkgdir}/usr/lib/virtualbox/ExtensionPacks"
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/ExtensionPacks"

    # languages
    install -d -m0755 "${pkgdir}/usr/share/virtualbox/nls"
    install -m0755 nls/*.qm -t "${pkgdir}/usr/share/virtualbox/nls"

    # useless scripts
    install -m0755 VBoxCreateUSBNode.sh VBoxSysInfo.sh -t "${pkgdir}/usr/share/virtualbox"

    # icons
    install -D -m0644 VBox.png "${pkgdir}/usr/share/pixmaps/VBox.png"

    pushd icons >/dev/null
    for i in *; do
        install -d "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
        cp "${i}/"* "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
    done
    popd >/dev/null

    #desktop
    install -D -m0644 virtualbox.desktop "${pkgdir}/usr/share/applications/virtualbox.desktop"
    install -D -m0644 virtualbox.xml "${pkgdir}/usr/share/mime/packages/virtualbox.xml"

    #install configuration
    install -d -m0755 "${pkgdir}/etc/vbox"
    echo 'INSTALL_DIR=/usr/lib/virtualbox' > "${pkgdir}/etc/vbox/vbox.cfg"

    # back to srcdir
    cd "${srcdir}"

# license
    install -D -m0644 VirtualBox-${_vboxver}/COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m0644 VirtualBox-${_vboxver}/COPYING.CDDL "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.CDDL"

    # install systemd stuff
    install -D -m0644 virtualbox.sysusers "${pkgdir}/usr/lib/sysusers.d/virtualbox.conf"
}

knoelli commented on 2024-03-25 21:21 (UTC) (edited on 2024-03-25 21:22 (UTC) by knoelli)

Updated PKGBUILD for version 20240325 with changes suggested by @galvez_65 and all modules enabled:

# Maintainer: xyzzy

# Adapted from the official virtualbox package by
# Contributor: Christian Hesse <eworm@archlinux.org>
# Contributor: Sébastien "Seblu" Luttringer
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=virtualbox-kvm
pkgdesc='Powerful x86 virtualization for enterprise as well as home use (KVM backend)'
pkgver=20240325
_pkgver=dev-${pkgver}
pkgrel=1
_vboxver='7.0.14'
conflicts=('virtualbox' 'virtualbox-ose')
depends=('curl' 'gcc-libs' 'glibc' 'liblzf' 'libpng' 'libtpms' 'libvpx' 'libx11' 'libxcursor'
            'libxext' 'libxinerama' 'libxml2' 'libxmu' 'libxt' 'openssl' 'procps-ng' 'python'
            'qt5-base' 'qt5-tools' 'qt5-x11extras' 'sdl' 'shared-mime-info' 'zlib')
optdepends=('vde2: Virtual Distributed Ethernet support'
            'virtualbox-guest-iso: Guest Additions CD image'
            'virtualbox-ext-vnc: VNC server support'
            'virtualbox-sdk: Developer kit')
backup=('etc/vbox/vbox.cfg')
replaces=('virtualbox-ose')
arch=('x86_64')
url='https://github.com/cyberus-technology/virtualbox-kvm'
vboxurl='https://download.virtualbox.org/virtualbox/'
license=('GPL' 'custom:CDDL')

makedepends=('alsa-lib' 'cdrkit' 'curl' 'device-mapper' 'git' 'glu' 'gsoap' 'glslang' 'iasl'
                'jdk8-openjdk' 'libidl2' 'liblzf' 'libpulse' 'libtpms' 'libvncserver' 'libvpx'
                'libxcomposite' 'libxcursor' 'libxinerama' 'libxml2' 'libxmu' 'libxrandr' 'libxslt'
                'libxtst' 'linux-headers' 'mesa' 'python' 'qt5-base' 'qt5-tools' 'qt5-x11extras'
                'sdl' 'sdl_ttf' 'vde2' 'xorgproto' 'xorg-server-devel' 'yasm')

source=("${vboxurl}${_vboxver}/VirtualBox-${_vboxver}.tar.bz2"
    "${url}/releases/download/${_pkgver}/kvm-backend-7.0.14-${_pkgver}.patch"
        'virtualbox-host-dkms.conf'
        'virtualbox.sysusers'
        'virtualbox-guest-utils.sysusers'
        '60-vboxdrv.rules'
        '60-vboxguest.rules'
        'LocalConfig.kmk'
        'vboxservice.service'
        'vboxservice-nox.service'
        'vboxdrmclient.path'
        'vboxdrmclient.service'
        'vboxweb.service'
        'vboxreload'
        '001-disable-update.patch'
        '004-drop-Wno-format.patch'
        '008-no-vboxvideo.patch'
        '009-properly-handle-i3wm.patch'
        '012-vbglR3GuestCtrlDetectPeekGetCancelSupport.patch'
        '013-support-building-from-dkms.patch'
        '018-upate-xclient-script.patch'
        '019-libxml-2-12.patch')
sha256sums=('45860d834804a24a163c1bb264a6b1cb802a5bc7ce7e01128072f8d6a4617ca9'
            'f02aaab9e6dec3741aa246adc7613c3d0216edcf59b9ce081120d6eece0b0297'
            '76d98ea062fcad9e5e3fa981d046a6eb12a3e718a296544a68b66f4b65cb56db'
            '2101ebb58233bbfadf3aa74381f22f7e7e508559d2b46387114bc2d8e308554c'
            'da4c49f6ca94e047e196cdbcba2c321199f4760056ea66e0fbc659353e128c9e'
            'f876e9f55243eded423fda4fc2ffe3b174dca90380a6315f7c9b3cd1c9d07206'
            '033c597e0f5285d2ddb0490868e5b6f945f45c7b1b1152a02a9e6fea438b2c95'
            '0ae014c6bb778a1b079121064f17179c27b8dde9479a37d34ce071fb3b084e25'
            'c41a801fe344a4471a7b61a4764d1d857c403e4fb96e2ba6bc89c77a35f2be7a'
            '01dbb921bd57a852919cc78be5b73580a564f28ebab2fe8d6c9b8301265cbfce'
            '83d8f24bff25bb925083cf39b3195236c6136105e62417712cc3f25b92e14b47'
            '2beab8de525220fa418c9873f9e0d657ddbad4ff9e4a46d7053e6cd9bc4ce95e'
            'e6e875ef186578b53106d7f6af48e426cdaf1b4e86834f01696b8ef1c685787f'
            '4001b5927348fe669a541e80526d4f9ea91b883805f102f7d571edbb482a9b9d'
            '9ee947c9b5ec5b25f52d3e72340fc3a57ca6e65a604e15b669ac582a3fb0dc1b'
            '7675f87d31ad3137f057dc3ee3d4a2c5b2cfe8cd362adba130ddbf7a65069516'
            '053bfeee8863f3ffdf2f0e3f9f0d77dc61dd32764700a97a7635fd8611e20491'
            'ad0d7af1e4c94f9efbc60827abea9e605398549b3673c40f697d042bb6bfe88a'
            '81900e13d36630488accd8c0bfd2ceb69563fb2c4f0f171caba1cca59d438024'
            '00f68b86d32a1fada900c2da8dad2ab4215106cd58004f049bded99727cda2ff'
            '87dddfd9047480e4c2b73367facf5dd3702148418c2efcd606af17c07da90fe0'
            '25271f26d897bb76ae2a39b6fdf10409acc929e2d424e34d1bd42014a42a0d31')

prepare() {
    cd "VirtualBox-${_vboxver}"

    # apply patches from the source array
    local filename
    for filename in "${source[@]}"; do
        if [[ "${filename}" =~ \.patch$ ]]; then
            echo "Applying patch ${filename##*/}"
            patch -p1 -N -i "${srcdir}/${filename##*/}"
        fi
    done

    sed -i '/cstring/a #include <cstdint>' src/libs/dxvk-native-1.9.2a/src/util/util_bit.h

    echo 'Applying local config'
    cp "${srcdir}/LocalConfig.kmk" .

    echo 'Use our CFLAGS'
    echo "VBOX_GCC_OPT=$CXXFLAGS" >> LocalConfig.kmk
}

build() {
    cd "VirtualBox-${_vboxver}"

    echo 'Build virtualbox-kvm'
    ./configure \
        --with-kvm \
        --disable-hardening \
        --disable-docs \
        --disable-kmods \
        --disable-vmmraw \
        --enable-vde \
        --enable-vnc \
        --enable-webservice \
        --with-makeself=/usr/bin/echo
    # fake makeself binary to compile without nofatal
    # makeself is used by linux installer. we don't need it.
    source ./env.sh
    kmk

    echo 'Build VNC extension pack'
    kmk -C src/VBox/ExtPacks/VNC packing
}

package() {
    source "VirtualBox-${_vboxver}/env.sh"
    cd "VirtualBox-${_vboxver}/out/linux.${BUILD_PLATFORM_ARCH}/release/bin"

    # libraries (and non-PATH executables)
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox"
    install -m0755 *.so -t "${pkgdir}/usr/lib/virtualbox"
    install -m0644 *.r0 VBoxEFI*.fd -t "${pkgdir}/usr/lib/virtualbox"

    # binaries (in /usr/lib/virtualbox)
    install -m0755 \
        VirtualBoxVM \
        VBoxSDL \
        VBoxHeadless \
        VBoxNetAdpCtl \
        VBoxNetDHCP \
        VBoxNetNAT \
        VirtualBox \
        VBoxManage \
        VBoxSVC \
        VBoxExtPackHelperApp \
        VBoxXPCOMIPCD \
        VBoxTestOGL \
        VBoxBalloonCtrl \
        vbox-img \
        vboximg-mount \
        vboxwebsrv \
        webtest \
        -t "${pkgdir}/usr/lib/virtualbox"

    # binaries (in /usr/bin)
    install -d -m0755 "${pkgdir}/usr/bin"
    install -m0755 VBox.sh "${pkgdir}/usr/bin/VBox"
    for i in VirtualBox VirtualBoxVM VBoxManage VBoxSDL VBoxHeadless VBoxBugReport VBoxBalloonCtrl VBoxAutostart vboxwebsrv; do
        ln -sf VBox "${pkgdir}/usr/bin/${i}"
        ln -sf VBox "${pkgdir}/usr/bin/${i,,}"
    done
    for i in vbox-img vboximg-mount; do
        ln -s ../lib/virtualbox/"${i}" "${pkgdir}/usr/bin/${i}"
    done

    # components
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/components"
    install -m0755 components/* -t "${pkgdir}/usr/lib/virtualbox/components"

    # extension packs
    install -d -m0755 "${pkgdir}/usr/lib/virtualbox/ExtensionPacks"

    # languages
    install -d -m0755 "${pkgdir}/usr/share/virtualbox/nls"
    install -m0755 nls/*.qm -t "${pkgdir}/usr/share/virtualbox/nls"

    # scripts
    install -m0755 VBoxCreateUSBNode.sh VBoxSysInfo.sh -t "${pkgdir}/usr/share/virtualbox"

    # icons
    install -D -m0644 VBox.png "${pkgdir}/usr/share/pixmaps/VBox.png"
    pushd icons >/dev/null
    for i in *; do
        install -d "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
        cp "${i}/"* "${pkgdir}/usr/share/icons/hicolor/${i}/mimetypes"
    done
    popd >/dev/null

    # desktop
    install -D -m0644 virtualbox.desktop "${pkgdir}/usr/share/applications/virtualbox.desktop"
    install -D -m0644 virtualbox.xml "${pkgdir}/usr/share/mime/packages/virtualbox.xml"

    # install configuration
    install -d -m0755 "${pkgdir}/etc/vbox"
    echo 'INSTALL_DIR=/usr/lib/virtualbox' > "${pkgdir}/etc/vbox/vbox.cfg"

    cd "${srcdir}"

    # licence
    install -D -m0644 VirtualBox-${_vboxver}/COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
    install -D -m0644 VirtualBox-${_vboxver}/COPYING.CDDL "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.CDDL"

    # systemd
    install -D -m0644 60-vboxdrv.rules "${pkgdir}/usr/lib/udev/rules.d/60-vboxdrv.rules"
    install -D -m0644 vboxweb.service "${pkgdir}/usr/lib/systemd/system/vboxweb.service"
    install -D -m0644 virtualbox.sysusers "${pkgdir}/usr/lib/sysusers.d/virtualbox.conf"

    # module reloading shortcut (with a symlink with default helper)
    install -D -m0755 vboxreload "${pkgdir}/usr/bin"
    ln -s vboxreload "${pkgdir}/usr/bin/rcvboxdrv"
}