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(ospackages=self.__apt)) else: return str(apt_get(ospackages=self.__ospackages)) elif hpccm.config.g_linux_distro == linux_distro.CENTOS: if self.__yum: return str(yum(epel=self.__epel, ospackages=self.__yum)) else: return str(yum(epel=self.__epel, ospackages=self.__ospackages)) else: raise RuntimeError('Unknown Linux distribution')
def test_basic(self): """Basic yum""" y = yum(ospackages=['gcc', 'gcc-c++', 'gcc-fortran']) self.assertEqual(str(y), r'''RUN yum install -y \ gcc \ gcc-c++ \ gcc-fortran && \ rm -rf /var/cache/yum/*''')
def test_add_repo(self): """Add repo and key""" y = yum(keys=['https://www.example.com/key.pub'], ospackages=['example'], repositories=['http://www.example.com/example.repo']) self.assertEqual(str(y), r'''RUN rpm --import https://www.example.com/key.pub && \ yum-config-manager --add-repo http://www.example.com/example.repo && \ yum install -y \ example && \ rm -rf /var/cache/yum/*''')