Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to download the RPM package and all its dependencies in CentOS

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

How to download the RPM package in CentOS and all its dependencies, I believe that many inexperienced people do not know what to do, so this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

We can download any package using curl or wget, but these commands cannot download the required dependent package. You have to take some time and manually to find and download the packages on which the installed software depends. However, we do not have to do so. In this short tutorial, I will show you how to download the package and all its dependent packages in two ways. I've tested it under CentOS 7, but these same steps may work on other distributions based on RPM management systems, 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 download the RPM package and all its dependent packages through the "Downloadonly" plug-in of the yum command.

To install the Downloadonly plug-in, run the following command as root.

Yum install yum-plugin-downloadonly

Now, run the following command to download a RPM package.

Yum install-downloadonly

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

Yum install-downloadonly-downloaddir=

Example:

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

Terminal output:

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: centos.excellmedia.net * epel: epel.mirror.angkasa.id * extras: centos.excellmedia.net * updates: centos.excellmedia.net Resolving Dependencies-- > Running transaction check-- > Package httpd.x86_64 0pur2.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 03.el7 will be installed 1.4.8-3.el7 will be installed-> Package apr-util.x86_64 0Rover 1.5.2-6.el7 will be installed-- > Package httpd-tools.x86_64 0Rod 2.4.6-40.el7.centos.4 will be installed-- > Package mailcap.noarch 0Rule 2.1.41-2.el7 will be installed-- > Finished Dependency Resolution Dependencies Resolved = Package Arch Version Repository Size = Installing: httpd x86'64 2.4.6-40.el7.centos.4 updates 2.7 M Installing for dependencies: apr x86'64 1.4.8-3.el7 base 103k 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 k Transaction Summary = = Install 1 Package (+ 4 Dependent packages) Total download Size: 3.0 M Installed size: 10 M Background downloading packages Then exiting: (1 kB 5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:01 (2 kB 5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01 (3 kB 5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:01 (4 kB 5): httpd-tools-2.4.6-40.el7. Centos.4.x86_64.rpm | 83 kB 00:00:01 (5amp 5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7MB 00:00:09- -Total 331kB/s | 3.0MB 00:00:09 exiting because "Download Only" specified

Now go to the directory location you specified, and you will see that there are downloaded packages and dependent software there. In my case, I have downloaded the 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.rpm apr-util-1.5.2-6.el7.x86_64.rpm httpd-2.4.6-40.el7.centos.4.x86_64.rpm httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm mailcap-2.1.41-2.el7.noarch.rpm [object Object]

As you can see from the output above, the httpd package has been downloaded based on all dependencies.

Note that this plug-in works for yum install/yum update, but not for yum groupinstall. By default, this plug-in will download the packages available in the repository. However, you can download a particular software version by specifying the version number.

Example:

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

In addition, you can download multiple packages at one time as follows:

Yum install-downloadonly-downloaddir=/root/mypackages/ httpd vsftpd

Method 2 use the "Yumdownloader" tool to download the RPM package and all its dependent packages

"Yumdownloader" is a simple but useful command-line tool that downloads any RPM package and all its dependencies at once.

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 package, such as httpd.

Yumdownloader httpd

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

Yumdownloader-resolve httpd

By default, Yumdownloader will download the 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: fastestmirror

Loading 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 0RU 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 0RU 1.4.8-3.el7 will be installed

-> Package apr-util.x86_64 0RU 1.5.2-6.el7 will be installed

-> Package httpd-tools.x86_64 0RU 2.4.6-40.el7.centos.4 will be installed

-> Package mailcap.noarch 0RU 2.1.41-2.el7 will be installed

-> Finished Dependency Resolution

(1ap5): apr-util-1.5.2-6.el7.x86_64.rpm | 92 kB 00:00:01

(2ache 5): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:02

(3ache 5): apr-1.4.8-3.el7.x86_64.rpm | 103 kB 00:00:02

(4ache 5): httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm | 83 kB 00:00:03

(5ache 5): httpd-2.4.6-40.el7.centos.4.x86_64.rpm | 2.7MB 00:00:19

[object Object]

Let's make sure that the package is downloaded to the directory we specified.

Ls / root/mypackages/

Terminal output:

Apr-1.4.8-3.el7.x86_64.rpm apr-util-1.5.2-6.el7.x86_64.rpm httpd-2.4.6-40.el7.centos.4.x86_64.rpm httpd-tools-2.4.6-40.el7.centos.4.x86_64.rpm mailcap-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 prefer Yumdownloader to Yum's Downloadonly plug-in. However, both are very easy to understand and can do the same job.

After reading the above, have you learned how to download the RPM package and all its dependencies in CentOS? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report