Nombre total de pages vues

samedi 15 janvier 2011

Download RPM packages with yum

Yum don't keeps RPM packages when you install from itself. So when you need to backup those packages locally, it's interesting to have a way for do this. There is few methods that permit to do it. First method is to configure yum.conf with keepcache=1, packages will be archived into path who is specified into cachedir parameter. Problem is that system will download packages for the future but packages that have already been installed will be not stocked in the cachedir path.
vi /etc/yum.conf

cachedir=/var/cache/yum
keepcache=1
Second method is to use yum-downloadonly. This is a yum plugin that adds --downloadonly flag to yum. With this method yum is going to download RPM packages without install or update them. Plugin adds two options to yum: --downloadonly : indicates to yum to just download without install or update packages. --downloaddir=/path/to/dir : specifies directory for storing packages. Here we are going to download and install this yum plugin:
yum install yum-downloadonly -y
Now we can use two news flags that were added to yum: Here we donwload vsftpd in the current directory (we can use install or update, done the same):
yum install vsftpd -y --downloadonly
Or we can download vsftpd to home directory:
yum update vsftpd -y --downloadonly --downloaddir=/home
vsftpd package is now stored into /home:
ls /home/*
Same problem for this second method: if packages are already installed on this CentOS server, yum don't downloads packages and says "already installed and latest version" or "No Packages maked for Update". Third method consists to use yumdownloader which is included into yum-utils. yum-utils is a collection of tools that permit yum to be most complete. So we have to install yum-utils with:
yum install yum-utils -y
Now we can download easily packages from CentOS repositories. This method is more fun because we can now download packages that are already installed on server. For example we check that vsftpd is already installed:
rpm -qa | grep vsftpd
vsftpd-2.0.5-16.el5_5.1
And now we download this package from repository to store it into home directory:
yumdownloader vsftpd --destdir /home
Then:
ls /home/*
vsftpd-2.0.5-16.el5_5.1.i386.rpm
Possibles options for yumdownloader are: --destdir : to specify where to store packages --urls : list the urls it would download instead of downloading --resolve : resolve dependancies and download required packages --source: operate on source packages --archlist: only download packages of certain architectures (i386,i686,x86_64,noarch) Last method can be an alternative method, but it's not the better way. It consists to use wget. With wget we can download directly packages from an url but we have to know exactly where packages are stored on the web. Sometimes it's difficult to guess if package come from base repo or from updates repo, so this method is useful in some context. If wget command isn't available you have to install it with:
yum install wget -y
Then you can download package from url with wget:
wget http://mirror.ate.info/ftp.centos.org/5.5/updates/i386//RPMS/vsftpd-2.0.5-16.el5_5.1.i386.rpm
Package will be stored into current directory. To store it into another directory, use this command instead:
wget http://mirror.ate.info/ftp.centos.org/5.5/updates/i386//RPMS/vsftpd-2.0.5-16.el5_5.1.i386.rpm -P /home
It will be stored into home directory. I hope this article can help you and it will give you better way to handle RPM packages with the powerful yum.

Aucun commentaire:

Enregistrer un commentaire