def __str__(self): """String representation of the building block""" if hpccm.config.g_linux_distro == linux_distro.UBUNTU: if self.__apt: return str( apt_get(keys=self.__apt_keys, ospackages=self.__apt, ppas=self.__apt_ppas, repositories=self.__apt_repositories)) else: return str( apt_get(keys=self.__apt_keys, ospackages=self.__ospackages, ppas=self.__apt_ppas, repositories=self.__apt_repositories)) elif hpccm.config.g_linux_distro == linux_distro.CENTOS: if self.__yum: return str( yum(epel=self.__epel, keys=self.__yum_keys, ospackages=self.__yum, scl=self.__scl, repositories=self.__yum_repositories)) else: return str( yum(epel=self.__epel, keys=self.__yum_keys, ospackages=self.__ospackages, scl=self.__scl, repositories=self.__yum_repositories)) else: raise RuntimeError('Unknown Linux distribution')
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, 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: ospackages = self.__yum else: ospackages = self.__ospackages self += yum(download=self.__download, download_directory=self.__download_directory, extract=self.__extract, epel=self.__epel, keys=self.__yum_keys, ospackages=ospackages, powertools=self.__powertools, release_stream=self.__release_stream, scl=self.__scl, repositories=self.__yum_repositories, yum4=self.__yum4) else: raise RuntimeError('Unknown Linux distribution')
def test_basic(self): """Basic apt_get""" a = apt_get(ospackages=['gcc', 'g++', 'gfortran']) self.assertEqual( str(a), r'''RUN apt-get update -y && \ apt-get install -y --no-install-recommends \ gcc \ g++ \ gfortran && \ rm -rf /var/lib/apt/lists/*''')
def test_download(self): """Download parameter""" a = apt_get(download=True, download_directory='/tmp/download', ospackages=['libibverbs1']) self.assertEqual(str(a), r'''RUN apt-get update -y && \ mkdir -m 777 -p /tmp/download && cd /tmp/download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ libibverbs1 && \ rm -rf /var/lib/apt/lists/*''')
def test_add_repo(self): """Add repo and key""" a = apt_get(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['deb http://www.example.com all main']) self.assertEqual(str(a), r'''RUN wget -qO - https://www.example.com/key.pub | apt-key add - && \ echo "deb http://www.example.com all main" >> /etc/apt/sources.list.d/hpccm.list && \ apt-get update -y && \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ example && \ rm -rf /var/lib/apt/lists/*''')
def test_extract(self): """Extract parameter""" a = apt_get(download=True, extract='/usr/local/ofed', ospackages=['libibverbs1']) self.assertEqual(str(a), r'''RUN apt-get update -y && \ mkdir -m 777 -p /var/tmp/apt_get_download && cd /var/tmp/apt_get_download && \ DEBIAN_FRONTEND=noninteractive apt-get download -y --no-install-recommends \ libibverbs1 && \ mkdir -p /usr/local/ofed && \ find /var/tmp/apt_get_download -regextype posix-extended -type f -regex "/var/tmp/apt_get_download/(libibverbs1).*deb" -exec dpkg --extract {} /usr/local/ofed \; && \ rm -rf /var/tmp/apt_get_download && \ rm -rf /var/lib/apt/lists/*''')