示例#1
0
 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')
示例#2
0
 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/*''')
示例#3
0
 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 && \
 apt-get install -y --no-install-recommends \
     example && \
 rm -rf /var/lib/apt/lists/*''')