archinstall icon indicating copy to clipboard operation
archinstall copied to clipboard

Need Help: How to Add Custom Mirror Server Url Correctly in Arch Install

Open geekshen8521 opened this issue 1 year ago • 6 comments

I have created a pacman local cache according to https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Read-only_cache. I use Nginx to host the cache. Then I add my custom server url (e.g. Server = http://192.168.13.xx:8080/ )to the /etc/pacman.d/mirrorlist of some other Arch machine in the LAN. It works very well.

But when I try to add the custom mirror following: Mirrors Custom mirrors Add a custom mirror Enter name (leave blank to skip) Enter url ......

The server url and other info are added to the pacman.conf. For example:

[Home]
SigLevel = Optional TrustAll
Server = http://192.168.13.xx:8080

But shouldn't the mirror be added to /etc/pacman.d/mirrorlist?

From the code, I find the below function add_custom_mirrors: https://github.com/archlinux/archinstall/blob/f107104103b74ac065a56bd94a0878f0d263e177/archinstall/lib/mirrors.py#L276 It operates on /etc/pacman.conf

However, another function use_mirrors: https://github.com/archlinux/archinstall/blob/f107104103b74ac065a56bd94a0878f0d263e177/archinstall/lib/mirrors.py#L290C1-L290C1 operates on /etc/pacman.d/mirrorlist

Another _add_custom_mirror here: https://github.com/archlinux/archinstall/blob/f107104103b74ac065a56bd94a0878f0d263e177/archinstall/lib/mirrors.py#L141

The code gives me the feeling that it is trying to add a custom repository, but the name from the menu says Add a custom mirror.

It is really confusing.

geekshen8521 avatar Dec 21 '23 10:12 geekshen8521

https://github.com/svartkanin/archinstall/blob/16132e6fc9d54f237f260227f99dad5b639891db/archinstall/lib/mirrors.py#L276

  • Is used to set the mirror in the ISO (or host system), it takes a list of custom mirrors

https://github.com/svartkanin/archinstall/blob/16132e6fc9d54f237f260227f99dad5b639891db/archinstall/lib/mirrors.py#L141

  • Is part of the CustomMirrorList class which is the visual menu where custom mirrors can be configured

https://github.com/svartkanin/archinstall/blob/16132e6fc9d54f237f260227f99dad5b639891db/archinstall/lib/mirrors.py#L290

  • Is setting the mirror list on the device where arch is going to be installed

According to the code:

  • pacman.conf is written on the installation target
  • mirrorlist is written on the localhost

svartkanin avatar Jan 28 '24 00:01 svartkanin

So adding the configuration only to pacman.conf does not work for you? Looking at the man https://archlinux.org/pacman/pacman.conf.5.html I cannot see a refernce to the mirorlist that indicates it would be necessary to add it there

svartkanin avatar Jan 28 '24 05:01 svartkanin

Sorry if I didn't make it clear.

I mean, according to the man page you linked, repositories are added to the pacman.conf. For each repository, a server url can be added.

The example given in the man page is the following:

[core]
# use this server first
Server = ftp://ftp.archlinux.org/$repo/os/$arch
# next use servers as defined in the mirrorlist below
Include = {sysconfdir}/pacman.d/mirrorlist

Aim: Utilize the pacman package cache hosted on a local server and speed up the installation.

My thoughts on possible ways to do it:

  • specify a server url for each repository, as in the man page example or
  • add the server url directly to the /etc/pacman.d/mirrorlist.

What archinstall do

using the Add a custom mirror menu, request a name, a server url, and write to /etc/pacman.conf like:

[name_requested]
SigLevel = Optional TrustAll
Server = url_requested

Problem it caused

pacman tries to download a name_requested.db file, treating name_requested as a repository.

geekshen8521 avatar Jan 28 '24 10:01 geekshen8521

What confuses me is, there is a option to Add a custom mirror, that does similar things as adding a custom repository.

geekshen8521 avatar Jan 28 '24 10:01 geekshen8521

IMHO, one way is to do this:

/etc/pacman.conf
[core]
# use this server first
Server = URL_PROVIDED_BY_USER
# next use servers as defined in the mirrorlist below
Include = {sysconfdir}/pacman.d/mirrorlist

Another way is to add

/etc/pacman.d/mirrorlist
Server = URL_PROVIDED_BY_USER

geekshen8521 avatar Jan 28 '24 10:01 geekshen8521

I have raised a PR with some changes to write the provided url to the mirrorlist. You can give that one a go https://github.com/archlinux/archinstall/pull/2350

svartkanin avatar Jan 28 '24 11:01 svartkanin