How does pacman choose which repo to use when downloading & installing

Hello Arch forums,

I'm teaching myself the more advanced aspects of Arch and have though of a question regarding sofrware packages. I have attempted to find the answer myself but I keep running into keyword problems describing my question.

I'd like to know the following:When a package is available on two or more repos, how does Arch choose which repo to use by defaults? Here's an example using 'yay' to search for 'google-chrome' with the repos archlinuxcn and condresrepo enabled.

This is obviously a command that asks me to make a choice but when installing the same package with 'yay -S google-chrome' the package manager does the selection for me.

Since I don't want to use the deveolpment version, #1 and #3 are the only ones I care about. I'm guessing that #1 will be picked as the source repo for the package because archlinuxcn is listed higher up in my /etc/pacman.conf than condresrepo. Is my assumption correct? If not, how do the standard package-managers pacman/yay/yaourt/etc choose which repo to use when installing a package contained within more than one?

I can't say I've ever run into a problem regarding which repo a certain package is coming from, I'm simply curious about how this works as I'm trying to become more proficient with Arch altogether.

Re: How does pacman choose which repo to use when downloading & installing

man pacman.conf wrote:

...The order of repositories in the configuration files matters; repositories listed first will take precedence over those listed later in the file when packages in two repositories have identical names, regardless of version number....

Also there is only one standard package manager, and repository packages will in the end always be installed by pacman, whichever helper frontend you use here shouldn't factor in for repository packages.

Re: How does pacman choose which repo to use when downloading & installing

koesherbacon wrote:

I'm guessing that #1 will be picked as the source repo for the package because archlinuxcn is listed higher up in my /etc/pacman.conf than condresrepo. Is my assumption correct? If not, how do the standard package-managers pacman/yay/yaourt/etc choose which repo to use when installing a package contained within more than one?

As V1del said, pacman documents exactly how it chooses which package to choose -- but since google-chrome-dev != google-chrome (it merely provides it) you will never get offered this regardless of which repo comes first. Provides are only used for pacman -S, when there is not an exact pkgname match...

Whyever and however the yay/yaourt selection algorithms work is a question best asked of the yay/yaourt developers. I assume and hope that -Syu is modeled to respect how pacman itself operates. pacman does not have any option to not specify any options, so it seems yay has modeled your example after yaourt and introduced a mode of operation entirely foreign to pacman entirely.

Managing AUR repos The Right Way -- aurpublish (now a standalone tool)