1
0
forked from pool/virtualbox

- Make necessary updates so that VirtualBox will build with Python 3.7 - boo#1113894

Change kernel module code to build against the API changes in kernel 4.20 - This change
  adds file "fixes_for_4.20".

- Require(pre) virtualbox by the -qt package: otherewise it might
  happen that virtualbox-qt is installed before virtualbox, which
  then results in files being assigned to group 'root' instead of
  'vboxusers', as the group is only created later.

OBS-URL: https://build.opensuse.org/package/show/Virtualization/virtualbox?expand=0&rev=448
This commit is contained in:
Larry Finger 2018-11-03 04:10:03 +00:00 committed by Git OBS Bridge
parent 31274b539e
commit 2558a64093
4 changed files with 275 additions and 28 deletions

175
fixes_for_4.20.patch Normal file
View File

@ -0,0 +1,175 @@
Index: VirtualBox-5.2.20/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
===================================================================
--- VirtualBox-5.2.20.orig/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
+++ VirtualBox-5.2.20/src/VBox/HostDrivers/VBoxNetAdp/linux/VBoxNetAdp-linux.c
@@ -84,8 +84,11 @@ static long VBoxNetAdpLinuxIOCtlUnlocked
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 36) */
static void vboxNetAdpEthGetDrvinfo(struct net_device *dev, struct ethtool_drvinfo *info);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *link_ksettings);
+#else
static int vboxNetAdpEthGetSettings(struct net_device *dev, struct ethtool_cmd *cmd);
-
+#endif
/*********************************************************************************************************************************
* Global Variables *
@@ -129,7 +132,11 @@ static struct miscdevice g_CtlDev =
static const struct ethtool_ops gEthToolOpsVBoxNetAdp =
{
.get_drvinfo = vboxNetAdpEthGetDrvinfo,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+ .get_link_ksettings = vboxNetAdpEthGetSettings,
+#else
.get_settings = vboxNetAdpEthGetSettings,
+#endif
.get_link = ethtool_op_get_link,
};
@@ -200,10 +207,64 @@ static void vboxNetAdpEthGetDrvinfo(stru
"N/A");
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static bool
+convert_link_ksettings_to_legacy_settings(
+ struct ethtool_cmd *legacy_settings,
+ const struct ethtool_link_ksettings *link_ksettings)
+{
+ bool retval = true;
+
+ memset(legacy_settings, 0, sizeof(*legacy_settings));
+ /* this also clears the deprecated fields in legacy structure:
+ * __u8 transceiver;
+ * __u32 maxtxpkt;
+ * __u32 maxrxpkt;
+ */
+
+ retval &= ethtool_convert_link_mode_to_legacy_u32(
+ &legacy_settings->supported,
+ link_ksettings->link_modes.supported);
+ retval &= ethtool_convert_link_mode_to_legacy_u32(
+ &legacy_settings->advertising,
+ link_ksettings->link_modes.advertising);
+ retval &= ethtool_convert_link_mode_to_legacy_u32(
+ &legacy_settings->lp_advertising,
+ link_ksettings->link_modes.lp_advertising);
+ ethtool_cmd_speed_set(legacy_settings, link_ksettings->base.speed);
+ legacy_settings->duplex
+ = link_ksettings->base.duplex;
+ legacy_settings->port
+ = link_ksettings->base.port;
+ legacy_settings->phy_address
+ = link_ksettings->base.phy_address;
+ legacy_settings->autoneg
+ = link_ksettings->base.autoneg;
+ legacy_settings->mdio_support
+ = link_ksettings->base.mdio_support;
+ legacy_settings->eth_tp_mdix
+ = link_ksettings->base.eth_tp_mdix;
+ legacy_settings->eth_tp_mdix_ctrl
+ = link_ksettings->base.eth_tp_mdix_ctrl;
+ legacy_settings->transceiver
+ = link_ksettings->base.transceiver;
+ return retval;
+}
+#endif
/* ethtool_ops::get_settings */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_link_ksettings *link_ksettings)
+#else
static int vboxNetAdpEthGetSettings(struct net_device *pNetDev, struct ethtool_cmd *cmd)
+#endif
{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+ struct ethtool_cmd *cmd = kzalloc(sizeof(struct ethtool_cmd), GFP_KERNEL);
+ if (!cmd)
+ return 1;
+ convert_link_ksettings_to_legacy_settings(cmd, link_ksettings);
+#endif
cmd->supported = 0;
cmd->advertising = 0;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
@@ -218,6 +279,9 @@ static int vboxNetAdpEthGetSettings(stru
cmd->autoneg = AUTONEG_DISABLE;
cmd->maxtxpkt = 0;
cmd->maxrxpkt = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+ kfree(cmd);
+#endif
return 0;
}
Index: VirtualBox-5.2.20/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
===================================================================
--- VirtualBox-5.2.20.orig/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
+++ VirtualBox-5.2.20/src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
@@ -171,11 +171,19 @@ RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPE
{
IPRT_LINUX_SAVE_EFL_AC();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+ struct timespec64 Ts;
+ ktime_get_real_ts64(&Ts);
+#else
struct timespec Ts;
ktime_get_real_ts(&Ts);
+#endif
IPRT_LINUX_RESTORE_EFL_AC();
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
+ return RTTimeSpecSetTimespec64(pTime, &Ts);
+#else
return RTTimeSpecSetTimespec(pTime, &Ts);
-
+#endif
#else /* < 2.6.16 */
struct timeval Tv;
do_gettimeofday(&Tv);
Index: VirtualBox-5.2.20/include/iprt/time.h
===================================================================
--- VirtualBox-5.2.20.orig/include/iprt/time.h
+++ VirtualBox-5.2.20/include/iprt/time.h
@@ -54,7 +54,6 @@ typedef struct RTTIMESPEC
int64_t i64NanosecondsRelativeToUnixEpoch;
} RTTIMESPEC;
-
/** @name RTTIMESPEC methods
* @{ */
@@ -388,6 +387,7 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
{
return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
}
+
#endif /* various ways of detecting struct timeval */
@@ -427,6 +427,25 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
{
return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
}
+
+#ifndef _LINUX_TIME64_H
+/* With kernel 4.20+, the second argument of time routines change from
+ * struct timespec to struct timespec64. This file is built twice, once
+ * in user mode, and once in kernel mode. In user mode, the struct is
+ * undefined, thus the following definition is provided. The guard macro
+ * from the kernels include/linux/time64.h is _LINUX_TIME64_H, thus
+ * the definition of that macro determines whether the struct is defined.
+ */
+struct timespec64 {
+ long long tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+};
+#endif
+
+DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
+{
+ return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), 1000 * pTimeval->tv_nsec);
+}
#endif /* various ways of detecting struct timespec */

