x11-misc/virtualgl: OpenSSL 1.1 compatibility
authorCraig Andrews <candrews@gentoo.org>
Wed, 9 Jan 2019 16:08:31 +0000 (11:08 -0500)
committerCraig Andrews <candrews@gentoo.org>
Fri, 11 Jan 2019 21:30:51 +0000 (16:30 -0500)
Closes: https://bugs.gentoo.org/673988
Package-Manager: Portage-2.3.54, Repoman-2.3.12
Signed-off-by: Craig Andrews <candrews@gentoo.org>
x11-misc/virtualgl/files/virtualgl-2.5.2-openssl-1.1-compat-a974c22141d0ded9ff60a0b903f81e6b484d6ba4.patch [new file with mode: 0644]
x11-misc/virtualgl/virtualgl-2.5.2-r1.ebuild [new file with mode: 0644]

diff --git a/x11-misc/virtualgl/files/virtualgl-2.5.2-openssl-1.1-compat-a974c22141d0ded9ff60a0b903f81e6b484d6ba4.patch b/x11-misc/virtualgl/files/virtualgl-2.5.2-openssl-1.1-compat-a974c22141d0ded9ff60a0b903f81e6b484d6ba4.patch
new file mode 100644 (file)
index 0000000..d5d923f
--- /dev/null
@@ -0,0 +1,168 @@
+Patch modified to apply to VirtualGL 2.5.2, before
+1b82bceb3723b24ea5dc32edffbe019a8a37ab39 reformatted whitespace
+
+
+From a974c22141d0ded9ff60a0b903f81e6b484d6ba4 Mon Sep 17 00:00:00 2001
+From: DRC <information@virtualgl.org>
+Date: Mon, 16 Apr 2018 15:06:07 -0500
+Subject: [PATCH] OpenSSL improvements
+
+- Fix build issues with OpenSSL 1.1 (OpenSSL 1.1 and later no longer
+  provides CRYPTO_set_locking_callback(), since locking is now performed
+  internally.)
+- Detect whether the platform has /dev/urandom at compile time, rather
+  than assuming that all Sun and SGI machines don't have it (Solaris 10
+  and later supports /dev/urandom.)
+---
+ ChangeLog.md        |  2 ++
+ include/Socket.h    |  8 ++++++--
+ util/CMakeLists.txt |  5 +++++
+ util/Socket.cpp     | 25 ++++++++++++++++---------
+ 4 files changed, 29 insertions(+), 11 deletions(-)
+
+diff --git a/ChangeLog.md b/ChangeLog.md
+index 3632c1d8..5c9bff84 100644
+--- a/ChangeLog.md
++++ b/ChangeLog.md
+@@ -52,6 +52,8 @@ a subsequent segfault when VTK tried to call `glBlendFuncSeparate()`.
+ VirtualGL's implementation of `glXGetVisualFromFBConfig()` now returns NULL
+ unless the FB config has a corresponding visual on the 3D X server.
+ 
++6. VirtualGL can now be built and run with OpenSSL 1.1.
++
+ 
+ 2.5.2
+ =====
+diff --git a/include/Socket.h b/include/Socket.h
+index dfe45e3a..f7409956 100644
+--- a/include/Socket.h
++++ b/include/Socket.h
+@@ -1,6 +1,6 @@
+ /* Copyright (C)2004 Landmark Graphics Corporation
+  * Copyright (C)2005 Sun Microsystems, Inc.
+- * Copyright (C)2014, 2016 D. R. Commander
++ * Copyright (C)2014, 2016, 2018 D. R. Commander
+  *
+  * This library is free software and may be redistributed and/or modified under
+  * the terms of the wxWindows Library License, Version 3.1 or (at your option)
+@@ -23,7 +23,7 @@
+ #endif
+ #include <openssl/ssl.h>
+ #include <openssl/err.h>
+-#if defined(sun) || defined(sgi)
++#if !defined(HAVE_DEVURANDOM) && !defined(_WIN32)
+ #include <openssl/rand.h>
+ #endif
+ #endif
+@@ -161,15 +161,19 @@ namespace vglutil
+ 
+                       #ifdef USESSL
+ 
++                      #if OPENSSL_VERSION_NUMBER < 0x10100000L
+                       static void lockingCallback(int mode, int type, const char *file,
+                               int line)
+                       {
+                               if(mode&CRYPTO_LOCK) cryptoLock[type].lock();
+                               else cryptoLock[type].unlock();
+                       }
++                      #endif
+ 
+                       static bool sslInit;
++                      #if OPENSSL_VERSION_NUMBER < 0x10100000L
+                       static CriticalSection cryptoLock[CRYPTO_NUM_LOCKS];
++                      #endif
+                       bool doSSL;  SSL_CTX *sslctx;  SSL *ssl;
+ 
+                       #endif
+diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt
+index 65ef59e7..ed1dfb39 100644
+--- a/util/CMakeLists.txt
++++ b/util/CMakeLists.txt
+@@ -13,6 +13,11 @@ target_link_libraries(bmptest vglutil)
+ add_executable(pftest pftest.c)
+ target_link_libraries(pftest vglutil)
+ 
++if(EXISTS /dev/urandom)
++      message(STATUS "Using /dev/urandom for random number generation")
++      add_definitions(-DHAVE_DEVURANDOM)
++endif()
++
+ add_library(vglsocket STATIC Socket.cpp)
+ target_link_libraries(vglsocket vglutil)
+ if(WIN32)
+diff --git a/util/Socket.cpp b/util/Socket.cpp
+index 0d230841..b41c25e9 100644
+--- a/util/Socket.cpp
++++ b/util/Socket.cpp
+@@ -1,6 +1,6 @@
+ /* Copyright (C)2004 Landmark Graphics Corporation
+  * Copyright (C)2005 Sun Microsystems, Inc.
+- * Copyright (C)2014, 2016 D. R. Commander
++ * Copyright (C)2014, 2016, 2018 D. R. Commander
+  *
+  * This library is free software and may be redistributed and/or modified under
+  * the terms of the wxWindows Library License, Version 3.1 or (at your option)
+@@ -43,32 +43,37 @@ typedef socklen_t SOCKLEN_T;
+ 
+ #ifdef USESSL
+ bool Socket::sslInit=false;
++#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ CriticalSection Socket::cryptoLock[CRYPTO_NUM_LOCKS];
+ #endif
++#endif
+ CriticalSection Socket::mutex;
+ int Socket::instanceCount=0;
+ 
+ 
+ #ifdef USESSL
+ 
+-static void progressCallback(int p, int n, void *arg)
+-{
+-}
+-
+-
+ static EVP_PKEY *newPrivateKey(int bits)
+ {
++      BIGNUM *bn = NULL;
++      RSA *rsa = NULL;
+       EVP_PKEY *pk=NULL;
+ 
+       try
+       {
++              if(!(bn = BN_new())) _throwssl();
++              if(!BN_set_word(bn, RSA_F4)) _throwssl();
++              if(!(rsa = RSA_new())) _throwssl();
++              if(!RSA_generate_key_ex(rsa, bits, bn, NULL)) _throwssl();
+               if(!(pk=EVP_PKEY_new())) _throwssl();
+-              if(!EVP_PKEY_assign_RSA(pk, RSA_generate_key(bits, 0x10001,
+-                      progressCallback, NULL))) _throwssl();
++              if(!EVP_PKEY_assign_RSA(pk, rsa)) _throwssl();
++              BN_free(bn);
+               return pk;
+       }
+       catch (...)
+       {
++              if(bn) BN_free(bn);
++              if(rsa) RSA_free(rsa);
+               if(pk) EVP_PKEY_free(pk);
+               throw;
+       }
+@@ -147,7 +152,7 @@ Socket::Socket(bool doSSL_)
+       #ifdef USESSL
+       if(!sslInit && doSSL)
+       {
+-              #if defined(sun) || defined(sgi)
++              #if !defined(HAVE_DEVURANDOM) && !defined(_WIN32)
+               char buf[128];  int i;
+               srandom(getpid());
+               for(i = 0; i < 128; i++)
+@@ -158,7 +163,9 @@ Socket::Socket(bool doSSL_)
+               SSL_load_error_strings();
+               ERR_load_crypto_strings();
+               CRYPTO_set_id_callback(Thread::threadID);
++              #if OPENSSL_VERSION_NUMBER < 0x10100000L
+               CRYPTO_set_locking_callback(lockingCallback);
++              #endif
+               SSL_library_init();
+               sslInit = true;
+               char *env = NULL;
diff --git a/x11-misc/virtualgl/virtualgl-2.5.2-r1.ebuild b/x11-misc/virtualgl/virtualgl-2.5.2-r1.ebuild
new file mode 100644 (file)
index 0000000..aa35612
--- /dev/null
@@ -0,0 +1,91 @@
+# Copyright 1999-2019 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+inherit cmake-multilib flag-o-matic multilib systemd
+
+DESCRIPTION="Run OpenGL applications remotely with full 3D hardware acceleration"
+HOMEPAGE="https://www.virtualgl.org/"
+
+MY_PN="VirtualGL"
+MY_P="${MY_PN}-${PV}"
+S="${WORKDIR}/${MY_P}"
+SRC_URI="mirror://sourceforge/${PN}/files/${PV}/${MY_P}.tar.gz"
+
+SLOT="0"
+LICENSE="LGPL-2.1 wxWinLL-3.1 FLTK"
+KEYWORDS="~amd64 ~arm64 ~x86"
+IUSE="libressl ssl"
+
+RDEPEND="
+       ssl? (
+               !libressl? ( dev-libs/openssl:0=[${MULTILIB_USEDEP}] )
+               libressl? ( dev-libs/libressl:0=[${MULTILIB_USEDEP}] )
+       )
+       media-libs/libjpeg-turbo[${MULTILIB_USEDEP}]
+       x11-libs/libX11[${MULTILIB_USEDEP}]
+       x11-libs/libXext[${MULTILIB_USEDEP}]
+       x11-libs/libXv[${MULTILIB_USEDEP}]
+       virtual/glu[${MULTILIB_USEDEP}]
+       virtual/opengl[${MULTILIB_USEDEP}]
+       amd64? ( abi_x86_32? (
+               >=media-libs/libjpeg-turbo-1.3.0-r3[abi_x86_32]
+               >=x11-libs/libX11-1.6.2[abi_x86_32]
+               >=x11-libs/libXext-1.3.2[abi_x86_32]
+               >=x11-libs/libXv-1.0.10[abi_x86_32]
+               >=virtual/glu-9.0-r1[abi_x86_32]
+               >=virtual/opengl-7.0-r1[abi_x86_32]
+       ) )
+"
+DEPEND="${RDEPEND}"
+PATCHES=(
+       "${FILESDIR}/virtualgl-2.5.2-openssl-1.1-compat-a974c22141d0ded9ff60a0b903f81e6b484d6ba4.patch"
+)
+
+src_prepare() {
+       # Use /var/lib, bug #428122
+       sed -e "s#/etc/opt#/var/lib#g" -i doc/unixconfig.txt doc/index.html doc/advancedopengl.txt \
+               server/vglrun.in server/vglgenkey server/vglserver_config || die
+
+       cmake-utils_src_prepare
+}
+
+src_configure() {
+       # Completely breaks steam/wine for discrete graphics otherwise
+       # see https://github.com/VirtualGL/virtualgl/issues/16
+       append-ldflags "-Wl,--no-as-needed"
+
+       abi_configure() {
+               local mycmakeargs=(
+                       -DVGL_USESSL="$(usex ssl)"
+                       -DCMAKE_INSTALL_DOCDIR=/usr/share/doc/"${PF}"
+                       -DTJPEG_INCLUDE_DIR=/usr/include
+                       -DCMAKE_INSTALL_LIBDIR=/usr/$(get_libdir)
+                       -DTJPEG_LIBRARY=/usr/$(get_libdir)/libturbojpeg.so
+                       -DCMAKE_LIBRARY_PATH=/usr/$(get_libdir)
+               )
+               cmake-utils_src_configure
+       }
+       multilib_parallel_foreach_abi abi_configure
+}
+
+src_install() {
+       cmake-multilib_src_install
+
+       # Make config dir
+       dodir /var/lib/VirtualGL
+       fowners root:video /var/lib/VirtualGL
+       fperms 0750 /var/lib/VirtualGL
+       newinitd "${FILESDIR}/vgl.initd-r3" vgl
+       newconfd "${FILESDIR}/vgl.confd-r2" vgl
+
+       exeinto /usr/libexec
+       doexe "${FILESDIR}/vgl-helper.sh"
+       systemd_dounit "${FILESDIR}/vgl.service"
+
+       # Rename glxinfo to vglxinfo to avoid conflict with x11-apps/mesa-progs
+       mv "${D}"/usr/bin/{,v}glxinfo || die
+
+       # Remove license files, bug 536284
+       rm "${D}"/usr/share/doc/${PF}/{LGPL.txt*,LICENSE*} || die
+}