Skip to content

Commit 9af1585

Browse files
committed
ci(apt): unify Azure/archive fallback via mirror+file://
Previously the classic /etc/apt/sources.list (jammy) was handled by duplicating `deb` lines with azure.archive.ubuntu.com first and archive.ubuntu.com second. apt treats parallel deb lines as independent sources and fetches InRelease/Packages from both, wasting ~35 MB per update rather than falling back only when needed. Switch both the Dockerfile and setup-universe workflow to apt's `mirror+file://` transport: - Write /etc/apt/ubuntu-mirrors.list with Azure first, archive second. - Replace each `http://archive.ubuntu.com/ubuntu` reference (classic or deb822) with `mirror+file:///etc/apt/ubuntu-mirrors.list`. apt reads the list and tries URLs in order, using the first that responds, so we get true first-win fallback in both sources formats. security.ubuntu.com is left untouched (separate host, not mirrored on Azure). The file-existence guard uses `if [ -f "$f" ]; then ...; fi` rather than `[ -f "$f" ] && sed ...`: under `sh -e` (the default for GHA `run:` steps) the `&&` chain short-circuits and returns 1 when the file doesn't exist, tripping errexit. Only one of the two sources formats is present on any given Ubuntu version, so the non-matching iteration would otherwise kill the step. Verified locally by baking both the humble (jammy / classic sources.list) and jazzy (noble / deb822) base images end to end; the apt-get install inside the ansible rmw role succeeded via mirror+file:// on both. Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
1 parent 348e581 commit 9af1585

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

.github/workflows/setup-universe.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ jobs:
4646
echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/99-retries
4747
echo 'Acquire::http::Timeout "30";' >> /etc/apt/apt.conf.d/99-retries
4848
echo 'Acquire::https::Timeout "30";' >> /etc/apt/apt.conf.d/99-retries
49-
if [ -f /etc/apt/sources.list ]; then
50-
sed -i '/^deb http:\/\/archive\.ubuntu\.com\/ubuntu/{h;s|archive\.ubuntu\.com|azure.archive.ubuntu.com|;G}' /etc/apt/sources.list
51-
fi
52-
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
53-
sed -i 's|^URIs: http://archive\.ubuntu\.com/ubuntu|URIs: http://azure.archive.ubuntu.com/ubuntu http://archive.ubuntu.com/ubuntu|' /etc/apt/sources.list.d/ubuntu.sources
54-
fi
49+
printf 'http://azure.archive.ubuntu.com/ubuntu\nhttp://archive.ubuntu.com/ubuntu\n' > /etc/apt/ubuntu-mirrors.list
50+
for f in /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources; do
51+
if [ -f "$f" ]; then
52+
sed -E -i 's|http://archive\.ubuntu\.com/ubuntu/?|mirror+file:///etc/apt/ubuntu-mirrors.list|g' "$f"
53+
fi
54+
done
5555
5656
- name: Install dependencies
5757
run: |

docker-new/base.Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ RUN rm -f /etc/apt/apt.conf.d/docker-clean && \
1414
echo 'Acquire::Retries "5";' > /etc/apt/apt.conf.d/99-retries && \
1515
echo 'Acquire::http::Timeout "30";' >> /etc/apt/apt.conf.d/99-retries && \
1616
echo 'Acquire::https::Timeout "30";' >> /etc/apt/apt.conf.d/99-retries && \
17-
if [ -f /etc/apt/sources.list ]; then \
18-
sed -i '/^deb http:\/\/archive\.ubuntu\.com\/ubuntu/{h;s|archive\.ubuntu\.com|azure.archive.ubuntu.com|;G}' /etc/apt/sources.list; \
19-
fi && \
20-
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then \
21-
sed -i 's|^URIs: http://archive\.ubuntu\.com/ubuntu|URIs: http://azure.archive.ubuntu.com/ubuntu http://archive.ubuntu.com/ubuntu|' /etc/apt/sources.list.d/ubuntu.sources; \
22-
fi
17+
printf 'http://azure.archive.ubuntu.com/ubuntu\nhttp://archive.ubuntu.com/ubuntu\n' > /etc/apt/ubuntu-mirrors.list && \
18+
for f in /etc/apt/sources.list /etc/apt/sources.list.d/ubuntu.sources; do \
19+
if [ -f "$f" ]; then \
20+
sed -E -i 's|http://archive\.ubuntu\.com/ubuntu/?|mirror+file:///etc/apt/ubuntu-mirrors.list|g' "$f"; \
21+
fi; \
22+
done
2323

2424
RUN --mount=type=cache,id=apt-cache-${ROS_DISTRO},target=/var/cache/apt,sharing=locked \
2525
--mount=type=cache,id=apt-lists-${ROS_DISTRO},target=/var/lib/apt/lists,sharing=locked \

0 commit comments

Comments
 (0)