Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_detect_ubuntu_16(self):
"""Base image Linux distribution detection"""
b = baseimage(image='ubuntu:16.04')
self.assertEqual(hpccm.config.g_linux_distro, linux_distro.UBUNTU)
self.assertEqual(hpccm.config.g_linux_version, StrictVersion('16.04'))
def __instructions(self):
"""String representation of the building block"""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if self.__apt:
ospackages = self.__apt
else:
ospackages = self.__ospackages
self += apt_get(aptitude=self.__aptitude,
download=self.__download,
download_directory=self.__download_directory,
extra_opts=self.__extra_opts,
extract=self.__extract,
keys=self.__apt_keys,
ospackages=ospackages,
ppas=self.__apt_ppas,
repositories=self.__apt_repositories)
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if self.__yum:
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__ospackages:
self.__ospackages = ['file', 'hwloc', 'libevent-dev', 'make',
'tar', 'wget']
if self.__check:
self.__ospackages.append('perl')
self.__runtime_ospackages = ['libevent-2.*',
'libevent-pthreads-2.*']
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__ospackages:
self.__ospackages = ['file', 'hwloc', 'libevent-devel', 'make',
'tar', 'wget']
if self.__check:
self.__ospackages.append('perl')
self.__runtime_ospackages = ['libevent']
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__ospackages:
self.__ospackages = ['bzip2', 'file', 'make', 'wget',
'zlib1g-dev']
self.__runtime_ospackages = ['zlib1g']
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__ospackages:
self.__ospackages = ['bzip2', 'file', 'make', 'wget',
'zlib-devel']
if self.__check:
self.__ospackages.append('diffutils')
self.__runtime_ospackages = ['zlib']
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__ospackages:
self.__ospackages = ['apt-transport-https', 'ca-certificates',
'gcc', 'gnupg', 'man-db',
'openssh-client', 'wget']
self.__bashrc = '/etc/bash.bashrc'
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__ospackages:
self.__ospackages = ['man-db', 'openssh-clients', 'which']
self.__bashrc = '/etc/bashrc'
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__oslabel:
if hpccm.config.g_linux_version >= StrictVersion('18.0'):
self.__oslabel = 'ubuntu18.04'
else:
self.__oslabel = 'ubuntu16.04'
if not self.__ospackages:
self.__ospackages = ['bzip2', 'openssh-client', 'tar', 'wget']
self.__bashrc = '/etc/bash.bashrc'
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__oslabel:
if hpccm.config.g_linux_version >= StrictVersion('8.0'):
self.__oslabel = 'redhat8.0'
else:
self.__oslabel = 'redhat7.6'
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__ospackages:
self.__ospackages = ['libhwloc-dev', 'make']
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__ospackages:
self.__ospackages = ['hwloc-devel', 'make']
if hpccm.config.g_linux_version >= StrictVersion('8.0'):
# hwloc-devel is in the CentOS powertools repository
self.__powertools = True
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
if self.repository:
self.__ospackages.extend(['ca-certificates', 'git'])
else:
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
self.__deppackages = ['libnl-3-200', 'libnl-route-3-200',
'libnuma1']
if hpccm.config.g_linux_version >= StrictVersion('18.0'):
# Give priority to packages from the Ubuntu repositories over
# vendor repositories
self.__extra_opts = ['-t bionic']
self.__ospackages= ['dapl2-utils', 'ibutils',
'ibverbs-providers', 'ibverbs-utils',
'infiniband-diags',
'libdapl2', 'libdapl-dev',
'libibmad5', 'libibmad-dev',
'libibverbs1', 'libibverbs-dev',
'librdmacm1', 'librdmacm-dev',
'rdmacm-utils']
def __distro(self):
"""Based on the Linux distribution, set values accordingly. A user
specified value overrides any defaults."""
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if not self.__ospackages:
self.__ospackages = ['byacc', 'file', 'make',
'openssh-client', 'wget']
self.__runtime_ospackages = ['openssh-client']
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
if not self.__ospackages:
self.__ospackages = ['byacc', 'file', 'make',
'openssh-clients', 'wget']
self.__runtime_ospackages = ['openssh-clients']
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
if self.__source:
# Build dependencies
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
self.__ospackages = ['bzip2', 'file', 'gcc', 'g++', 'git',
'make', 'perl', 'tar', 'wget', 'xz-utils']
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
self.__ospackages = ['bzip2', 'file', 'gcc', 'gcc-c++', 'git',
'make', 'perl', 'tar', 'wget', 'xz']
else: # pragma: no cover
raise RuntimeError('Unknown Linux distribution')
elif self.__version and not self.__source:
# Setup the environment so that the alternate compiler version
# is the new default
alternatives = {}
if hpccm.config.g_linux_distro == linux_distro.UBUNTU:
if self.__cc:
alternatives['gcc'] = '$(which gcc-{})'.format(
self.__version)
if self.__cxx:
alternatives['g++'] = '$(which g++-{})'.format(
self.__version)
if self.__fortran:
alternatives['gfortran'] = '$(which gfortran-{})'.format(
self.__version)
alternatives['gcov'] = '$(which gcov-{})'.format(
self.__version)
elif hpccm.config.g_linux_distro == linux_distro.CENTOS:
# Default for CentOS 7
toolset_path = '/opt/rh/devtoolset-{}/root/usr/bin'.format(
self.__version)
if hpccm.config.g_linux_version >= StrictVersion('8.0'):