yum and downloadonly

Latest response

What is the new option to download only but not install using yum?

Excuse me if this is ridiculously simple. Puzzling me and I can't find any discussion of it.

Recent rhel6 update to yum obviated the need for the yum-plugin-downloadonly and actually uninstalled the plugin. So for information purposes you try to re-install it:

# yum install yum-plugin-downloadonly
Setting up Install Process
Package yum-plugin-downloadonly-1.1.30-30.el6.noarch is obsoleted by yum-3.2.29-69.el6.noarch which is already installed
Nothing to do

Ok, but we run a nightly cron job to download any current updates but not install them. (We prefer that a human do the actual installation while monitoring any output). We do this in order to speed up those mornings when we have 50+ systems to patch and reboot in a small service window. If there are 200+ packages to download first, things get a tad bogged down as you can imagine.

That part of the cron job looks like this and has worked fine until the recent rhel6 overhaul:

/usr/bin/yum -R 10 -e 0 -d 0 -y update --downloadonly

--downloadonly is still in yum manual page as a viable option. It ain't, as far as i can tell. For example, try to run an update manually using the option and you get the same result we get in our nightly cronjob, viz:

# yum -y update --downloadonly
Setting up Update Process
Resolving Dependencies
--> Running transaction check
---> Package bind.x86_64 32:9.8.2-0.37.rc1.el6_7.1 will be updated
...
...
--> Finished Dependency Resolution

Dependencies Resolved

Updating:
bind x86_64 32:9.8.2-0.37.rc1.el6_7.2 rhel-x86_64-server-6 4.0 M
...
...
Downloading Packages:
exiting because --downloadonly specified

thanks for any help

Responses

Hi Eric,

I suspect for the issue you discovered with RHEL6, it will likely require intervention with Red Hat... perhaps.

see this link first before proceeding with below: https://access.redhat.com/solutions/10154.

Also see this link, which works for rhel5, I just tested it

and for RHEL6 it seems I found what you found, and it seems you are close to the solution above, the difference with the 2nd link I provided is "yum -y install yum-plugin-downloadonly" then use yum --downloadonly upgrade, and you can probably use an undocumented safety net of "echo n | yum --downloadonly upgrade".

The below is only useful for individual rpm downloads

Install the rpm called "yum-utils"
then use the command "yumdownloader"

The below example would install the yum-utils command, then download the samba rpm to the newly created /tmp/rpms/ directory. You can use "yum search [name_of_rpm]" to obtain rpms you wish to download. Then use yumdownloader without the version etc to grab the rpm.

[root@yoursystem] # yum -y install yum-utils
[root@yoursystem] # mkdir /tmp/rpms 
[root@yoursystem] #  cd /tmp/rpms
[root@yoursystem] #  yumdownloader samba
samba-3.6.23-14.el6_6.x86_64.rpm
[root@yoursystem] # pwd ; ls
/tmp/rpms
samba-3.6.23-14.el6_6.x86_64.rpm

However, this will not grab dependencies, and there's another method to stage the files without actually going through with the installation. I'll see if I can find it.

Actually, you can use yumdownloader for a list of RPMs or entire RPM-groups

# yumdownloader --destdir=/tmp @mysql @mysql-client
mysql-server-5.1.73-5.el6_6.x86_64.rpm                   | 8.6 MB     00:00
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64.rpm               |  86 kB     00:00
mysql-5.1.73-5.el6_6.x86_64.rpm                          | 894 kB     00:00
mysql-connector-odbc-5.1.5r1144-7.el6.x86_64.rpm         | 114 kB     00:00

It's a really useful tool for creating the kind of tailored build-repo (even better than reposync in some ways) needed to seed a chroot() install for creating custom AWS AMIs.

I read in the man page today yumdownloader can also do dependency solving with "--resolve"

It can but, in actual use, it's been kinda tetchy. It works best with explicit lists or resolveable groups. Telling it "download this RPM and its dependencies" works well enough if neither the target RPM nor any of its dependencies (or its dependencies' dependencies) are already present. If anything in the dependency-chain is already present on the host system, it can be a little unreliable. IIRC, reliability can be improved with --installroot and an appropriate yum.conf file, but it's been a while since I played with that and may be remembering other grab-methods.

Thanks R. Hinton and Tom Jones for the hints about yumdownloader. downloadonly option was certainly more elegant as it knew where to put all the downloaded packages for later installation, which seems to be:
/var/cache/yum/x86_64/6Server/whatever....

plus yumdownloader requires that you tell it what to download. If you want everything it looks like piping the output of check-update into yumdownloader seems to be the most straightforward option:

#cd /var/tmp
#mkdir rpms
#cd rpms
#yum check-update |grep x86| awk '{print $1}' |xargs yumdownloader

that works, but like I say, not pretty. for instance what happens later on when you run it again and there's still old junk sitting around in your temp dir?

thanks for your help!

I only ever run yumdownloader (hell, even reposync's equivalent option) with the --destdir option set. I tend to disagree with where "helpful" tools think is the best location to stage things. Most of the yum/repo-related utils have a number of options for governing their behavior. Most of those options are common across the utils since most of the utils are actually just wrappers for the more basic/familiar tools.

Glad it helped,

That looks like a beginning to me Eric, the only thing that I think could be a hitch is the potential lack of dependency solving, potentially averted with the use of --resolve with yumdownloader. Some people in my company will nearly fill up /var/tmp if I do not monitor it, so it might be good to get an idea of how much yumdownloader would drop off to /var/tmp/ and if it's currently being excessively (ab)used with consumption. perhaps make a (predefined variable of $timestamp) to /var/tmp/$timestap/ directory in case someone else has happened to drop off rpms in that area as well, then have a script dump the old $timestamp directory if needed. I've seen some other contracts where I go and help on occasion where someone has simply sym-linked /var/tmp to /tmp as well.

Euw... If you're going to do the ugly (yet SCAP-recommended) thing of linking /tmp and /var/tmp, use bind-mounts, not symlinks.

Right, thanks, I've used that - it was another contract that did the sym link... I prefer no such sym link.

Although I recall someone here mentioning a salient reason not to use bind mount, even though the stig says to.

Historically - and the behavior that apps are supposed to be written to - /tmp was meant to be truly temporary while /var/tmp was supposed to have persistence. Thus, screen writes its socket files to /tmp and vi writes its recovery files to /var/tmp.

It would suck if your machine crashed out from under you and an application expecting recoverability across epochs couldn't do so.

Eric,

Hi, when u see this:

yum install yum-plugin-downloadonly

Setting up Install Process Package yum-plugin-downloadonly-1.1.30-30.el6.noarch is obsoleted by yum-3.2.29-69.el6.noarch which is already installed Nothing to do

Just use the download only parameters by default, not need install the plugin. Try

yum install --downloadonly --downloaddir=

Regards, Jaime

How do I download only a Version that I want and with out dependencies being down loaded example: yumdownloader kernel-3.10.0-327.36.3.el7.x86_64.rpm Loaded plugins: product-id No Match for argument kernel-3.10.0-327.36.3.el7.x86_64.rpm Nothing to download

or yum upgrade --downloadonly --releasever=7.2 selinux-policy-targeted-3.13.1-60.el7_2.9.noarch

The --downloadonly option to yum worked for me. From a freshly-installed (and subscribed) RHEL6.9,

yum -y update --downloadonly

downloaded 118 packages and put them into: /var/cache/yum/x86_64/6Server/rhel-6-server-rpms/packages

Then, yum exited with: exiting because --downloadonly specified

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.