Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 6 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.extend(rpmUtils.arch.getArchList(opts.arch))
    archlist = opts.arch.split(',') # Change to this
else:
    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 at 7:51

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

Your Answer

 
discard

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.