summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/vizglow/package.py
blob: 1e68e9632c94dfa230418dd2ddad6bdb9cb82bcc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)

import glob
import os

from spack import *


class Vizglow(Package):
    """VizGlow software tool is used for high-fidelity multi-dimensional
    modeling of non-equilibrium plasma discharges.

    Note: VizGlow is licensed software. You will need to create an account on
    the EsgeeTech homepage and download VizGlow yourself. Spack will search
    your current directory for a file of this format. Alternatively, add this
    file to a mirror so that Spack can find it. For instructions on how to
    set up a mirror, see http://spack.readthedocs.io/en/latest/mirrors.html"""

    homepage = "https://esgeetech.com/products/vizglow-plasma-modeling/"
    manual_download = True

    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', '--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)