Merge pull request #1163 from epfl-scitas/fixes/reserved_name_for_system_packages

fixes : reserved name for system packages
This commit is contained in:
Todd Gamblin 2016-07-04 21:25:50 -07:00 committed by GitHub
commit f2a692c515

View File

@ -35,7 +35,7 @@ class Openssl(Package):
Transport Layer Security (TLS v1) protocols as well as a Transport Layer Security (TLS v1) protocols as well as a
full-strength general purpose cryptography library.""" full-strength general purpose cryptography library."""
homepage = "http://www.openssl.org" homepage = "http://www.openssl.org"
url = "https://www.openssl.org/source/openssl-1.0.1h.tar.gz" url = "https://www.openssl.org/source/openssl-1.0.1h.tar.gz"
version('1.0.1h', '8d6d684a9430d5cc98a62a5d8fbda8cf') version('1.0.1h', '8d6d684a9430d5cc98a62a5d8fbda8cf')
version('1.0.1r', '1abd905e079542ccae948af37e393d28') version('1.0.1r', '1abd905e079542ccae948af37e393d28')
@ -50,21 +50,24 @@ class Openssl(Package):
parallel = False parallel = False
def url_for_version(self, version): def url_for_version(self, version):
# This URL is computed pinging the place where the latest version is stored. To avoid slowdown # This URL is computed pinging the place where the latest version is
# due to repeated pinging, we store the URL in a private class attribute to do the job only once per version # 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_urls = getattr(Openssl, '_openssl_url', {})
openssl_url = openssl_urls.get(version, None) openssl_url = openssl_urls.get(version, None)
# Same idea, but just to avoid issuing the same message multiple times # Same idea, but just to avoid issuing the same message multiple times
warnings_given_to_user = getattr(Openssl, '_warnings_given', {}) warnings_given_to_user = getattr(Openssl, '_warnings_given', {})
if openssl_url is None: if openssl_url is None:
if self.spec.satisfies('@external'): if self.spec.satisfies('@system'):
# The version @external is reserved to system openssl. In that case return a fake url and exit # The version @system is reserved to system openssl. In that
openssl_url = '@external (reserved version for system openssl)' # case return a fake url and exit
openssl_url = '@system (reserved version for system openssl)'
if not warnings_given_to_user.get(version, False): if not warnings_given_to_user.get(version, False):
tty.msg('Using openssl@external : the version @external is reserved for system openssl') tty.msg('Using openssl@system : the version @system is reserved for system openssl') # NOQA: ignore=E501
warnings_given_to_user[version] = True warnings_given_to_user[version] = True
else: else:
openssl_url = self.check_for_outdated_release(version, warnings_given_to_user) # Store the computed URL openssl_url = self.check_for_outdated_release(
version, warnings_given_to_user) # Store the computed URL
openssl_urls[version] = openssl_url openssl_urls[version] = openssl_url
# Store the updated dictionary of URLS # Store the updated dictionary of URLS
Openssl._openssl_url = openssl_urls Openssl._openssl_url = openssl_urls
@ -75,22 +78,23 @@ def url_for_version(self, version):
def check_for_outdated_release(self, version, warnings_given_to_user): def check_for_outdated_release(self, version, warnings_given_to_user):
latest = 'ftp://ftp.openssl.org/source/openssl-{version}.tar.gz' latest = 'ftp://ftp.openssl.org/source/openssl-{version}.tar.gz'
older = 'http://www.openssl.org/source/old/{version_number}/openssl-{version_full}.tar.gz' older = 'http://www.openssl.org/source/old/{version_number}/openssl-{version_full}.tar.gz' # NOQA: ignore=E501
# Try to use the url where the latest tarballs are stored. If the url does not exist (404), then # Try to use the url where the latest tarballs are stored.
# return the url for older format # If the url does not exist (404), then return the url for
# older format
version_number = '.'.join([str(x) for x in version[:-1]]) version_number = '.'.join([str(x) for x in version[:-1]])
try: try:
openssl_url = latest.format(version=version) openssl_url = latest.format(version=version)
urllib.urlopen(openssl_url) urllib.urlopen(openssl_url)
except IOError: except IOError:
openssl_url = older.format(version_number=version_number, version_full=version) openssl_url = older.format(version_number=version_number, version_full=version) # NOQA:ignore=E501
# Checks if we already warned the user for this particular version of OpenSSL. # Checks if we already warned the user for this particular
# If not we display a warning message and mark this version # version of OpenSSL. If not we display a warning message
# and mark this version
if not warnings_given_to_user.get(version, False): if not warnings_given_to_user.get(version, False):
tty.warn( tty.warn('This installation depends on an old version of OpenSSL, which may have known security issues. ') # NOQA: ignore=E501
'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.') # NOQA: ignore=E501
tty.warn('Consider updating to the latest version of this package.') tty.warn('More details at {homepage}'.format(homepage=Openssl.homepage)) # NOQA: ignore=E501
tty.warn('More details at {homepage}'.format(homepage=Openssl.homepage))
warnings_given_to_user[version] = True warnings_given_to_user[version] = True
return openssl_url return openssl_url