Centos – Download RPM packages for command which is already installed

centosrpmyum

I have a CentOS machine in which I already installed openssl-devel using

$ yum install openssl-devel 

It downloaded and installed all the dependency packages.
Now I need all those RPM packages. Is it possible to download only the RPM packages? When I do this:

 $ yum install  openssl-devel -y --downloadonly 

It says

Package 1:openssl-devel-1.0.1e-4.fc18.x86_64 already installed and latest version

since it's already installed.

Does anyone know how to download those RPM packages on the same system?

Best Answer

It is possible to download the packages of an RPM which is already installed using the --downloadonly switch. I am not sure why yum doesn't check this setting before checking whether the package is already installed, but I guess it could be caused by the underlying architecture of the tool.

Anyway, all you need to do is to tell yum to reinstall the package:

yum --downloadonly --downloaddir=/tmp/rpm_files/ reinstall package_name

Of course, yum will not know which dependencies were installed just for this package, so if you take the RPMs and try to install them on a different system, some dependencies might be missing. There are ways to explore the whole dependency graph and I'm sure this was already described elsewhere on SE.