kolla/tests/templates/template_overrides.j2
Marcin Juszkiewicz 0c523e7f1b CI/centos/rocky: use repos from opendev mirror
Repo definitions in RHEL 9 rebuilds use metalink method for most of
entries which makes our use of sed obsolete.

This patch adds file with definitions of all CS9 repos we use and
moves all official definitions a side at start of build. After build our
definitions get removed and official ones are restored.

Similar is done for RockyLinux 9 builds but there RL9 repos are used
from official mirrors while CS9/EPEL ones are from OpenDev mirrors.

Final images will have repos in wrong enabled/disabled state.

Change-Id: I04121fd5ca9894b6deeda3808808cbffd6b97811
2022-10-03 15:29:05 +02:00

131 lines
3.8 KiB
Django/Jinja

{% raw %}
{% extends parent_template %}
{% block base_pip_conf %}
{% endraw %}
ENV PIP_INDEX_URL {{ nodepool_pypi_mirror }}
ENV PIP_TRUSTED_HOST {{ nodepool_mirror_host }}
{% if use_infra_wheels_mirror | default(true) %}
ENV PIP_EXTRA_INDEX_URL {{ nodepool_wheel_mirror }}
{% endif %}
RUN echo registry={{ nodepool_npmjs_proxy }} > /etc/npmrc \
&& mkdir -p /usr/etc \
&& ln -s /etc/npmrc /usr/etc/npmrc
{% raw %}
{% endblock %}
{% endraw %}
{% if base_distro in ['centos', 'rocky'] %}
{% if base_distro == 'centos' %}
{% raw %}
{% block base_centos_repo_overrides_post_copy %}
{% endraw %}
COPY ci-centos.repo /etc/yum.repos.d/
RUN cd /etc/yum.repos.d/ && mkdir not-for-ci/ && mv centos*.repo not-for-ci/ \
&& sed -i -e "s/MIRROR/{{ nodepool_mirror_host }}/g" /etc/yum.repos.d/ci-centos.repo
{% raw %}
{% endblock %}
{% endraw %}
{% elif base_distro == 'rocky' %}
{#
NOTE(hrw): Rocky is not mirrored but it uses CentOS repos which are
#}
{% raw %}
{% block base_centos_repo_overrides_post_copy %}
{% endraw %}
COPY ci-rocky.repo /etc/yum.repos.d/
RUN cd /etc/yum.repos.d/ && mkdir not-for-ci/ \
&& sed -i -e "s/MIRROR/{{ nodepool_mirror_host }}/g" /etc/yum.repos.d/ci-rocky.repo
{% raw %}
{% endblock %}
{% endraw %}
{% endif %} {# if centos/rocky #}
{% raw %}
{% block base_centos_repo_overrides_post_rpm %}
{% endraw %}
RUN sed -i \
-e "s|https://trunk.rdoproject.org|{{ nodepool_rdo_proxy }}|g" \
/etc/yum.repos.d/delorean*.repo
{% raw %}
{% endblock %}
{% block base_centos_repo_overrides_post_yum -%}
{%- endraw -%}
&& cd /etc/yum.repos.d/ && mv CentOS*.repo epel*.repo not-for-ci/
{%- raw -%}
{% endblock %}
{% endraw %}
{% endif %}
{% raw %}
{% block base_debian_after_sources_list %}
{% endraw %}
{% if base_distro == "debian" %}
RUN sed -i -e "s|http://deb.debian.org|[trusted=yes] http://{{ nodepool_mirror_host }}|" \
-e "s|http://security.debian.org|[trusted=yes] http://{{ nodepool_mirror_host }}|" \
/etc/apt/sources.list
{% elif base_distro == "ubuntu" %}
RUN sed -i -e "s|mirror://mirrors.ubuntu.com/mirrors.txt|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu/|" \
-e "s|http://ubuntu-cloud.archive.canonical.com/ubuntu|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|" \
-e "s|http://ports.ubuntu.com|[trusted=yes] http://{{ nodepool_mirror_host }}/ubuntu-ports|" \
/etc/apt/sources.list
{% endif %}
{% raw %}
{% endblock %}
{# Revert to upstream mirrors after build is complete #}
{% block footer %}
{% endraw %}
ENV PIP_INDEX_URL=
ENV PIP_TRUSTED_HOST=
{% if use_infra_wheels_mirror | default(true) %}
ENV PIP_EXTRA_INDEX_URL=
{% endif %}
RUN if [ -f /usr/etc/npmrc ]; then \
unlink /usr/etc/npmrc; \
fi \
&& rm -f /etc/npmrc
{% if base_distro in ['centos', 'rocky'] %}
{# NOTE(hrw): Some images have two footer blocks.
For example neutron-infobox-ipam-agent being
child of neutron-server.
#}
RUN if [ -d /etc/yum.repos.d/not-for-ci/ ]; then \
cd /etc/yum.repos.d/ && \
rm ci-{{ base_distro }}.repo && \
mv not-for-ci/*.repo . && \
rm -rf not-for-ci; \
fi
{% elif base_distro == "debian" %}
RUN sed -i -e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}|http://deb.debian.org|" \
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}|http://security.debian.org|" \
/etc/apt/sources.list
{% elif base_distro == "ubuntu" %}
RUN sed -i -e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu/|mirror://mirrors.ubuntu.com/mirrors.txt|" \
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu-cloud-archive|http://ubuntu-cloud.archive.canonical.com/ubuntu|" \
-e "s|\[trusted=yes\] http://{{ nodepool_mirror_host }}/ubuntu-ports|http://ports.ubuntu.com|" \
/etc/apt/sources.list
{% endif %}
{% raw %}
{% endblock %}
{% endraw %}