@@ -204,11 +204,18 @@ stackhpc_ubuntu_focal_repos:
204204 - " deb {{ stackhpc_repo_ubuntu_focal_security_url }} focal-security main universe"
205205 - " deb {{ stackhpc_repo_ubuntu_cloud_archive_url }} focal-updates/wallaby main"
206206
207+ # Whether to revert to the upstream mirrors in built Kolla container images.
208+ stackhpc_kolla_clean_up_repo_mirrors : true
209+
207210# Dict mapping Jinja2 block names in kolla's Docker images to their contents.
208211kolla_build_blocks :
209212 base_header : |
210213 {% if kolla_base_distro == 'centos' %}
211214 RUN \
215+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
216+ mkdir -p /etc/yum.repos.d.backup && \
217+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
218+ {% endif %}
212219 {% for repo in stackhpc_centos_stream_repos %}
213220 sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
214221 -e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
@@ -219,11 +226,34 @@ kolla_build_blocks:
219226 base_centos_repo_overrides_post_yum : |
220227 {# fixme #}
221228 && \
229+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
230+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
231+ tar -czf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d . && \
232+ {% endif %}
222233 {% for repo in stackhpc_centos_stream_repos + stackhpc_epel_repos + stackhpc_centos_additional_repos + stackhpc_third_party_repos %}
223234 sed -i -e 's/^\(mirrorlist *=.*\)/#\1/g' \
224235 -e 's/^[# ]*\(baseurl *=.*\)/#\1/g' \
225236 -e '/#baseurl.*/a baseurl={{ repo.url }}' /etc/yum.repos.d/{{ repo.file }}{% if not loop.last %} &&{% endif %} \
226237 {% endfor %}
238+ footer : |
239+ {% if stackhpc_kolla_clean_up_repo_mirrors | bool %}
240+ {% if kolla_base_distro == 'centos' %}
241+ RUN \
242+ tar -xzf /etc/yum.repos.d.backup/repos.tar.gz -C /etc/yum.repos.d && \
243+ if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/yum.repos.d; then \
244+ echo "Found repository mirror in Yum repositories"; \
245+ exit 1; \
246+ fi && \
247+ rm -rf /etc/yum.repos.d.backup/
248+ {% else %}
249+ # RUN \
250+ # mv /etc/apt/sources.list.backup /etc/apt/sources.list && \
251+ # if grep -r '{{ stackhpc_repo_mirror_url }}' /etc/apt/sources.list; then \
252+ # echo "Found repository mirror in APT repositories"; \
253+ # exit 1; \
254+ # fi
255+ {% endif %}
256+ {% endif %}
227257 # NOTE: The Open vSwitch and OVN packages in Ubuntu Wallaby UCA repository
228258 # are quite old - 2.15 and 20.12 respectively. Pull in these packages from
229259 # the Yoga UCA, which are 2.17 and 22.03, to more closely match the CentOS
@@ -250,7 +280,7 @@ kolla_build_blocks:
250280 # sometimes).
251281 # base_ubuntu_package_sources_list: |
252282 # RUN \
253- # rm -f /etc/apt/sources.list && \
283+ # mv /etc/apt/sources.list{,.backup} && \
254284 # {% for repo in stackhpc_ubuntu_focal_repos %}
255285 # echo '{{ repo }}' >> /etc/apt/sources.list {% if not loop.last %} && \
256286 # {% endif %}
0 commit comments