Allow --qemu and file:// --mirrors to be used together

When using file:// mirrors, rootfs.py will spawn a local HTTP
server at 127.0.0.1.

In combination with --qemu, this poses a problem: downloads
on the host machine will work, but downloads on the guest
machine will not reach the local server.

This commit introduces a change to rewrite the address to
10.0.2.2 inside the guest, only when QEMU=True is set in
the configuration, allowing this combination to build
past the get_network improvement step.
This commit is contained in:
Alexandre Gomes Gaigalas 2025-06-11 22:17:25 -03:00
parent f2d7fda460
commit 6e5e42307b
2 changed files with 5 additions and 0 deletions

View file

@ -283,6 +283,10 @@ download_source_line() {
fname="${fname:-$(basename "${upstream_url}")}"
if ! [ -e "${fname}" ]; then
for mirror in $(randomize "${MIRRORS}"); do
# In qemu SimpleMirror is not running on the guest os, use qemu IP
case "${QEMU}-${mirror}" in 'True-http://127.0.0.1'*)
mirror="http://10.0.2.2${mirror#'http://127.0.0.1'}"
esac
mirror_url="${mirror}/${fname}"
echo "${mirror_url}"
curl --fail --retry 3 --location "${mirror_url}" --output "${fname}" || true && break