always update APT lists when install packages

Normally we update APT lists when 'base' image is built. But when some
time pass those lists get out-of-date and images can not be built.

CentOS based images handle that without issues because YUM updates
repository data whenever they are out-of-date.

Change-Id: I5ba5b2067566639b399329b878027d4513567f71
This commit is contained in:
Marcin Juszkiewicz 2017-05-04 15:54:21 +02:00
parent 9751b32a7b
commit bfc72492e7
3 changed files with 4 additions and 4 deletions

View File

@ -24,8 +24,7 @@ COPY {{ opendaylight_repo }} /etc/yum.repos.d/
{% set odl_release_deb_url = 'http://download.opensuse.org/repositories/home:/akshitajha/Debian_8.0/' %} {% set odl_release_deb_url = 'http://download.opensuse.org/repositories/home:/akshitajha/Debian_8.0/' %}
{% endif %} {% endif %}
{% endif %} {% endif %}
RUN sh -c "echo 'deb {{ odl_release_deb_url }} /' > /etc/apt/sources.list.d/opendaylight.list" \ RUN sh -c "echo 'deb {{ odl_release_deb_url }} /' > /etc/apt/sources.list.d/opendaylight.list"
&& apt-get update
{% endif %} {% endif %}
{{ macros.install_packages(opendaylight_packages | customizable("packages")) }} {{ macros.install_packages(opendaylight_packages | customizable("packages")) }}

View File

@ -44,6 +44,7 @@ def debian_package_install(packages):
# handle the apt-get install # handle the apt-get install
if reg_packages: if reg_packages:
cmds.append('apt-get update')
cmds.append('apt-get -y install --no-install-recommends {}'.format( cmds.append('apt-get -y install --no-install-recommends {}'.format(
' '.join(reg_packages) ' '.join(reg_packages)
)) ))

View File

@ -19,5 +19,5 @@ class MethodsTest(base.TestCase):
def test_debian_package_install(self): def test_debian_package_install(self):
packages = ['https://packages.debian.org/package1.deb', 'package2.deb'] packages = ['https://packages.debian.org/package1.deb', 'package2.deb']
result = methods.debian_package_install(packages) result = methods.debian_package_install(packages)
expectCmd = 'apt-get -y install --no-install-recommends package2.deb ' expectCmd = 'apt-get -y install --no-install-recommends package2.deb'
self.assertEqual(expectCmd, result.split("&&")[0]) self.assertEqual(expectCmd, result.split("&&")[1].strip())