summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Sternberg <sternberg@anl.gov>2018-08-30 00:04:14 -0500
committerscheibelp <scheibel1@llnl.gov>2018-08-29 22:04:14 -0700
commitd95fdc8441550a6d583c3e3a3d62111cf02fb531 (patch)
tree814be005ba6e21f6abc34852f77bedf2a0026ffa /lib
parenta86f22d755887c66b03b62c8be2fa708b79fad0a (diff)
downloadspack-d95fdc8441550a6d583c3e3a3d62111cf02fb531.tar.gz
spack-d95fdc8441550a6d583c3e3a3d62111cf02fb531.tar.bz2
spack-d95fdc8441550a6d583c3e3a3d62111cf02fb531.tar.xz
spack-d95fdc8441550a6d583c3e3a3d62111cf02fb531.zip
Update instructions to initialize Spack-global license files (#8991)
* Suggest adding contents before the explanatory comment to avoid issue #6534 * Mention that the license file may not need to be edited
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/hooks/licensing.py99
1 files changed, 55 insertions, 44 deletions
diff --git a/lib/spack/spack/hooks/licensing.py b/lib/spack/spack/hooks/licensing.py
index 1421663f96..2b4f78091c 100644
--- a/lib/spack/spack/hooks/licensing.py
+++ b/lib/spack/spack/hooks/licensing.py
@@ -85,63 +85,74 @@ def write_license_file(pkg, license_path):
Comments give suggestions on alternative methods of
installing a license."""
- comment = pkg.license_comment
+ # License files
+ linktargets = ""
+ for f in pkg.license_files:
+ linktargets += "\t%s\n" % f
- # Global license directory may not already exist
- if not os.path.exists(os.path.dirname(license_path)):
- os.makedirs(os.path.dirname(license_path))
- license = open(license_path, 'w')
+ # Environment variables
+ envvars = ""
+ if pkg.license_vars:
+ for varname in pkg.license_vars:
+ envvars += "\t%s\n" % varname
- # License files
- license.write("""\
-{0} A license is required to use {1}.
-{0}
-{0} The recommended solution is to store your license key in this global
-{0} license file. After installation, the following symlink(s) will be
-{0} added to point to this file (relative to the installation prefix):
-{0}
-""".format(comment, pkg.name))
+ # Documentation
+ url = ""
+ if pkg.license_url:
+ url += "\t%s\n" % pkg.license_url
- for filename in pkg.license_files:
- license.write("{0}\t{1}\n".format(comment, filename))
+ # Assemble. NB: pkg.license_comment will be prepended upon output.
+ txt = """
+ A license is required to use package '{0}'.
- license.write("{0}\n".format(comment))
+ * If your system is already properly configured for such a license, save this
+ file UNCHANGED. The system may be configured if:
- # Environment variables
- if pkg.license_vars:
- license.write("""\
-{0} Alternatively, use one of the following environment variable(s):
-{0}
-""".format(comment))
+ - A license file is installed in a default location.
+""".format(pkg.name)
- for var in pkg.license_vars:
- license.write("{0}\t{1}\n".format(comment, var))
+ if envvars:
+ txt += """\
+ - One of the following environment variable(s) is set for you, possibly via
+ a module file:
- 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, pkg.name))
+""".format(envvars)
+
+ txt += """\
+ * Otherwise, depending on the license you have, enter AT THE BEGINNING of
+ this file:
+
+ - the contents of your license file, or
+ - the address(es) of your license server.
+
+ After installation, the following symlink(s) will be added to point to
+ this Spack-global file (relative to the installation prefix).
- # Documentation
- if pkg.license_url:
- license.write("""\
-{0} For further information on how to acquire a license, please refer to:
-{0}
-{0}\t{1}
{0}
-""".format(comment, pkg.license_url))
+""".format(linktargets)
+
+ if url:
+ txt += """\
+ * For further information on licensing, see:
- license.write("""\
-{0} You may enter your license below.
+{0}
+""".format(url)
-""".format(comment))
+ txt += """\
+ Recap:
+ - You may not need to modify this file at all.
+ - Otherwise, enter your license or server address AT THE BEGINNING.
+"""
+ # Global license directory may not already exist
+ if not os.path.exists(os.path.dirname(license_path)):
+ os.makedirs(os.path.dirname(license_path))
- license.close()
+ # Output
+ with open(license_path, 'w') as f:
+ for line in txt.splitlines():
+ f.write("{0}{1}\n".format(pkg.license_comment, line))
+ f.close()
def post_install(spec):