From 343f3b2fde46f2de34f16ed1cacbd7455b4a8498 Mon Sep 17 00:00:00 2001
From: "Adam J. Stewart" <ajstewart426@gmail.com>
Date: Fri, 31 Mar 2017 11:51:13 -0500
Subject: [PATCH] Add QBank package (#3641)

* Add QBank package

* Install the documentation and add it to the MANPATH

* Add Perl DBI package

* Make sure setup method variables are consistent
---
 .../builtin/packages/perl-dbi/package.py      | 36 ++++++++
 .../repos/builtin/packages/perl/package.py    | 10 +--
 .../repos/builtin/packages/qbank/package.py   | 87 +++++++++++++++++++
 3 files changed, 128 insertions(+), 5 deletions(-)
 create mode 100644 var/spack/repos/builtin/packages/perl-dbi/package.py
 create mode 100644 var/spack/repos/builtin/packages/qbank/package.py

diff --git a/var/spack/repos/builtin/packages/perl-dbi/package.py b/var/spack/repos/builtin/packages/perl-dbi/package.py
new file mode 100644
index 0000000000..d1c6a11fb4
--- /dev/null
+++ b/var/spack/repos/builtin/packages/perl-dbi/package.py
@@ -0,0 +1,36 @@
+##############################################################################
+# 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 PerlDbi(PerlPackage):
+    """The DBI is the standard database interface module for Perl. It defines
+    a set of methods, variables and conventions that provide a consistent
+    database interface independent of the actual database being used."""
+
+    homepage = "https://dbi.perl.org/"
+    url      = "http://search.cpan.org/CPAN/authors/id/T/TI/TIMB/DBI-1.636.tar.gz"
+
+    version('1.636',  '60f291e5f015550dde71d1858dfe93ba')
diff --git a/var/spack/repos/builtin/packages/perl/package.py b/var/spack/repos/builtin/packages/perl/package.py
index 94c8d91e4b..3f2f3aa1a7 100644
--- a/var/spack/repos/builtin/packages/perl/package.py
+++ b/var/spack/repos/builtin/packages/perl/package.py
@@ -118,13 +118,13 @@ def setup_environment(self, spack_env, run_env):
         """Set PERL5LIB to support activation of Perl packages"""
         run_env.set('PERL5LIB', join_path(self.prefix, 'lib', 'perl5'))
 
-    def setup_dependent_environment(self, spack_env, run_env, extension_spec):
+    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
         """Set PATH and PERL5LIB to include the extension and
            any other perl extensions it depends on,
            assuming they were installed with INSTALL_BASE defined."""
         perl_lib_dirs = []
         perl_bin_dirs = []
-        for d in extension_spec.traverse(
+        for d in dependent_spec.traverse(
                 deptype=('build', 'run'), deptype_query='run'):
             if d.package.extends(self.spec):
                 perl_lib_dirs.append(join_path(d.prefix, 'lib', 'perl5'))
@@ -136,7 +136,7 @@ def setup_dependent_environment(self, spack_env, run_env, extension_spec):
         run_env.prepend_path('PATH', perl_bin_path)
         run_env.prepend_path('PERL5LIB', perl_lib_path)
 
-    def setup_dependent_package(self, module, ext_spec):
+    def setup_dependent_package(self, module, dependent_spec):
         """Called before perl modules' install() methods.
            In most cases, extensions will only need to have one line:
            perl('Makefile.PL','INSTALL_BASE=%s' % self.prefix)
@@ -146,9 +146,9 @@ def setup_dependent_package(self, module, ext_spec):
         module.perl = Executable(join_path(self.spec.prefix.bin, 'perl'))
 
         # Add variables for library directory
-        module.perl_lib_dir = join_path(ext_spec.prefix, 'lib', 'perl5')
+        module.perl_lib_dir = join_path(dependent_spec.prefix, 'lib', 'perl5')
 
         # Make the site packages directory for extensions,
         # if it does not exist already.
-        if ext_spec.package.is_extension:
+        if dependent_spec.package.is_extension:
             mkdirp(module.perl_lib_dir)
diff --git a/var/spack/repos/builtin/packages/qbank/package.py b/var/spack/repos/builtin/packages/qbank/package.py
new file mode 100644
index 0000000000..976bda8fbd
--- /dev/null
+++ b/var/spack/repos/builtin/packages/qbank/package.py
@@ -0,0 +1,87 @@
+##############################################################################
+# 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 *
+import os
+
+
+class Qbank(Package):
+    """QBank is a unique dynamic reservation-based allocation management system
+    that manages the utilization of computational resources in a multi-project
+    environment. It is used in conjunction with a resource management system
+    allowing an organization to guarantee greater fairness and enforce mission
+    priorities by associating a charge with the use of computational resources
+    and allocating resource credits which limit how much of the resources may
+    be used at what time and by whom. It tracks resource utilization and allows
+    for insightful planning."""
+
+    # QBank is so old that it no longer has (never had?) a homepage
+    # but it was developed at Pacific Northwest National Laboratory
+    # by Scott Jackson <Scott.Jackson@pnl.gov>
+    homepage = "http://www.pnnl.gov/"
+    url      = "file://{0}/qbank-2.10.4.tar.gz".format(os.getcwd())
+
+    version('2.10.4', '0820587353e63d32ddb49689dd4289e7')
+
+    variant('doc', default=False, description='Build documentation')
+
+    depends_on('openssl')
+
+    depends_on('perl@5.6:5.16',  type=('build', 'run'))
+    depends_on('perl-dbi@1.00:', type=('build', 'run'))
+
+    phases = ['configure', 'build', 'install']
+
+    def configure_args(self):
+        prefix = self.prefix
+
+        config_args = [
+            '--prefix', prefix,
+            '--logdir', join_path(prefix, 'var', 'log', 'qbank')
+        ]
+
+        return config_args
+
+    def configure(self, spec, prefix):
+        perl = which('perl')
+        perl('configure', *self.configure_args())
+
+    def build(self, spec, prefix):
+        make()
+
+        if '+doc' in spec:
+            make('docs')
+
+    def install(self, spec, prefix):
+        make('install')
+
+        if '+doc' in spec:
+            install_tree('doc', join_path(prefix, 'doc'))
+
+    def setup_environment(self, spack_env, run_env):
+        spec = self.spec
+        prefix = self.prefix
+
+        if '+doc' in spec:
+            run_env.prepend_path('MANPATH', join_path(prefix, 'doc'))
-- 
GitLab