@@ -201,11 +201,18 @@ stackhpc_ubuntu_focal_repos:
201201 - " deb {{ stackhpc_repo_ubuntu_focal_security_url }} focal-security main universe"
202202 - " deb {{ stackhpc_repo_ubuntu_cloud_archive_url }} focal-updates/{{ openstack_release }} main"
203203
204+ # Whether to revert to the upstream mirrors in built Kolla container images.
205+ stackhpc_kolla_clean_up_repo_mirrors : true
206+
204207# Dict mapping Jinja2 block names in kolla's Docker images to their contents.
205208kolla_build_blocks :
206209 base_header : |
207210 {% if kolla_base_distro == 'centos' %}
208211 RUN \
212+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
213+ mkdir -p /etc/yum.repos.d.backup && \
214+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
215+ {% endif %}
209216 {% for repo in stackhpc_centos_stream_repos %}
210217 sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
211218 -e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
@@ -216,11 +223,34 @@ kolla_build_blocks:
216223 base_centos_repo_overrides_post_yum : |
217224 {# fixme #}
218225 && \
226+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
227+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
228+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
229+ {% endif %}
219230 {% for repo in stackhpc_centos_stream_repos + stackhpc_epel_repos + stackhpc_centos_additional_repos + stackhpc_third_party_repos %}
220231 sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
221232 -e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
222233 -e '/#baseurl.*/a baseurl={{ repo.url }}' /etc/yum.repos.d/{{ repo.file }}{% if not loop.last %} &&{% endif %} \
223234 {% endfor %}
235+ footer : |
236+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
237+ {% if kolla_base_distro == 'centos' %}
238+ RUN \
239+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
240+ if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/yum.repos.d; then \
241+ echo "Found repository mirror in Yum repositories"; \
242+ exit 1; \
243+ fi && \
244+ rm -rf /etc/yum.repos.d.backup/
245+ {% else %}
246+ # RUN \
247+ # mv /etc/apt/sources.list.backup /etc/apt/sources.list && \
248+ # if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/apt/sources.list; then \
249+ # echo "Found repository mirror in APT repositories"; \
250+ # exit 1; \
251+ # fi
252+ {% endif %}
253+ {% endif %}
224254 # NOTE: The Open vSwitch and OVN packages in Ubuntu Wallaby UCA repository
225255 # are quite old - 2.15 and 20.12 respectively. Pull in these packages from
226256 # the Yoga UCA, which are 2.17 and 22.03, to more closely match the CentOS
@@ -247,7 +277,7 @@ kolla_build_blocks:
247277 # sometimes).
248278 # base_ubuntu_package_sources_list: |
249279 # RUN \
250- # rm -f /etc/apt/sources.list && \
280+ # mv /etc/apt/sources.list{,.backup} && \
251281 # {% for repo in stackhpc_ubuntu_focal_repos %}
252282 # echo '{{ repo }}' >> /etc/apt/sources.list {% if not loop.last %} && \
253283 # {% endif %}
0 commit comments