18

If the rpm package is available in multiple repos (configured in /etc/yum.repos.d/ directory), yum is scanning all the repo files and installing it from the one which has the latest version of that package.

I want the package to be downloaded from a specific repo, also I don't want to completely disable the other repositories, instead, I want just one package to be fetched from a specific repo, and disable it from getting downloaded from other repo.

I also don't want to use the version as a filter as there could be the same version of the same package present on multiple repos.

Vivek
  • 11,938
  • 19
  • 92
  • 127

2 Answers2

40

you can tell yum which repositories he can use:

yum --disablerepo="*" --enablerepo="<desired-repo-id>" install package-name

This does not permanently enable/disable repositories; just for this command execution.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
11

If you don't want to disable all repos, then only solution here is to use yum-priorities. It's a plugin.

$ yum install yum-plugin-priorities

Then in a yum repo in /etc/yum.repos.d/*.repo, you can use,

[some_repo]
....
priority=1

Note, the lowest numerical value represents the highest priority. If your package is available in multiple repos, installation/update will occur from the highest priority repo.

Read more here: https://wiki.centos.org/PackageManagement/Yum/Priorities

iamauser
  • 11,119
  • 5
  • 34
  • 52