Debian及Centos怎么下载软件包及依赖包

Debian下载步骤:

$ sudo apt-get install --download-only <package_name>
or
$ sudo apt install apt-rdepends

$ apt download $(apt-rdepends vim | grep -v "^ ")
This command will recursively download all required packages.

Just in case if you encountered with an error like below:

E: Can't select candidate version from package debconf-2.0 as it has no candidate
Try this command instead:

$ apt-get download $(apt-rdepends vim | grep -v "^ " | sed 's/debconf-2.0/debconf/g')

Centos下载步骤:
1. Download RPM packages with all dependencies using "Downloadonly" plugin
We can easily download any RPM package with all dependencies using "Downloadonly" plugin for yum command.

To install Downloadonly plugin, run the following command as root user.

# yum install yum-plugin-downloadonly
Now, run the following command to download a RPM package.

# yum install --downloadonly <package-name>
By default, this command will download and save the packages in /var/cache/yum/ location. However, you can download and save the packages in any location of your choice using "--downloaddir" option.

# yum install --downloadonly --downloaddir=<directory> <package-name>
Example:

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

As you see in the above output, the package httpd has been downloaded with all dependencies.

Please note that this plugin is applicable for "yum install/yum update" and not for "yum groupinstall". By default this plugin will download the latest available packages in the repository. You can however download a particular version by specifying the version.

Example:

# yum install --downloadonly --downloaddir=/root/mypackages/ httpd-2.2.6-40.el7
Also, you can download multiple packages at once as shown below.

# yum install --downloadonly --downloaddir=/root/mypackages/ httpd vsftpd
2. Download RPM packages with all dependencies using "Yumdownloader" utility
Yumdownloader is a simple, yet useful command-line utility that downloads any RPM package along with all required dependencie

猜你喜欢

转载自blog.csdn.net/taoxicun/article/details/127754791