From 6906911e85f5df504ef0a039ac510822eafc3643 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Tue, 5 Apr 2016 11:00:55 -0500 Subject: Allow license files to use different symbols for comments --- lib/spack/spack/package.py | 72 +++++++++++++++---------- var/spack/repos/builtin/packages/nag/package.py | 13 ++++- var/spack/repos/builtin/packages/pgi/package.py | 1 + 3 files changed, 56 insertions(+), 30 deletions(-) diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index 6d425c3dc7..322cf502a6 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -378,6 +378,9 @@ class Package(object): if not hasattr(self, 'license_required'): self.license_required = False + if not hasattr(self, 'license_comment'): + self.license_comment = '#' + if not hasattr(self, 'license_files'): self.license_files = [] @@ -1040,46 +1043,59 @@ class Package(object): def write_license_file(self, license_path): - # Use the first file listed in license_files + """Writes empty license file. + + Comments give suggestions on alternative methods of installing + a license.""" + + comment = self.license_comment license = open(license_path, 'w') license.write("""\ -# A license is required to use %s. -# -# The recommended solution is to store your license key in this file. -# By default, %s searches the following file(s) for a license key -# (relative to the installation prefix): -# -#\t%s -# -""" % (self.name, self.name, '\n#\t'.join(self.license_files))) +{0} A license is required to use {1}. +{0} +{0} The recommended solution is to store your license key in this file. +{0} By default, {1} searches the following file(s) for a license key +{0} (relative to the installation prefix): +{0} +""".format(comment, self.name)) + + for filename in self.license_files: + license.write("{0}\t{1}\n".format(comment, filename)) + + license.write("{0}\n".format(comment)) if self.license_vars: license.write("""\ -# Alternatively, use one of the following environment variable(s): -# -#\t%s -# -# If you choose to store your license in a non-standard location, you may -# set one of these variable(s) to the full pathname to the license file, or -# port@host if you store your license keys on a dedicated license server. -# You will likely want to set this variable in a module file so that it -# gets loaded every time someone tries to use %s. -# -""" % ('\n#\t'.join(self.license_vars), self.name)) +{0} Alternatively, use one of the following environment variable(s): +{0} +""".format(comment)) + + for var in self.license_vars: + license.write("{0}\t{1}\n".format(comment, var)) + + license.write("""\ +{0} +{0} If you choose to store your license in a non-standard location, you may +{0} set one of these variable(s) to the full pathname to the license file, or +{0} port@host if you store your license keys on a dedicated license server. +{0} You will likely want to set this variable in a module file so that it +{0} gets loaded every time someone tries to use {1}. +{0} +""".format(comment, self.name)) if self.license_url: license.write("""\ -# For further information on how to acquire a license, please refer to: -# -#\t%s -# -""" % self.license_url) +{0} For further information on how to acquire a license, please refer to: +{0} +{0}\t{1} +{0} +""".format(comment, self.license_url)) license.write("""\ -# You may enter your license below. +{0} You may enter your license below. -""") +""".format(comment)) license.close() diff --git a/var/spack/repos/builtin/packages/nag/package.py b/var/spack/repos/builtin/packages/nag/package.py index 840b79c66b..c6c33ecad5 100644 --- a/var/spack/repos/builtin/packages/nag/package.py +++ b/var/spack/repos/builtin/packages/nag/package.py @@ -5,17 +5,26 @@ class Nag(Package): """The NAG Fortran Compiler.""" homepage = "http://www.nag.com/nagware/np.asp" - version('6.1', '1e29d9d435b7ccc2842a320150b28ba4', - url='http://www.nag.com/downloads/impl/npl6a61na_amd64.tgz') + version('6.1', '1e29d9d435b7ccc2842a320150b28ba4') + version('6.0', '3fa1e7f7b51ef8a23e6c687cdcad9f96') # Licensing license_required = True + license_comment = '!' license_files = ['lib/nag.key', 'lib/nag.licence', 'lib/nagware.licence'] license_vars = ['NAG_KUSARI_FILE'] license_url = 'http://www.nag.com/doc/inun/np61/lin-mac/klicence.txt' + + def url_for_version(self, version): + # TODO: url and checksum are architecture dependent + # TODO: We currently only support x86_64 + return 'http://www.nag.com/downloads/impl/npl6a%sna_amd64.tgz' % \ + str(version).replace('.', '') + + def install(self, spec, prefix): # Set installation directories os.environ['INSTALL_TO_BINDIR'] = prefix.bin diff --git a/var/spack/repos/builtin/packages/pgi/package.py b/var/spack/repos/builtin/packages/pgi/package.py index 649c7dbee2..095569a2a9 100644 --- a/var/spack/repos/builtin/packages/pgi/package.py +++ b/var/spack/repos/builtin/packages/pgi/package.py @@ -27,6 +27,7 @@ class Pgi(Package): # Licensing license_required = True + license_comment = '#' license_files = ['license.dat'] license_vars = ['PGROUPD_LICENSE_FILE', 'LM_LICENSE_FILE'] license_url = 'http://www.pgroup.com/doc/pgiinstall.pdf' -- cgit v1.2.3-70-g09d2