Download the RPM package and all its dependent packages from CentOS

Source: Internet
Author: User

Download the RPM package and all its dependent packages from CentOS

You must spend some time and manually searching for and downloading the software packages that the installed software depends on. However, we do not have. In this short tutorial, I will show you how to download the software package and all its dependent packages in two ways. I have tested it in CentOS 7, but these same steps may also work in other release versions based on the RPM management system, such as RHEL, Fedora, and Scientific Linux.

Method 1 download the RPM package and all its dependent packages using the Downloadonly plug-in

We can use the Downloadonly plug-in of the yum command to download the RPM package and all its dependent packages.
To install the Downloadonly plug-in, run the following command as root.

yum install yum-plugin-downloadonly

Run the following command to download an RPM package.

yum install --downloadonly <package-name>

By default, this command will download and save the software package to the rhel-{arch}-channel/packageslocation directory of/var/cache/yum/. However, you can also download and save the software package to any location. You can use the-downloaddir option to specify the package.

yum install --downloadonly --downloaddir=<directory> <package-name>

Example:

yum install --downloadonly --downloaddir=/root/mypackages/ httpd

Terminal output:

Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: epel.mirror.angkasa.id * extras: centos.excellmedia.net * updates: centos.excellmedia.netResolving Dependencies--> Running transaction check---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed--> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Running transaction check---> Package apr.x86_64 0:1.4.8-3.el7 will be installed---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================= Package Arch Version Repository Size=======================================================================================================================================Installing: httpd x86_64 2.4.6-40.el7.centos.4 updates 2.7 MInstalling for dependencies: apr x86_64 1.4.8-3.el7 base 103 k apr-util x86_64 1.5.2-6.el7 base 92 k httpd-tools x86_64 2.4.6-40.el7.centos.4 updates 83 k mailcap noarch 2.1.41-2.el7 base 31 kTransaction Summary=======================================================================================================================================Install 1 Package (+4 Dependent packages)Total download size: 3.0 MInstalled size: 10 MBackground downloading packages, then exiting:(1/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:01 (2/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 (3/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01 (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:01 (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:09 ---------------------------------------------------------------------------------------------------------------------------------------Total 331 kB/s | 3.0 MB 00:00:09 exiting because "Download Only" specified


Now go to the directory you specified, and you will see the downloaded software packages and dependent software. In this case, I have downloaded the software package to the/root/mypackages/directory. Let's take a look at the content:

ls /root/mypackages/

Sample output:

apr-1.4.8-3.el7.x86_64.rpmapr-util-1.5.2-6.el7.x86_64.rpmhttpd-2.4.6-40.el7.centos.4.x86_64.rpmhttpd-tools-2.4.6-40.el7.centos.4.x86_64.rpmmailcap-2.1.41-2.el7.noarch.rpm


As you can see in the above output, the httpd package has been downloaded based on all dependencies.
Note that this plug-in applies to yum install/yum update, but not to yum groupinstall. By default, this plug-in will download the latest available software packages in the repository. However, you can download a specific software version by specifying the version number.
Example:

yum install --downloadonly --downloaddir=/root/mypackages/ httpd-2.2.6-40.el7

You can also download multiple packages at a time as follows:

yum install --downloadonly --downloaddir=/root/mypackages/ httpd vsftpd
Method 2 Use Yumdownloader to download the RPM package and all its dependent packages

Yumdownloader is a simple but useful command line tool that can download any RPM software package and all its dependent packages at one time.
Run the following command as root to install the Yumdownloader tool.

yum install yum-utils

Once the installation is complete, run the following command to download a software package, such as httpd.

yumdownloader httpd

To download the software package based on all dependencies, we use the -- resolve parameter:

yumdownloader --resolve httpd

By default, Yumdownloader downloads the software package to the current working directory.
To download the software to a specific directory, we use the -- destdir parameter:

yumdownloader --resolve --destdir=/root/mypackages/ httpd

Or,

yumdownloader --resolve --destdir /root/mypackages/ httpd

Terminal output:

Loaded plugins: fastestmirrorLoading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: epel.mirror.angkasa.id * extras: centos.excellmedia.net * updates: centos.excellmedia.net--> Running transaction check---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed--> Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64--> Running transaction check---> Package apr.x86_64 0:1.4.8-3.el7 will be installed---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be installed---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed--> Finished Dependency Resolution(1/5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 (2/5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:02 (3/5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:02 (4/5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:03 (5/5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7 MB 00:00:19


Let's check whether the software package is downloaded to the directory we specified.

ls /root/mypackages/

Terminal output:

apr-1.4.8-3.el7.x86_64.rpmapr-util-1.5.2-6.el7.x86_64.rpmhttpd-2.4.6-40.el7.centos.4.x86_64.rpmhttpd-tools-2.4.6-40.el7.centos.4.x86_64.rpmmailcap-2.1.41-2.el7.noarch.rpm

Unlike the Downloadonly plug-in, Yumdownload can download a set of related software packages.

yumdownloader "@Development Tools" --resolve --destdir /root/mypackages/

In my opinion, I like Yumdownloader better than Yum's Downloadonly plug-in. However, both are easy to understand and can do the same job.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.