16

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?

JohnEye
  • 409
  • 1
  • 5
  • 12
abubacker
  • 285
  • 1
  • 2
  • 7

5 Answers5

16

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.

JohnEye
  • 409
  • 1
  • 5
  • 12
7

yumdownloader in yum-utils will download any packages you pass to it, or optionally generate the URLs the packages can be downloaded from.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84
5

You can use the repotrack command from the yum-utils package. It will download the entire dependency tree - even if it is already installed.

Example:

sudo yum install yum-utils      # Install yum-utils
sudo repotrack openssl-devel    # Download all dependencies for openssl-devel


Sample output:

[sbadra@rhel6 ~]$ sudo yum install openssl-devel
Loaded plugins: product-id, search-disabled-repos, subscription-manager
Setting up Install Process
Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version
Nothing to do

[sbadra@rhel6 ~]$ sudo repotrack openssl-devel
Downloading audit-libs-2.4.5-6.el6.x86_64.rpm
Downloading audit-libs-2.4.5-6.el6.i686.rpm
Downloading basesystem-10.0-4.el6.noarch.rpm
Downloading bash-4.1.2-48.el6.x86_64.rpm
Downloading ca-certificates-2017.2.14-65.0.1.el6_9.noarch.rpm
Downloading chkconfig-1.3.49.5-1.el6.x86_64.rpm
Downloading coreutils-8.4-46.el6.x86_64.rpm
Downloading coreutils-libs-8.4-46.el6.x86_64.rpm
.... more packages ....
Downloading openssl-1.0.1e-57.el6.i686.rpm
Downloading openssl-1.0.1e-57.el6.x86_64.rpm
Downloading openssl-devel-1.0.1e-57.el6.i686.rpm
Downloading openssl-devel-1.0.1e-57.el6.x86_64.rpm
.... more packages ....
Downloading sed-4.2.1-10.el6.x86_64.rpm
Downloading setup-2.8.14-23.el6.noarch.rpm
Downloading tzdata-2018c-1.el6.noarch.rpm
Downloading zlib-1.2.3-29.el6.x86_64.rpm
Downloading zlib-1.2.3-29.el6.i686.rpm
Downloading zlib-devel-1.2.3-29.el6.i686.rpm
Downloading zlib-devel-1.2.3-29.el6.x86_64.rpm
Sami Badra
  • 51
  • 1
  • 2
  • 1
    I retracted the note about the architecture bug since it is actually the expected behavior. (x86_64 is a superset of i686, which is why the command also downloads i686 packages) See [this](https://github.com/rpm-software-management/yum/issues/25) and [this](http://yum-devel.baseurl.narkive.com/h43gi3vs/why-doesn-t-reposync-work-for-me) article for more info. – Sami Badra Feb 23 '18 at 21:16
  • very good!!!!!! – Demetry Pascal Aug 10 '23 at 23:23
2

One possibility in the longer term might be to designate a machine as the one to download from the internet, then run NFS (or a webserver) on it to expose /var/cache/yum to the internal hosts.

You would then need to update your yum config, to add:

[main]
keepcache = 1

Per https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Working_with_Yum_Cache.html:

Once you enabled caching, every yum operation may download package data from the configured repositories.

In more practical terms:

$ sudo yum install -y nginx
$ sudo find /var/cache/yum/ -type f -name '*.rpm'
<...snip....>
/var/cache/yum/x86_64/7/epel/packages/nginx-1.10.2-1.el7.x86_64.rpm

The other answers will actually solve your immediate issue, where this will only help if you run yum reinstall for the packages you already have, and want RPMs for.

iwaseatenbyagrue
  • 3,688
  • 15
  • 24
0

Here's what I do:

sudo yum install --config=./yum.conf 
  --installroot=/tmp/f541Sdex 
  --downloadonly 
  --downloaddir /tmp/DL-e25xds 
  $(cat list-of-packages)