kolla/docker/macros.j2
Marcin Juszkiewicz d2c8372e99 make yum fail on missing packages
By default yum skips missing packages. As a result built images may not
contain what we expect them to have (often found on non-x86
architectures).

There is an option to make it fail in same way as APT does in Debian
world. And this patch makes use of it so broken images just fail:

INFO:kolla.image.build.openstack-base:No package Percona-Server-shared-56 available.
INFO:kolla.image.build.openstack-base:Error: Not tolerating missing names on install, stopping.
INFO:kolla.image.build.openstack-base:
INFO:kolla.image.build.openstack-base:Removing intermediate container d5e506330b08
ERROR:kolla.image.build.openstack-base:Error'd with the following message

Closes-Bug: #1675401

Change-Id: Ib6b9e6b8cc216ce283cd043fa3600db7c0cc2a98
2017-03-29 12:18:30 +02:00

62 lines
2.3 KiB
Django/Jinja

{% macro install_packages(packages) -%}
{% if packages is defined and packages|length > 0 -%}
{% if base_distro in ['centos', 'oraclelinux', 'rhel'] -%}
RUN yum --setopt skip_missing_names_on_install=False -y install {{ packages | join(' ') }} && yum clean all
{%- elif base_distro in ['ubuntu', 'debian'] -%}
{#-
debian_package_install is a utility method to build up an appropriate
set of commands to install packages in a debian-based environment that
may include URL links to a .deb package (e.g, heka)
-#}
RUN {{ debian_package_install(packages) }}
{%- endif %}
{%- endif %}
{%- endmacro %}
{% macro install_pip(packages, constraints = true) %}
{%- if packages is sequence and packages|length > 0 -%}
pip --no-cache-dir install --upgrade{{ ' ' }}
{%- if constraints %}-c requirements/upper-constraints.txt {% endif -%}
{{ packages | join(' ') }}
{%- else -%}
true
{%- endif -%}
{% endmacro %}
{% macro configure_user(name, groups=None, shell=None, homedir=None) %}
{% set user=users[name] %}
{%- if not homedir %}
{% set homedir='/var/lib/' + name %}
{%- endif %}
RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \
{%- if groups %}
&& usermod --append --groups {{ groups }} {{ name }} \
{%- endif %}
{%- if shell %}
&& chsh --shell {{ shell }} {{ name }} \
{%- endif %}
&& mkdir -p {{ homedir }} \
&& chown -R {{ user.uid }}:{{ user.gid }} {{ homedir }}
{% endmacro %}
{% macro ubuntu_trove_bug_1651852() %}
{# NOTE(SamYaple): The postinst script breaks because it calls getenv instead of getent #}
{# TODO(SamYaple): Remove once issue is fixed -- https://bugs.launchpad.net/ubuntu/+source/openstack-trove/+bug/1651852 #}
RUN apt-get -y install --no-install-recommends trove-common \
|| sed -i 's/getenv/getent/g' /var/lib/dpkg/info/trove-common.postinst \
&& apt-get -y install -f \
&& apt-get clean
{% endmacro %}
{% macro debian_haproxy_existing_user_fix() %}
{# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #}
RUN apt-get -y install --no-install-recommends haproxy \
|| sed -i '/^adduser/,+1 d' /var/lib/dpkg/info/haproxy.postinst \
&& apt-get -y install -f \
&& apt-get clean
{% endmacro %}