Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to download all dependencies with yumdownloader, even if they are already installed?

I'm trying to create a local repo and only want to include the packages we need.

share|improve this question
up vote 16 down vote accepted

You can use repotrack instead like this:

repotrack -a x86_64 -p /repos/Packages [packages]

Unfortunately there is a bug with the -a flag (arch). It will download i686 and x86_64.

Here's how to fix it:

if opts.arch:
    #archlist = []
    archlist = opts.arch.split(',') # Change to this
    archlist = rpmUtils.arch.getArchList()

You can use repoquery to get a list of group packages:

repoquery --qf=%{name} -g --list --grouppkgs=all [groups]

Which you can feed into repotrack:

repoquery --qf=%{name} -g --list --grouppkgs=all [groups] | xargs repotrack -a x86_64 -p /repos/Packages
share|improve this answer
Updated to use repotrack instead. repoquery's --requires --resolve option doesn't work recursively for deps. – Luke Oct 13 '12 at 1:32
add the --recursive option to the repoquery command to get it work recursively. – ZaSter May 7 '13 at 22:40
Fixing repotrack the way suggested above did not work for me: no package was downloaded for x86_64 arch. Anyway +1 for a good tip: with repotrack one could download both i386 and x86_64 and filter out unnecessary part. – Alexander Vasiljev Jun 1 '14 at 7:51
@Luke how to use fix part... means where to execute if condition mentioned... and what if i need to check for only certain package in repoquery command. – AVJ Sep 14 '15 at 8:20
How do you invert this process and install the leaf package using the local dependencies? – bias Oct 16 '15 at 16:39

This is a problem that many people look to have faced, including myself. The solution itself is not as freely available as the question. It took me a bit of effort to find out one working way to download a RPM and all its dependencies even if any of them are already installed. So, let me write it down here.

For everyone's information, yumdownloader does not do the job. For anyone with some experience in package management with `yum, it is natural to expect that the following command-line would recursively download a package RPM and all its dependencies:

yumdownloader --resolve <package>

But it does not. May be it prints first-level dependencies or those that are not already installed. I am not sure.

Here is one method that works on CentOS 6.5. Follow the steps to install the downloadonly plugin for yum as given by Red Hat. Basically, on CentOS 6.x, do:

$ sudo yum install yum-plugin-downloadonly.noarch

Then make use of the plugin in combination with the --installroot switch of yum.

sudo yum install \
  --installroot=</path/to/tmp_dir> \
  --downloadonly --downloaddir <rpm_dir> <package>

You would downloaded RPMs of the package, <package> and all its dependencies in the directory, <rpm_dir>. Example, with Git:

$ mkdir root rpms
$ sudo yum install --installroot=/home/roy/root \
  --downloadonly --downloaddir rpms/ git
share|improve this answer
How do you invert this process and install the leaf package using the local dependencies? – bias Oct 16 '15 at 16:34
centos65 sudo yum install yum-plugin-downloadonly.noarch says No package yum-plugin-downloadonly.noarch available. what to do? – Howard Lee Jun 27 at 22:44

If you're from the future (Fedora 23+), where yum is getting replaced with dnf, you might find this bash script useful.

share|improve this answer
Is it the future yet? – kirkpatt Jun 24 at 22:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.