From c7a1328326054980bd8f8e78dfb5fe6c0a83819d Mon Sep 17 00:00:00 2001
From: "Adam J. Stewart" <ajstewart426@gmail.com>
Date: Thu, 26 Jan 2017 04:30:18 -0600
Subject: [PATCH] Add missing dependencies to VizGlow package (#2581)

* Add missing dependencies to VizGlow package

* Use a version-specific URL for xterm
---
 .../builtin/packages/libcanberra/package.py   | 68 +++++++++++++++++++
 .../repos/builtin/packages/libogg/package.py  | 35 ++++++++++
 .../builtin/packages/libvorbis/package.py     | 44 ++++++++++++
 .../repos/builtin/packages/vizglow/package.py | 57 +++++++++++++++-
 .../repos/builtin/packages/xterm/package.py   | 55 +++++++++++++++
 5 files changed, 257 insertions(+), 2 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/libcanberra/package.py
 create mode 100644 var/spack/repos/builtin/packages/libogg/package.py
 create mode 100644 var/spack/repos/builtin/packages/libvorbis/package.py
 create mode 100644 var/spack/repos/builtin/packages/xterm/package.py

diff --git a/var/spack/repos/builtin/packages/libcanberra/package.py b/var/spack/repos/builtin/packages/libcanberra/package.py
new file mode 100644
index 0000000000..dfeb5c9c3e
--- /dev/null
+++ b/var/spack/repos/builtin/packages/libcanberra/package.py
@@ -0,0 +1,68 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Libcanberra(AutotoolsPackage):
+    """libcanberra is an implementation of the XDG Sound Theme and
+    Name Specifications, for generating event sounds on free desktops,
+    such as GNOME."""
+
+    homepage = "http://0pointer.de/lennart/projects/libcanberra/"
+    url      = "http://0pointer.de/lennart/projects/libcanberra/libcanberra-0.30.tar.xz"
+
+    version('0.30', '34cb7e4430afaf6f447c4ebdb9b42072')
+
+    # TODO: Add variants and dependencies for the following audio support:
+    # ALSA, OSS, PulseAudio, udev, GStreamer, null, GTK3+ , tdb
+
+    variant('gtk', default=False, description='Enable optional GTK+ support')
+
+    depends_on('libxrender',    when='+gtk')
+    depends_on('libxext',       when='+gtk')
+    depends_on('libx11',        when='+gtk')
+    depends_on('libxinerama',   when='+gtk')
+    depends_on('libxrandr',     when='+gtk')
+    depends_on('libxcursor',    when='+gtk')
+    depends_on('libxcomposite', when='+gtk')
+    depends_on('libxdamage',    when='+gtk')
+    depends_on('libxfixes',     when='+gtk')
+    depends_on('libxcb',        when='+gtk')
+    depends_on('libxau',        when='+gtk')
+    depends_on('gtkplus',       when='+gtk')
+
+    depends_on('libvorbis')
+
+    depends_on('pkg-config@0.9.0:', type='build')
+
+    def configure_args(self):
+        args = ['--enable-static']
+
+        if '+gtk' in self.spec:
+            args.append('--enable-gtk')
+        else:
+            args.append('--disable-gtk')
+
+        return args
diff --git a/var/spack/repos/builtin/packages/libogg/package.py b/var/spack/repos/builtin/packages/libogg/package.py
new file mode 100644
index 0000000000..bb80764b7c
--- /dev/null
+++ b/var/spack/repos/builtin/packages/libogg/package.py
@@ -0,0 +1,35 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Libogg(AutotoolsPackage):
+    """Ogg is a multimedia container format, and the native file and stream
+    format for the Xiph.org multimedia codecs."""
+
+    homepage = "https://www.xiph.org/ogg/"
+    url      = "http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.gz"
+
+    version('1.3.2', 'b72e1a1dbadff3248e4ed62a4177e937')
diff --git a/var/spack/repos/builtin/packages/libvorbis/package.py b/var/spack/repos/builtin/packages/libvorbis/package.py
new file mode 100644
index 0000000000..e716abe46d
--- /dev/null
+++ b/var/spack/repos/builtin/packages/libvorbis/package.py
@@ -0,0 +1,44 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Libvorbis(AutotoolsPackage):
+    """Ogg Vorbis is a fully open, non-proprietary, patent-and-royalty-free,
+    general-purpose compressed audio format for mid to high quality (8kHz-
+    48.0kHz, 16+ bit, polyphonic) audio and music at fixed and variable
+    bitrates from 16 to 128 kbps/channel."""
+
+    homepage = "https://xiph.org/vorbis/"
+    url      = "http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.gz"
+
+    version('1.3.5', '7220e089f3be3412a2317d6fde9e3944')
+
+    depends_on('libogg')
+
+    depends_on('pkg-config@0.9.0:', type='build')
+
+    # `make check` crashes when run in parallel
+    parallel = False
diff --git a/var/spack/repos/builtin/packages/vizglow/package.py b/var/spack/repos/builtin/packages/vizglow/package.py
index 9e4506b05a..42e3e23ace 100644
--- a/var/spack/repos/builtin/packages/vizglow/package.py
+++ b/var/spack/repos/builtin/packages/vizglow/package.py
@@ -39,20 +39,73 @@ class Vizglow(Package):
 
     homepage = "http://esgeetech.com/products/vizglow-plasma-modeling/"
 
-    version('2.2a-15', 'be2b5044f30f2b2c3bbe87a0037bf228', expand=False,
+    version('2.2alpha20', '2bef890c66f3a44aaf96f7c96788c89e', expand=False,
+            url="file://{0}/VizGlow_v2.2alpha20-Linux-x86_64-R09December2016-Install".format(os.getcwd()))
+    version('2.2alpha17', '1de268564363e0ee86f9ffff1c3b82e1', expand=False,
+            url="file://{0}/VizGlow_v2.2alpha17-R21November2016-Linux-x86_64-Install".format(os.getcwd()))
+    version('2.2alpha15', 'be2b5044f30f2b2c3bbe87a0037bf228', expand=False,
             url="file://{0}/VizGlow_v2.2alpha15-Linux-x86_64-R31October2016-Install".format(os.getcwd()))
 
+    # depends_on('mesa')  # TODO: mesa build doesn't work for me
+    depends_on('zlib')
+    depends_on('freetype')
+    depends_on('fontconfig')
+    depends_on('libxrender')
+    depends_on('xterm')
+    # Can't get mozjs to build, packagekit -> polkit -> mozjs
+    # depends_on('packagekit+gtk')
+    depends_on('libcanberra+gtk')
+
     # Licensing
     license_required = True
     license_comment = '#'
     license_files = ['esgeelm.lic']
     license_vars = ['ESGEE_LICENSE_FILE']
 
+    def configure(self, prefix):
+        # Dictionary of responses
+        responses = {
+            'CreateDesktopShortcut': 'No',
+            'CreateQuickLaunchShortcut': 'No',
+            'InstallDir': prefix
+        }
+
+        # Write response file
+        with open('spack-responses.txt', 'w') as response_file:
+            for key in responses:
+                response_file.write('{0}: {1}\n'.format(key, responses[key]))
+
     def install(self, spec, prefix):
+        self.configure(prefix)
+
         installer = glob.glob('VizGlow*Install')[0]
 
         chmod = which('chmod')
         chmod('+x', installer)
 
         installer = Executable(installer)
-        installer('--mode', 'silent', '--prefix', prefix)
+        installer('--mode', 'silent', '--response-file', 'spack-responses.txt')
+
+        self.filter_ld_library_path(spec, prefix)
+
+    def filter_ld_library_path(self, spec, prefix):
+        """Run after install to inject dependencies into LD_LIBRARY_PATH.
+
+        If we don't do this, the run files will clear the LD_LIBRARY_PATH.
+        Since the installer is a binary file, we have no means of specifying
+        an RPATH to use."""
+
+        files = glob.glob(prefix + '/binaries/*.run')
+
+        ld_library_path = ':'.join([
+            spec['zlib'].prefix.lib,
+            spec['freetype'].prefix.lib,
+            spec['fontconfig'].prefix.lib,
+            spec['libxrender'].prefix.lib,
+            spec['libcanberra'].prefix.lib
+        ])
+
+        for runfile in files:
+            filter_file('(export LD_LIBRARY_PATH=)$',
+                        r'\1{0}'.format(ld_library_path),
+                        runfile)
diff --git a/var/spack/repos/builtin/packages/xterm/package.py b/var/spack/repos/builtin/packages/xterm/package.py
new file mode 100644
index 0000000000..a4977491ea
--- /dev/null
+++ b/var/spack/repos/builtin/packages/xterm/package.py
@@ -0,0 +1,55 @@
+##############################################################################
+# Copyright (c) 2013-2016, Lawrence Livermore National Security, LLC.
+# Produced at the Lawrence Livermore National Laboratory.
+#
+# This file is part of Spack.
+# Created by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
+# LLNL-CODE-647188
+#
+# For details, see https://github.com/llnl/spack
+# Please also see the LICENSE file for our notice and the LGPL.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License (as
+# published by the Free Software Foundation) version 2.1, February 1999.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
+# conditions of the GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##############################################################################
+from spack import *
+
+
+class Xterm(AutotoolsPackage):
+    """The xterm program is a terminal emulator for the X Window System. It
+    provides DEC VT102 and Tektronix 4014 compatible terminals for programs
+    that can't use the window system directly."""
+
+    homepage = "http://invisible-island.net/xterm/"
+    url      = "ftp://invisible-island.net/xterm/xterm-327.tgz"
+
+    version('327', '3c32e931adcad44e64e57892e75d9e02')
+
+    depends_on('libxft')
+    depends_on('fontconfig')
+    depends_on('libxaw')
+    depends_on('libxmu')
+    depends_on('libxt')
+    depends_on('libx11')
+    depends_on('libxinerama')
+    depends_on('libxpm')
+    depends_on('libice')
+    depends_on('freetype')
+    depends_on('libxrender')
+    depends_on('libxext')
+    depends_on('libsm')
+    depends_on('libxcb')
+    depends_on('libxau')
+    depends_on('bzip2')
+
+    depends_on('pkg-config', type='build')
-- 
GitLab