Linux – How to Get Package Dependency Tree for Offline Download

package-managementrhelyum

Dear all I have to install for a customer some software on a Red Hat Linux system which has NO access to the internet. Lets assume I need to install Python 2.7 or other kind of packaged software normally available trough "yum install python27" or other kind of package manager.

While such software packages may dependent on other packages etc., how can I get the list of dependencies while not using the linux machine? i.e. exists some web pages or even tools on Windows which allows such analyzes or queries for given Linux Operating systems and version i.e. Red Hat Enterprise 6.7.1?

Thank you

regards
Mark

Best Answer

This information comes from a blog post I wrote some time ago.

First, create a Virtual Machine and do a fresh install of the same RHEL version on it. Make sure you perform a minimal installation so that the packages installed on the machine are kept to the minimum required for the machine to run.

Then, run the following commands on the machine:

[vm]# mkdir /root/tmppkg
[vm]# yum --downloadonly --downloaddir=/root/tmppkg install foobar

Yum will download Foobar and all its dependencies recursively, storing the RPMs in the directory mentioned above.

Create a repository from the bunch of packages downloaded by Yum.

[vm]# chown -R root:root /root/tmppkg
[vm]# createrepo /root/tmppkg
[vm]# chmod -R 755 /root/tmppkg

Transfer the tmppkg directory on the server (via USB thumb drive or CD-ROM) and put it in the /share directory. Then create a file /etc/yum.repos.d/local.repo as such:

[local]
name=Local repository
baseurl=file:///share/tmppkg
enabled=1
gpgcheck=0
protect=1

Now you can install the Foobar package on the server in the usual way. The package manager will fetch all the necessary content from the newly created local repository:

[server]# yum install foobar

Once you’ve installed the package, the /share/tmppkg directory can be safely deleted.

Related Question