View File

@ -1,7 +1,7 @@
Index: VirtualBox-5.2.16/configure
Index: VirtualBox-5.2.20/configure
===================================================================
--- VirtualBox-5.2.16.orig/configure
+++ VirtualBox-5.2.16/configure
--- VirtualBox-5.2.20.orig/configure
+++ VirtualBox-5.2.20/configure
@@ -1959,17 +1959,17 @@ extern "C" int main(void)
{
Py_Initialize();
@ -19,14 +19,14 @@ Index: VirtualBox-5.2.16/configure
EOF
found=
- SUPPYTHONLIBS="python2.7 python2.6 python3.1 python3.2 python3.3 python3.4 python3.4m python3.5 python3.5m python3.6 python3.6m"
+ SUPPYTHONLIBS="python3.6m python3.6 python3.6m"
+ SUPPYTHONLIBS="python3.6m python3.6 python3.7m python3.7"
for p in $PYTHONDIR; do
for d in $SUPPYTHONLIBS; do
for b in lib/x86_64-linux-gnu lib/i386-linux-gnu lib64 lib/64 lib; do
Index: VirtualBox-5.2.16/src/VBox/Installer/linux/routines.sh
Index: VirtualBox-5.2.20/src/VBox/Installer/linux/routines.sh
===================================================================
--- VirtualBox-5.2.16.orig/src/VBox/Installer/linux/routines.sh
+++ VirtualBox-5.2.16/src/VBox/Installer/linux/routines.sh
--- VirtualBox-5.2.20.orig/src/VBox/Installer/linux/routines.sh
+++ VirtualBox-5.2.20/src/VBox/Installer/linux/routines.sh
@@ -375,8 +375,8 @@ terminate_proc() {
maybe_run_python_bindings_installer() {
VBOX_INSTALL_PATH="${1}"
@ -38,10 +38,10 @@ Index: VirtualBox-5.2.16/src/VBox/Installer/linux/routines.sh
if sys.version_info >= (2, 6):
print \"test\"' 2> /dev/null`" != "test" ]; then
echo 1>&2 "Python 2.6 or later not available, skipping bindings installation."
Index: VirtualBox-5.2.16/src/bldprogs/scm.cpp
Index: VirtualBox-5.2.20/src/bldprogs/scm.cpp
===================================================================
--- VirtualBox-5.2.16.orig/src/bldprogs/scm.cpp
+++ VirtualBox-5.2.16/src/bldprogs/scm.cpp
--- VirtualBox-5.2.20.orig/src/bldprogs/scm.cpp
+++ VirtualBox-5.2.20/src/bldprogs/scm.cpp
@@ -2031,7 +2031,7 @@ static int scmProcessFileInner(PSCMRWSTA
pszTreatAs = "shell";
else if ( (cchFirst >= 15 && strncmp(pchFirst, "/usr/bin/python", 15) == 0)
@ -51,10 +51,10 @@ Index: VirtualBox-5.2.16/src/bldprogs/scm.cpp
else if ( (cchFirst >= 13 && strncmp(pchFirst, "/usr/bin/perl", 13) == 0)
|| (cchFirst >= 17 && strncmp(pchFirst, "/usr/bin/env perl", 17) == 0) )
pszTreatAs = "perl";
Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/configure
Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/configure
===================================================================
--- VirtualBox-5.2.16.orig/src/libs/libxml2-2.9.4/configure
+++ VirtualBox-5.2.16/src/libs/libxml2-2.9.4/configure
--- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/configure
+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/configure
@@ -15153,10 +15153,10 @@ PYTHON_SITE_PACKAGES=
PYTHON_TESTS=
pythondir=
@ -79,10 +79,10 @@ Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/configure
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PYTHON+:} false; then :
Index: VirtualBox-5.2.16/src/VBox/ValidationKit/testboxscript/setup.sh
Index: VirtualBox-5.2.20/src/VBox/ValidationKit/testboxscript/setup.sh
===================================================================
--- VirtualBox-5.2.16.orig/src/VBox/ValidationKit/testboxscript/setup.sh
+++ VirtualBox-5.2.16/src/VBox/ValidationKit/testboxscript/setup.sh
--- VirtualBox-5.2.20.orig/src/VBox/ValidationKit/testboxscript/setup.sh
+++ VirtualBox-5.2.20/src/VBox/ValidationKit/testboxscript/setup.sh
@@ -644,7 +644,7 @@ import sys;\
x = sys.version_info[0] == 2 and (sys.version_info[1] >= 6 or (sys.version_info[1] == 5 and sys.version_info[2] >= 1));\
sys.exit(not x);\
@ -92,10 +92,10 @@ Index: VirtualBox-5.2.16/src/VBox/ValidationKit/testboxscript/setup.sh
do
python=`which ${python} 2> /dev/null`
if [ -n "${python}" -a -x "${python}" ]; then
Index: VirtualBox-5.2.16/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
Index: VirtualBox-5.2.20/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
===================================================================
--- VirtualBox-5.2.16.orig/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+++ VirtualBox-5.2.16/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
--- VirtualBox-5.2.20.orig/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+++ VirtualBox-5.2.20/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
@@ -20,7 +20,7 @@
%define %PYTHON% 1
%define VBOXDOCDIR %{_defaultdocdir}/%NAME%
@ -114,10 +114,10 @@ Index: VirtualBox-5.2.16/src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
%endif
rm -rf sdk/installer
mv nls $RPM_BUILD_ROOT/usr/share/virtualbox
Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml.spec.in
Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml.spec.in
===================================================================
--- VirtualBox-5.2.16.orig/src/libs/libxml2-2.9.4/libxml.spec.in
+++ VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml.spec.in
--- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/libxml.spec.in
+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml.spec.in
@@ -101,11 +101,11 @@ rm -fr %{buildroot}
make install DESTDIR=%{buildroot}
@ -133,10 +133,10 @@ Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml.spec.in
rm -f $RPM_BUILD_ROOT%{_libdir}/*.la
Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml2.spec
Index: VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml2.spec
===================================================================
--- VirtualBox-5.2.16.orig/src/libs/libxml2-2.9.4/libxml2.spec
+++ VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml2.spec
--- VirtualBox-5.2.20.orig/src/libs/libxml2-2.9.4/libxml2.spec
+++ VirtualBox-5.2.20/src/libs/libxml2-2.9.4/libxml2.spec
@@ -103,7 +103,7 @@ make install DESTDIR=%{buildroot}
%if 0%{?with_python3}
@ -146,3 +146,36 @@ Index: VirtualBox-5.2.16/src/libs/libxml2-2.9.4/libxml2.spec
make install DESTDIR=%{buildroot}
%endif # with_python3
Index: VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
===================================================================
--- VirtualBox-5.2.20.orig/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
+++ VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/ErrorUtils.cpp
@@ -439,8 +439,10 @@ char *PyTraceback_AsString(PyObject *exc
{ // a temp scope so I can use temp locals.
#if PY_MAJOR_VERSION <= 2
char *tempResult = PyString_AsString(obResult);
-#else
+#elif PY_MINOR_VERSION <= 6
char *tempResult = PyUnicode_AsUTF8(obResult);
+#else
+ const char *tempResult = PyUnicode_AsUTF8(obResult);
#endif
result = (char *)PyMem_Malloc(strlen(tempResult)+1);
if (result==NULL)
Index: VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/PyGBase.cpp
===================================================================
--- VirtualBox-5.2.20.orig/src/libs/xpcom18a4/python/src/PyGBase.cpp
+++ VirtualBox-5.2.20/src/libs/xpcom18a4/python/src/PyGBase.cpp
@@ -183,7 +183,11 @@ PyG_Base::~PyG_Base()
// Get the correct interface pointer for this object given the IID.
void *PyG_Base::ThisAsIID( const nsIID &iid )
{
- if (this==NULL) return NULL;
+#if PY_MINOR_VERSION <= 6
+ if (!this) return NULL;
+#else
+ if (!this) return NULL;
+#endif
if (iid.Equals(NS_GET_IID(nsISupports)))
return (nsISupports *)(nsIInternalPython *)this;
if (iid.Equals(NS_GET_IID(nsISupportsWeakReference)))

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Sat Nov 3 04:04:06 UTC 2018 - Larry Finger <Larry.Finger@gmail.com>
- Make necessary updates so that VirtualBox will build with Python 3.7 - boo#1113894
Change kernel module code to build against the API changes in kernel 4.20 - This change
adds file "fixes_for_4.20".
-------------------------------------------------------------------
Fri Nov 2 09:48:23 UTC 2018 - Dominique Leuenberger <dimstar@opensuse.org>
- Require(pre) virtualbox by the -qt package: otherewise it might
happen that virtualbox-qt is installed before virtualbox, which
then results in files being assigned to group 'root' instead of
'vboxusers', as the group is only created later.
-------------------------------------------------------------------
Mon Oct 29 20:11:57 UTC 2018 - Larry Finger <Larry.Finger@gmail.com>

View File

@ -240,7 +240,7 @@ GNU Public License (GPL).
%package qt
Summary: Qt GUI part for %{name}
Group: System/Emulators/PC
Requires: %{name} = %{version}
Requires(pre): %{name} = %{version}
Requires(pre): permissions
Provides: %{name}-gui = %{version}
#this is needed during update to trigger installing qt subpackage
@ -706,7 +706,7 @@ install -m 0755 -D src/VBox/Installer/linux/VBoxCreateUSBNode.sh %{buildroot}%{_
echo "entering python-virtualbox install section"
######################################################
pushd out/linux.*/release/bin/sdk/installer
VBOX_INSTALL_PATH=%{_vbox_instdir} python3 vboxapisetup.py install --prefix=%{_prefix} --root=%{buildroot} --record-rpm=%{_tmppath}/SITE_FILES
VBOX_INSTALL_PATH=%{_vbox_instdir} python3 vboxapisetup.py install --prefix=%{_prefix} --root=%{buildroot}
popd
install -d -m 755 %{buildroot}%{_vbox_instdir}/sdk/bindings/xpcom
cp -r out/linux.*/release/bin/sdk/bindings/xpcom/python %{buildroot}%{_vbox_instdir}/sdk/bindings/xpcom
@ -975,13 +975,37 @@ export DISABLE_RESTART_ON_UPDATE=yes
%dir /media
%endif
%files -n python3-%{name} -f %{_tmppath}/SITE_FILES
%defattr(-, root, root)
%dir %{_vbox_instdir}/sdk
%dir %{_vbox_instdir}/sdk/bindings
%dir %{_vbox_instdir}/sdk/bindings/xpcom
%{_vbox_instdir}/sdk/bindings/xpcom/python
#
# With Python 3.6 and earlier, vboxapisetup.py would save the names of the files
# that it created to a temporary file and use that file to create a list. With
# Python 3.7, this file is no longer created, thus the code is switched to handling
# those directories and file manually. The python3_version_nodots macro is used to
# detect the correct file names.
#
%if %python3_version_nodots > 36
%attr(0755, root, root) %{_vbox_instdir}/VBoxPython3_7m.so
%dir /usr/lib/python3.7/site-packages/vboxapi
%dir /usr/lib/python3.7/site-packages/vboxapi/__pycache__
%attr(0755, root, root) /usr/lib/python3.7/site-packages/vboxapi-1.0-py3.7.egg-info
%attr(0755, root, root) /usr/lib/python3.7/site-packages/vboxapi/VirtualBox_constants.py
%attr(0755, root, root) /usr/lib/python3.7/site-packages/vboxapi/__init__.py
%attr(0755, root, root) /usr/lib/python3.7/site-packages/vboxapi/__pycache__/VirtualBox_constants.cpython-37.pyc
%attr(0755, root, root) /usr/lib/python3.7/site-packages/vboxapi/__pycache__/__init__.cpython-37.pyc
%else
%dir /usr/lib/python3.6/site-packages/vboxapi
%dir /usr/lib/python3.6/site-packages/vboxapi/__pycache__
%attr(0755, root, root) %{_vbox_instdir}/VBoxPython3_6m.so
%attr(0755, root, root) /usr/lib/python3.6/site-packages/vboxapi-1.0-py3.6.egg-info
%attr(0755, root, root) /usr/lib/python3.6/site-packages/vboxapi/VirtualBox_constants.py
%attr(0755, root, root) /usr/lib/python3.6/site-packages/vboxapi/__init__.py
%attr(0755, root, root) /usr/lib/python3.6/site-packages/vboxapi/__pycache__/VirtualBox_constants.cpython-36.pyc
%attr(0755, root, root) /usr/lib/python3.6/site-packages/vboxapi/__pycache__/__init__.cpython-36.pyc
%endif
%files devel
%defattr(-,root, root)