summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2016-02-19 16:28:02 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2016-02-19 16:28:02 -0800
commit97c3854c4044a71cf756d9164684fa553915f6ab (patch)
tree79502627f79a179bbc891f0a64973dc19d6db3f2
parent3c1aa9a4addc722423918593a227a8ca16c1c4e6 (diff)
parent587d356d6ec8820cf04043b3650ac66b82a651b2 (diff)
downloadspack-97c3854c4044a71cf756d9164684fa553915f6ab.tar.gz
spack-97c3854c4044a71cf756d9164684fa553915f6ab.tar.bz2
spack-97c3854c4044a71cf756d9164684fa553915f6ab.tar.xz
spack-97c3854c4044a71cf756d9164684fa553915f6ab.zip
Merge pull request #422 from epfl-scitas/packages/openssl_url
openssl : url computation
-rw-r--r--var/spack/repos/builtin/packages/openssl/package.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/var/spack/repos/builtin/packages/openssl/package.py b/var/spack/repos/builtin/packages/openssl/package.py
index a225e30f6c..c73102f05d 100644
--- a/var/spack/repos/builtin/packages/openssl/package.py
+++ b/var/spack/repos/builtin/packages/openssl/package.py
@@ -1,3 +1,6 @@
+import urllib
+import llnl.util.tty as tty
+
from spack import *
class Openssl(Package):
@@ -18,6 +21,42 @@ class Openssl(Package):
depends_on("zlib")
parallel = False
+ def url_for_version(self, version):
+ # This URL is computed pinging the place where the latest version is stored. To avoid slowdown
+ # due to repeated pinging, we store the URL in a private class attribute to do the job only once per version
+ openssl_urls = getattr(Openssl, '_openssl_url', {})
+ openssl_url = openssl_urls.get(version, None)
+ # Same idea, but just to avoid issuing the same message multiple times
+ warnings_given_to_user = getattr(Openssl, '_warnings_given', {})
+ if openssl_url is None:
+ latest = 'http://www.openssl.org/source/openssl-{version}.tar.gz'
+ older = 'http://www.openssl.org/source/old/{version_number}/openssl-{version_full}.tar.gz'
+ # Try to use the url where the latest tarballs are stored. If the url does not exist (404), then
+ # return the url for older format
+ version_number = '.'.join([str(x) for x in version[:-1]])
+ older_url = older.format(version_number=version_number, version_full=version)
+ latest_url = latest.format(version=version)
+ response = urllib.urlopen(latest.format(version=version))
+ if response.getcode() == 404:
+ openssl_url = older_url
+ # Checks if we already warned the user for this particular version of OpenSSL.
+ # If not we display a warning message and mark this version
+ if not warnings_given_to_user.get(version, False):
+ tty.warn('This installation depends on an old version of OpenSSL, which may have known security issues. ')
+ tty.warn('Consider updating to the latest version of this package.')
+ tty.warn('More details at {homepage}'.format(homepage=Openssl.homepage))
+ warnings_given_to_user[version] = True
+ else:
+ openssl_url = latest_url
+ # Store the computed URL
+ openssl_urls[version] = openssl_url
+ # Store the updated dictionary of URLS
+ Openssl._openssl_url = openssl_urls
+ # Store the updated dictionary of warnings
+ Openssl._warnings_given = warnings_given_to_user
+
+ return openssl_url
+
def install(self, spec, prefix):
# OpenSSL uses a variable APPS in its Makefile. If it happens to be set
# in the environment, then this will override what is set in the