Use infra mirrors for advanced image prepare v2
In CI we seeing issues like [1] randomly while Customizing
test image. Let's use infra mirrors instead of ubuntu
public mirrors.
Added conditions so the override apply only when ubuntu images and nodes
involved.
Originally it was attempted to be fixed with [2] but that doesn't work
as the mount dir don't have access permission without sudo. Also images
newer than ubuntu jammy as new format[3] will not work, this patch makes
it work for newer ones too and also fix file accessibility by using sudo.
[1] File has unexpected size (2351988 != 2352236).
Mirror sync in progress? [IP: 91.189.91.81 80]
[2] https://review.opendev.org/949484
[3] https://repolib.readthedocs.io/en/latest/deb822-format.html
Related-Bug: #2110191
Change-Id: Icc3845beef53c2077197f84c5fae3b719abeb4d6
Signed-off-by: yatinkarel <ykarel@redhat.com>
diff --git a/tools/customize_ubuntu_image b/tools/customize_ubuntu_image
index 34b22fe..1ded664 100755
--- a/tools/customize_ubuntu_image
+++ b/tools/customize_ubuntu_image
@@ -69,8 +69,11 @@
bind_dir "/sys" "${mount_dir}/sys"
if [ -f /etc/apt/sources.list ]; then
mirror=$(grep -oP 'https?://\K[^/ ]+' /etc/apt/sources.list|head -1)
- if [ -f ${mount_dir}/etc/apt/sources.list ]; then
- source ${mount_dir}/etc/os-release
+ if sudo test -f ${mount_dir}/etc/apt/sources.list.d/ubuntu.sources; then
+ sudo sed -Ei "s|(http[s]?://)([^/]+)|\1${mirror}|g" ${mount_dir}/etc/apt/sources.list.d/ubuntu.sources
+ sudo sed -i "/URIs:/a Trusted: yes" ${mount_dir}/etc/apt/sources.list.d/ubuntu.sources
+ elif sudo test -f ${mount_dir}/etc/apt/sources.list; then
+ source <(sudo cat ${mount_dir}/etc/os-release)
sudo tee ${mount_dir}/etc/apt/sources.list <<EOF
deb [ trusted=yes ] https://${mirror}/ubuntu ${UBUNTU_CODENAME} main universe
deb [ trusted=yes ] https://${mirror}/ubuntu ${UBUNTU_CODENAME}-updates main universe