From a11765dbdfc5664125f4a93b1ef318ddfb35d2f8 Mon Sep 17 00:00:00 2001
From: Milton Woods <miltonjwoods@gmail.com>
Date: Mon, 15 Jan 2018 08:41:17 +1100
Subject: [PATCH] Qt fixes for RHEL6/7 (#6895)

* qt: move licence acceptance from qt3krell.patch to qt3accept.patch

* qt: ensure that ptrdiff_t is defined for qt@3.3.8b

* qt: disable webglplugin for qt@5.10~opengl

* qt: depend on libxext (for qt@3 and @4)

* qt: avoid X dependencies on darwin platforms

* Revert "qt: avoid X dependencies on darwin platforms"

This reverts commit 05ce08de94be1e02d7e2f2dae0c1ae59baa3f65a.

* qt: limit range of versions depending on libxext
---
 .../repos/builtin/packages/qt/package.py      | 11 ++++++
 .../repos/builtin/packages/qt/qt3accept.patch | 38 +++++++++++++++++++
 .../repos/builtin/packages/qt/qt3krell.patch  | 38 -------------------
 .../builtin/packages/qt/qt3ptrdiff.patch      | 20 ++++++++++
 4 files changed, 69 insertions(+), 38 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/qt/qt3accept.patch
 create mode 100644 var/spack/repos/builtin/packages/qt/qt3ptrdiff.patch

diff --git a/var/spack/repos/builtin/packages/qt/package.py b/var/spack/repos/builtin/packages/qt/package.py
index 3f3defeb8c..1505eff61a 100644
--- a/var/spack/repos/builtin/packages/qt/package.py
+++ b/var/spack/repos/builtin/packages/qt/package.py
@@ -71,7 +71,9 @@ class Qt(Package):
     # see https://github.com/Homebrew/homebrew-core/pull/5951
     patch('restore-pc-files.patch', when='@5.9: platform=darwin')
 
+    patch('qt3accept.patch', when='@3.3.8b')
     patch('qt3krell.patch', when='@3.3.8b+krellpatch')
+    patch('qt3ptrdiff.patch', when='@3.3.8b')
 
     # see https://bugreports.qt.io/browse/QTBUG-57656
     patch('QTBUG-57656.patch', when='@5.8.0')
@@ -125,9 +127,13 @@ class Qt(Package):
 
     # OpenGL hardware acceleration
     depends_on("mesa", when='@4:+opengl')
+
     depends_on("libxcb", when=sys.platform != 'darwin')
     depends_on("libx11", when=sys.platform != 'darwin')
 
+    if sys.platform != 'darwin':
+        depends_on("libxext", when='@3:4.99')
+
     # Webkit
     depends_on("flex", when='+webkit', type='build')
     depends_on("bison", when='+webkit', type='build')
@@ -368,6 +374,11 @@ def configure(self):
                 '-skip', 'webengine',
             ])
 
+        if '~opengl' in self.spec and self.spec.satisfies('@5.10:'):
+            config_args.extend([
+                '-skip', 'webglplugin',
+            ])
+
         configure('-no-eglfs',
                   '-no-directfb',
                   '-{0}gtk'.format('' if '+gtk' in self.spec else 'no-'),
diff --git a/var/spack/repos/builtin/packages/qt/qt3accept.patch b/var/spack/repos/builtin/packages/qt/qt3accept.patch
new file mode 100644
index 0000000000..32dfb9df08
--- /dev/null
+++ b/var/spack/repos/builtin/packages/qt/qt3accept.patch
@@ -0,0 +1,38 @@
+--- qt-x11-free-3.3.8b/configure	2008-01-15 13:09:15.000000000 -0600
++++ qt-x11-free-3.3.8b-fixes/configure	2015-07-08 15:49:03.379560633 -0500
+@@ -2339,7 +2339,7 @@
+         else
+             echo "Do you accept the terms of the $TheLicense? \c"
+         fi
+-        read acceptance
++        acceptance=yes
+         echo
+ 	if [ "$acceptance" = yes ]; then
+ 	    break
+@@ -2397,7 +2397,7 @@
+ 	else
+ 	    echo "Do you accept the terms of $affix license? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
+@@ -2443,7 +2443,7 @@
+ 	else
+ 	    echo "Do you accept the terms of the license? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
+@@ -2524,7 +2524,7 @@
+ 	else
+ 	    echo "Do you accept the terms of the $Platform License? \c"
+ 	fi
+-	read acceptance
++        acceptance=yes
+ 	echo
+ 	if [ "$acceptance" = "yes" ]; then
+ 	    break
diff --git a/var/spack/repos/builtin/packages/qt/qt3krell.patch b/var/spack/repos/builtin/packages/qt/qt3krell.patch
index 3333eeacd4..4f1c12e43e 100644
--- a/var/spack/repos/builtin/packages/qt/qt3krell.patch
+++ b/var/spack/repos/builtin/packages/qt/qt3krell.patch
@@ -28,41 +28,3 @@
  #endif
  
  template <class T>
---- qt-x11-free-3.3.8b/configure	2008-01-15 13:09:15.000000000 -0600
-+++ qt-x11-free-3.3.8b-fixes/configure	2015-07-08 15:49:03.379560633 -0500
-@@ -2339,7 +2339,7 @@
-         else
-             echo "Do you accept the terms of the $TheLicense? \c"
-         fi
--        read acceptance
-+        acceptance=yes
-         echo
- 	if [ "$acceptance" = yes ]; then
- 	    break
-@@ -2397,7 +2397,7 @@
- 	else
- 	    echo "Do you accept the terms of $affix license? \c"
- 	fi
--	read acceptance
-+        acceptance=yes
- 	echo
- 	if [ "$acceptance" = "yes" ]; then
- 	    break
-@@ -2443,7 +2443,7 @@
- 	else
- 	    echo "Do you accept the terms of the license? \c"
- 	fi
--	read acceptance
-+        acceptance=yes
- 	echo
- 	if [ "$acceptance" = "yes" ]; then
- 	    break
-@@ -2524,7 +2524,7 @@
- 	else
- 	    echo "Do you accept the terms of the $Platform License? \c"
- 	fi
--	read acceptance
-+        acceptance=yes
- 	echo
- 	if [ "$acceptance" = "yes" ]; then
- 	    break
diff --git a/var/spack/repos/builtin/packages/qt/qt3ptrdiff.patch b/var/spack/repos/builtin/packages/qt/qt3ptrdiff.patch
new file mode 100644
index 0000000000..5043e4b5a8
--- /dev/null
+++ b/var/spack/repos/builtin/packages/qt/qt3ptrdiff.patch
@@ -0,0 +1,20 @@
+--- a/src/tools/qmap.h	2008-01-16 06:09:13.000000000 +1100
++++ b/src/tools/qmap.h	2018-01-07 11:32:38.720893324 +1100
+@@ -52,6 +52,7 @@
+ #ifndef QT_NO_STL
+ #include <iterator>
+ #include <map>
++#include <stddef.h>
+ #endif
+ 
+ //#define QT_CHECK_MAP_RANGE
+--- a/src/tools/qvaluelist.h	2008-01-16 06:09:13.000000000 +1100
++++ b/src/tools/qvaluelist.h	2018-01-07 11:33:03.393206961 +1100
+@@ -50,6 +50,7 @@
+ #ifndef QT_NO_STL
+ #include <iterator>
+ #include <list>
++#include <stddef.h>
+ #endif
+ 
+ //#define QT_CHECK_VALUELIST_RANGE
-- 
GitLab