[SOLVED] Force Calamares to use specific mirrorlist

I have a number of machines that I want to use the net-installer on for KDE installations. I have a caching proxy set up with nginx, which works fine, but it depends on an entry pointing to it in mirrorlist. How can I tell the installer to use the mirrorlist I provide rather than creating one with reflector?

Welcome! :smile:

One possibility is to replace file /usr/bin/update-mirrorlist in the ISO with your own version.
Your replacement program should do something like this:

    #!/bin/bash
    sudo cp /path/to/my-mirror-list /etc/pacman.d/mirrorlist

This of course must be done before starting the installer program.

I’m not sure if this works in all cases, so let’s hear what @fernandomaroto has to say. :slight_smile:

But I guess it doesn’t hurt if you try this anyway (preferably in a virtual machine, to be safe).

Thanks! I’ll do just that.
[[UPDATE]]
That didn’t do it. I’m thinking that update-mirrorlist is used by the welcome program (in its post-install tab), rather than the installer itself? It seems the installer process is calling reflector and overwriting the mirrorlist directly.

No, the welcome app itself is not calling update-mirrorlist. And it is not calling reflector either without user actually starting it manually.

So it must be called somewhere in calamares, and @fernandomaroto knows best about that concerning the netinstaller.

Hi!
You can use /etc/pacman.d/mirrorlist before launching calamares.
pacstrap module from calamares always try to run /usr/bin/update-mirrorlist if exists in the system, if it doesn’t then it runs reflector, indeed overwriting your existing one.

To avoid it, just comment the lines
`#############################################################
update_mirrors_installed = Path("/usr/bin/update-mirrorlist")

try:
    if not update_mirrors_installed.exists():
        subprocess.call(BEST_MIRRORS.split(' '))
    else:
        #subprocess.call([BEST_MIRRORS], shell=True)
        subprocess.call([RANK_MIRRORS, '||', BEST_MIRRORS], shell=True)
except:
    pass

#############################################################`

from /usr/lib/calamares/modules/pacstrap/main.py

OBS: You may need some trials and errors, but this is possible the path to change to what you need.

Hi @fernandomaroto and thanks!
I see now why the change in update-mirrorlist that @manuel suggested didn’t work.

The code I have (from the 2019.12.22 ISO) in pacstrap/main.py is:

try:
    if not update_mirrors_installed.exists():
        subprocess.call(BEST_MIRRORS.split(' '))
    else:
        subprocess.call([BEST_MIRRORS], shell=True)
        #subprocess.call([RANK_MIRRORS, '||', BEST_MIRRORS], shell=True)
except:
    pass

so it never calls update-mirrorlist at all. It just runs reflector in either case.

I swapped the commented line to allow RANK_MIRRORS to be called and the modified update-mirrorlist did its thing correctly. The installer used the proxy as desired.

Then I tried as you suggested and ran another install with the whole try/except block commented out, and that was fine as well.

Thanks again to you both! Awesome job on the whole distro!

1 Like

Great that you figured it out! :smile:

1 Like