In these days i’ve worked a lot on Red Hat Enterprise and Centos machines, and so i’ve used yum to install, upgrade, remove and download packages.
I’m more used to .deb packages (or the portage system), and so for me these plugins are both new and really useful to extend the basic functions of yum.
In particular i’ll show you how:
- Tell to yum the priorities among his repository
- Use yum to download a package without installing it.
But first some information regarding yum from wikipedia:
The Yellowdog Updater, Modified (YUM) is an open-source command-line package-management utility for RPM-compatible Linux operating systems and has been released under the GNU General Public License. It was developed by Seth Vidal and a group of volunteer programmers. Though yum has a command-line interface, several other tools provide graphical user interfaces to yum functionality.
As a full rewrite of its predecessor tool, Yellowdog Updater (YUP), yum evolved primarily in order to update and manage Red Hat Linux systems used at the Duke University department of Physics. Since then, it has been adopted by Red Hat Enterprise Linux, Fedora, CentOS, and many other RPM-based Linux distributions, including Yellow Dog Linux itself, where it has replaced the original YUP utility.
Yum Priorities
I’ve found useful to add “not official” repository to Centos and Red Hat, like Epel or Remi for example, this allow me to add a lot of packages but with the compfort of having a repository that mantain the dependency and keep them updated over time.
But there is a drawback in this solution, some times these packages conflict with the official packages, and perhaps you want to keep as many official packages as possible, so what’s the solutions ?
Priority !
So as first think install this plugin with:
yum install yum-priorities |
Note: In Centos 6 the packages has changed name: yum-plugin-priorities
Check if it’s already activated, to do this you must find in the file /etc/yum/pluginconf.d/priorities.conf the parameter enabled=1
cat /etc/yum/pluginconf.d/priorities.conf [main] enabled=1 |
Now you need to go through all your repositories and give them a priority number from 1-99 the repos with the lowest number gets the highest priority, so I normally set all the official repos to 1.
This is an example with Centos, main repository are set to priority 1, the “contrib” repository to 2 and “epel” to 3:
[base] name=CentOS-$releasever - Base mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os #baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4 priority=1 #released updates [updates] name=CentOS-$releasever - Updates mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates #baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/ gpgcheck=1 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4 priority=1 [contrib] name=CentOS-$releasever - Contrib mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib #baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ gpgcheck=1 enabled=0 gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-centos4 priority=2 [epel] name=Extra Packages for Enterprise Linux 5 – $basearch #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch failovermethod=priority enabled=1 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL priority=3
After some time you want to display clarly all your repos and their repository, i’ve found in a blog this script that do it in one line :
sed -n -e "/^\[/h; /priority *=/{ G; s/\n/ /; s/ity=/ity = /; p }" /etc/yum.repos.d/*.repo | sort -k3n |
That should give you an output like this one:
priority = 10 [base] priority = 10 [updates] priority = 30 [extras] priority = 50 [centosplus] priority = 60 [c5-testing] priority = 70 [rpmforge] priority = 75 [kbs-CentOS-Testing] priority = 90 [kbs-CentOS-Misc-Testing] priority = 94 [epel]
Download packages with Yum without installing them
I had a machine with no direct internet connection but i was in need to install some extra packages and all their dependency, luckily i had another machine with the same version of Operating system and access to the net available.
So how it’s possible with yum to just downlaod a set of RPM ?
After a small search i’ve found another useful plugin: yum-downloadonly (i was on a RHEL 5.X, not sure if it has changed name in 6.x release), yum-downloadonly is a plugin which can be used to download any package from a configured yum repository without installing the package.
As first thing install this plugin with:
yum install yum-downloadonly |
Now, like the name said, you have the option to tell yum to “just downlaod” all the packages, to do it use a command like this one:
yum install --downloadonly --downloaddir=/tmp munin |
The package, by default, is saved in the directory /var/cache/yum/ in rhel-i386-server-5. But with the option –downloaddir you can specify an alternate directory to store the packages.
Popular Posts:
- None Found
Mi spiace contraddirti ma l’uso di yum-priorities è fortemente sconsigliato sia da Red Hat che dalla community CentOS:
http://wiki.centos.org/PackageManagement/Yum/Priorities#head-38b91468cc607d0243f463489c2334bf40bfaaee
Molto meglio usare repository come RPMforge che nativamente non hanno pacchetti che sovrascrivono quelli base.
Hai fatto benissimo a segnalarlo.
Probabilmente l’errore alla abse sono i repository aggiuntivi che mi hanno chiesto di aggiungere, che non sono a prova di errori come rpmforge.
Ciao