Allow license files to use different symbols for comments

This commit is contained in:
Adam J. Stewart 2016-04-05 11:00:55 -05:00
parent b63d11d5b0
commit 6906911e85
3 changed files with 56 additions and 30 deletions

View File

@ -378,6 +378,9 @@ def __init__(self, spec):
if not hasattr(self, 'license_required'): if not hasattr(self, 'license_required'):
self.license_required = False self.license_required = False
if not hasattr(self, 'license_comment'):
self.license_comment = '#'
if not hasattr(self, 'license_files'): if not hasattr(self, 'license_files'):
self.license_files = [] self.license_files = []
@ -1040,46 +1043,59 @@ def set_up_license(self):
def write_license_file(self, license_path): 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 = open(license_path, 'w')
license.write("""\ license.write("""\
# A license is required to use %s. {0} A license is required to use {1}.
# {0}
# The recommended solution is to store your license key in this file. {0} The recommended solution is to store your license key in this file.
# By default, %s searches the following file(s) for a license key {0} By default, {1} searches the following file(s) for a license key
# (relative to the installation prefix): {0} (relative to the installation prefix):
# {0}
#\t%s """.format(comment, self.name))
#
""" % (self.name, self.name, '\n#\t'.join(self.license_files))) 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: if self.license_vars:
license.write("""\ license.write("""\
# Alternatively, use one of the following environment variable(s): {0} Alternatively, use one of the following environment variable(s):
# {0}
#\t%s """.format(comment))
#
# If you choose to store your license in a non-standard location, you may for var in self.license_vars:
# set one of these variable(s) to the full pathname to the license file, or license.write("{0}\t{1}\n".format(comment, var))
# 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 license.write("""\
# gets loaded every time someone tries to use %s. {0}
# {0} If you choose to store your license in a non-standard location, you may
""" % ('\n#\t'.join(self.license_vars), self.name)) {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: if self.license_url:
license.write("""\ license.write("""\
# For further information on how to acquire a license, please refer to: {0} For further information on how to acquire a license, please refer to:
# {0}
#\t%s {0}\t{1}
# {0}
""" % self.license_url) """.format(comment, self.license_url))
license.write("""\ license.write("""\
# You may enter your license below. {0} You may enter your license below.
""") """.format(comment))
license.close() license.close()

View File

@ -5,17 +5,26 @@ class Nag(Package):
"""The NAG Fortran Compiler.""" """The NAG Fortran Compiler."""
homepage = "http://www.nag.com/nagware/np.asp" homepage = "http://www.nag.com/nagware/np.asp"
version('6.1', '1e29d9d435b7ccc2842a320150b28ba4', version('6.1', '1e29d9d435b7ccc2842a320150b28ba4')
url='http://www.nag.com/downloads/impl/npl6a61na_amd64.tgz') version('6.0', '3fa1e7f7b51ef8a23e6c687cdcad9f96')
# Licensing # Licensing
license_required = True license_required = True
license_comment = '!'
license_files = ['lib/nag.key', license_files = ['lib/nag.key',
'lib/nag.licence', 'lib/nag.licence',
'lib/nagware.licence'] 'lib/nagware.licence']
license_vars = ['NAG_KUSARI_FILE'] license_vars = ['NAG_KUSARI_FILE']
license_url = 'http://www.nag.com/doc/inun/np61/lin-mac/klicence.txt' 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): def install(self, spec, prefix):
# Set installation directories # Set installation directories
os.environ['INSTALL_TO_BINDIR'] = prefix.bin os.environ['INSTALL_TO_BINDIR'] = prefix.bin

View File

@ -27,6 +27,7 @@ class Pgi(Package):
# Licensing # Licensing
license_required = True license_required = True
license_comment = '#'
license_files = ['license.dat'] license_files = ['license.dat']
license_vars = ['PGROUPD_LICENSE_FILE', 'LM_LICENSE_FILE'] license_vars = ['PGROUPD_LICENSE_FILE', 'LM_LICENSE_FILE']
license_url = 'http://www.pgroup.com/doc/pgiinstall.pdf' license_url = 'http://www.pgroup.com/doc/pgiinstall.pdf'