[MD] Yum install -- download only download dependency packages, off-line installation of salt

Keywords: Python Ruby RPM yum

The original post was published at the beginning of 17 years. This time, it was re-edited and perfected with md.

copyright: wangn
2017-1-16
CentOS-7-x86_64-Minimal-1511.iso
CentOS Linux release 7.2.1511 (Core)

When deploying linux programs in offline production environment, rpm installation is often needed. This paper uses yum command to download rpm dependency packages locally at one time:

The test object is salt-master software

Before using yum to download, you need to install the linux add-on software epel source. rpm or yum installation is recommended.

1,yum install -y epel-release
2,wget http://centos.ustc.edu.cn/epel/7/aarch64/e/epel-release-7-9.noarch.rpm
   rpm -ivh epel-release-7-9.noarch.rpm

Download the rpm combination dependency package with the yum download only parameter:

# yum install --downloadonly --downloaddir=/home/salt-master salt-master
Loaded plugins: fastestmirror
epel/x86_64/metalink                                    | 5.9 kB  00:00:00     
epel                                                    | 4.3 kB  00:00:00     
(1/3): epel/x86_64/group_gz                             | 170 kB  00:00:00     
(2/3): epel/x86_64/updateinfo                           | 718 kB  00:00:00     
(3/3): epel/x86_64/primary_db                           | 4.5 MB  00:00:43     
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.tuna.tsinghua.edu.cn
 * extras: mirrors.aliyun.com
 * updates: centos.ustc.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package salt-master.noarch 0:2015.5.10-2.el7 will be installed
--> Processing Dependency: salt = 2015.5.10-2.el7 for package: salt-master-2015.5.10-2.el7.noarch
--> Processing Dependency: systemd-python for package: salt-master-2015.5.10-2.el7.noarch
--> Running transaction check
---> Package salt.noarch 0:2015.5.10-2.el7 will be installed
--> Processing Dependency: yum-utils for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: python-zmq for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: python-requests for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: python-msgpack for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: python-jinja2 for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: python-crypto for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: pciutils for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: m2crypto for package: salt-2015.5.10-2.el7.noarch
--> Processing Dependency: PyYAML for package: salt-2015.5.10-2.el7.noarch
---> Package systemd-python.x86_64 0:219-30.el7_3.6 will be installed
--> Processing Dependency: systemd-libs = 219-30.el7_3.6 for package: systemd-python-219-30.el7_3.6.x86_64
--> Processing Dependency: systemd = 219-30.el7_3.6 for package: systemd-python-219-30.el7_3.6.x86_64
--> Running transaction check
---> Package PyYAML.x86_64 0:3.10-11.el7 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: PyYAML-3.10-11.el7.x86_64
---> Package m2crypto.x86_64 0:0.21.1-17.el7 will be installed
---> Package pciutils.x86_64 0:3.5.1-1.el7 will be installed
--> Processing Dependency: pciutils-libs = 3.5.1-1.el7 for package: pciutils-3.5.1-1.el7.x86_64
--> Processing Dependency: libpci.so.3(LIBPCI_3.5)(64bit) for package: pciutils-3.5.1-1.el7.x86_64
--> Processing Dependency: libpci.so.3(LIBPCI_3.3)(64bit) for package: pciutils-3.5.1-1.el7.x86_64
---> Package python-jinja2.noarch 0:2.7.2-2.el7 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-2.el7.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-2.el7.noarch
---> Package python-requests.noarch 0:2.6.0-1.el7_1 will be installed
--> Processing Dependency: python-urllib3 >= 1.10.2-1 for package: python-requests-2.6.0-1.el7_1.noarch
--> Processing Dependency: python-chardet >= 2.2.1-1 for package: python-requests-2.6.0-1.el7_1.noarch
---> Package python-zmq.x86_64 0:14.3.1-1.el7 will be installed
--> Processing Dependency: libzmq.so.3()(64bit) for package: python-zmq-14.3.1-1.el7.x86_64
---> Package python2-crypto.x86_64 0:2.6.1-10.el7 will be installed
--> Processing Dependency: libtomcrypt.so.0()(64bit) for package: python2-crypto-2.6.1-10.el7.x86_64
---> Package python2-msgpack.x86_64 0:0.4.8-1.el7 will be installed
---> Package systemd.x86_64 0:219-19.el7_2.13 will be updated
--> Processing Dependency: systemd = 219-19.el7_2.13 for package: systemd-sysv-219-19.el7_2.13.x86_64
---> Package systemd.x86_64 0:219-30.el7_3.6 will be an update
---> Package systemd-libs.x86_64 0:219-19.el7_2.13 will be updated
--> Processing Dependency: systemd-libs = 219-19.el7_2.13 for package: libgudev1-219-19.el7_2.13.x86_64
---> Package systemd-libs.x86_64 0:219-30.el7_3.6 will be an update
---> Package yum-utils.noarch 0:1.1.31-40.el7 will be installed
--> Processing Dependency: yum >= 3.4.3-143 for package: yum-utils-1.1.31-40.el7.noarch
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-40.el7.noarch
--> Processing Dependency: libxml2-python for package: yum-utils-1.1.31-40.el7.noarch
--> Running transaction check
---> Package libgudev1.x86_64 0:219-19.el7_2.13 will be updated
---> Package libgudev1.x86_64 0:219-30.el7_3.6 will be an update
---> Package libtomcrypt.x86_64 0:1.17-23.el7 will be installed
--> Processing Dependency: libtommath >= 0.42.0 for package: libtomcrypt-1.17-23.el7.x86_64
--> Processing Dependency: libtommath.so.0()(64bit) for package: libtomcrypt-1.17-23.el7.x86_64
---> Package libxml2-python.x86_64 0:2.9.1-6.el7_2.3 will be installed
---> Package libyaml.x86_64 0:0.1.4-11.el7_0 will be installed
---> Package pciutils-libs.x86_64 0:3.2.1-4.el7 will be updated
---> Package pciutils-libs.x86_64 0:3.5.1-1.el7 will be an update
---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed
---> Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed
---> Package python-urllib3.noarch 0:1.10.2-2.el7_1 will be installed
--> Processing Dependency: python-six for package: python-urllib3-1.10.2-2.el7_1.noarch
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-urllib3-1.10.2-2.el7_1.noarch
---> Package systemd-sysv.x86_64 0:219-19.el7_2.13 will be updated
---> Package systemd-sysv.x86_64 0:219-30.el7_3.6 will be an update
---> Package yum.noarch 0:3.4.3-132.el7.centos.0.1 will be updated
---> Package yum.noarch 0:3.4.3-150.el7.centos will be an update
--> Processing Dependency: python-urlgrabber >= 3.10-8 for package: yum-3.4.3-150.el7.centos.noarch
---> Package zeromq3.x86_64 0:3.2.5-1.el7 will be installed
--> Processing Dependency: libpgm-5.2.so.0()(64bit) for package: zeromq3-3.2.5-1.el7.x86_64
--> Running transaction check
---> Package libtommath.x86_64 0:0.42.0-4.el7 will be installed
---> Package openpgm.x86_64 0:5.2.122-2.el7 will be installed
---> Package python-backports-ssl_match_hostname.noarch 0:3.4.0.2-4.el7 will be installed
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch
---> Package python-six.noarch 0:1.9.0-2.el7 will be installed
---> Package python-urlgrabber.noarch 0:3.10-7.el7 will be updated
---> Package python-urlgrabber.noarch 0:3.10-8.el7 will be an update
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================
 Package                                 Arch             Version             Repository             Size
===============================================================
Installing:
 salt-master                             noarch           2015.5.10-2.el7     epel                   1.0 M
Installing for dependencies:
 PyYAML                                  x86_64           3.10-11.el7         base                   153 k
 libtomcrypt                             x86_64           1.17-23.el7         epel                   224 k
 libtommath                              x86_64           0.42.0-4.el7        epel                   35 k
 libxml2-python                          x86_64           2.9.1-6.el7_2.3     base                   247 k
 libyaml                                 x86_64           0.1.4-11.el7_0      base                   55 k
 m2crypto                                x86_64           0.21.1-17.el7       base                   429 k
 openpgm                                 x86_64           5.2.122-2.el7       epel                   171 k
 pciutils                                x86_64           3.5.1-1.el7         base                   93 k
 python-babel                            noarch           0.9.6-8.el7         base                   1.4 M
 python-backports                        x86_64           1.0-8.el7           base                   5.8 k
 python-backports-ssl_match_hostname     noarch           3.4.0.2-4.el7       base                   12 k
 python-chardet                          noarch           2.2.1-1.el7_1       base                   227 k
 python-jinja2                           noarch           2.7.2-2.el7         base                   515 k
 python-kitchen                          noarch           1.1.1-5.el7         base                   267 k
 python-markupsafe                       x86_64           0.11-10.el7         base                   25 k
 python-requests                         noarch           2.6.0-1.el7_1       base                   94 k
 python-six                              noarch           1.9.0-2.el7         base                   29 k
 python-urllib3                          noarch           1.10.2-2.el7_1      base                   100 k
 python-zmq                              x86_64           14.3.1-1.el7        epel                   468 k
 python2-crypto                          x86_64           2.6.1-10.el7        epel                   475 k
 python2-msgpack                         x86_64           0.4.8-1.el7         epel                   83 k
 salt                                    noarch           2015.5.10-2.el7     epel                   4.1 M
 systemd-python                          x86_64           219-30.el7_3.6      updates                109 k
 yum-utils                               noarch           1.1.31-40.el7       base                   116 k
 zeromq3                                 x86_64           3.2.5-1.el7         epel                   344 k
Updating for dependencies:
 libgudev1                               x86_64           219-30.el7_3.6      updates                76 k
 pciutils-libs                           x86_64           3.5.1-1.el7         base                   46 k
 python-urlgrabber                       noarch           3.10-8.el7          base                   108 k
 systemd                                 x86_64           219-30.el7_3.6      updates                5.2 M
 systemd-libs                            x86_64           219-30.el7_3.6      updates                368 k
 systemd-sysv                            x86_64           219-30.el7_3.6      updates                63 k
 yum                                     noarch           3.4.3-150.el7.centosbase                   1.2 M
Transaction Summary
======================================================
Install  1 Package  (+25 Dependent packages)
Upgrade             (  7 Dependent packages)
Total download size: 18 M
Background downloading packages, then exiting:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /home/salt-master/libtommath-0.42.0-4.el7.x86_64.rpm.27716.tmp: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for libtommath-0.42.0-4.el7.x86_64.rpm.27716.tmp is not installed
(1/33): libtommath-0.42.0-4.el7.x86_64.rpm                                            |  35 kB  00:00:00     
(2/33): libgudev1-219-30.el7_3.6.x86_64.rpm                                           |  76 kB  00:00:00     
(3/33): PyYAML-3.10-11.el7.x86_64.rpm                                                 | 153 kB  00:00:00     
(4/33): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm                                     | 247 kB  00:00:00     
(5/33): pciutils-3.5.1-1.el7.x86_64.rpm                                               |  93 kB  00:00:00     
(6/33): pciutils-libs-3.5.1-1.el7.x86_64.rpm                                          |  46 kB  00:00:00     
(7/33): libyaml-0.1.4-11.el7_0.x86_64.rpm                                             |  55 kB  00:00:00     
(8/33): openpgm-5.2.122-2.el7.x86_64.rpm                                              | 171 kB  00:00:00     
(9/33): python-backports-1.0-8.el7.x86_64.rpm                                         | 5.8 kB  00:00:00     
(10/33): libtomcrypt-1.17-23.el7.x86_64.rpm                                           | 224 kB  00:00:00     
(11/33): python-chardet-2.2.1-1.el7_1.noarch.rpm                                      | 227 kB  00:00:00     
(12/33): python-kitchen-1.1.1-5.el7.noarch.rpm                                        | 267 kB  00:00:00     
(13/33): python-markupsafe-0.11-10.el7.x86_64.rpm                                     |  25 kB  00:00:00     
(14/33): python-requests-2.6.0-1.el7_1.noarch.rpm                                     |  94 kB  00:00:00     
(15/33): python-six-1.9.0-2.el7.noarch.rpm                                            |  29 kB  00:00:00     
(16/33): python-jinja2-2.7.2-2.el7.noarch.rpm                                         | 515 kB  00:00:00     
(17/33): python-urllib3-1.10.2-2.el7_1.noarch.rpm                                     | 100 kB  00:00:00     
(18/33): python-urlgrabber-3.10-8.el7.noarch.rpm                                      | 108 kB  00:00:00     
(19/33): python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm                 |  12 kB  00:00:00     
(20/33): python-babel-0.9.6-8.el7.noarch.rpm                                          | 1.4 MB  00:00:00     
(21/33): m2crypto-0.21.1-17.el7.x86_64.rpm                                            | 429 kB  00:00:01     
(22/33): python-zmq-14.3.1-1.el7.x86_64.rpm                                           | 468 kB  00:00:00     
(23/33): python2-msgpack-0.4.8-1.el7.x86_64.rpm                                       |  83 kB  00:00:00     
(24/33): python2-crypto-2.6.1-10.el7.x86_64.rpm                                       | 475 kB  00:00:00     
(25/33): systemd-libs-219-30.el7_3.6.x86_64.rpm                                       | 368 kB  00:00:00     
(26/33): systemd-sysv-219-30.el7_3.6.x86_64.rpm                                       |  63 kB  00:00:00     
(27/33): salt-master-2015.5.10-2.el7.noarch.rpm                                       | 1.0 MB  00:00:00     
(28/33): yum-utils-1.1.31-40.el7.noarch.rpm                                           | 116 kB  00:00:00     
(29/33): systemd-python-219-30.el7_3.6.x86_64.rpm                                     | 109 kB  00:00:01     
(30/33): yum-3.4.3-150.el7.centos.noarch.rpm                                          | 1.2 MB  00:00:01     
(31/33): salt-2015.5.10-2.el7.noarch.rpm                                              | 4.1 MB  00:00:03     
(32/33): zeromq3-3.2.5-1.el7.x86_64.rpm                                               | 344 kB  00:00:02     
(33/33): systemd-219-30.el7_3.6.x86_64.rpm                                            | 5.2 MB  00:00:05     
-------------------------------------------------------------------------------------
Total                                                                        2.6 MB/s |  18 MB  00:00:06     
exiting because "Download Only" specified 

There are several points to be noted:

1.yum download is a dependency combination of the current system state. If the current system has been upgraded or component installed, the results will be different each time. For actual deployment, the initial environment must be consistent. Here I choose CentOS-7-x86_64-Minimal-1511.iso, which is deployed offline directly using rpm after installation.
2. In the resolved process, the system prompts the name, architecture, version, source and size of the matched component package.
3. From the download process, the system gives each software that needs to be installed, installs 25 dependency software and upgrades 7 dependency software. The corresponding offline installation packages need to be treated differently. More attention should be paid here.

We list update as a separate directory. Other dependencies and main files are placed outside the update directory. The directory tree is as follows:

# tree
├── libtomcrypt-1.17-23.el7.x86_64.rpm
├── libtommath-0.42.0-4.el7.x86_64.rpm
├── libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm
├── libyaml-0.1.4-11.el7_0.x86_64.rpm
├── m2crypto-0.21.1-17.el7.x86_64.rpm
├── openpgm-5.2.122-2.el7.x86_64.rpm
├── pciutils-3.5.1-1.el7.x86_64.rpm
├── python2-crypto-2.6.1-10.el7.x86_64.rpm
├── python2-msgpack-0.4.8-1.el7.x86_64.rpm
├── python-babel-0.9.6-8.el7.noarch.rpm
├── python-backports-1.0-8.el7.x86_64.rpm
├── python-backports-ssl_match_hostname-3.4.0.2-4.el7.noarch.rpm
├── python-chardet-2.2.1-1.el7_1.noarch.rpm
├── python-jinja2-2.7.2-2.el7.noarch.rpm
├── python-kitchen-1.1.1-5.el7.noarch.rpm
├── python-markupsafe-0.11-10.el7.x86_64.rpm
├── python-requests-2.6.0-1.el7_1.noarch.rpm
├── python-six-1.9.0-2.el7.noarch.rpm
├── python-urllib3-1.10.2-2.el7_1.noarch.rpm
├── python-zmq-14.3.1-1.el7.x86_64.rpm
├── PyYAML-3.10-11.el7.x86_64.rpm
├── salt-2015.5.10-2.el7.noarch.rpm
├── salt-master-2015.5.10-2.el7.noarch.rpm
├── systemd-python-219-30.el7_3.6.x86_64.rpm
├── yum-utils-1.1.31-40.el7.noarch.rpm
│── zeromq3-3.2.5-1.el7.x86_64.rpm
└── update
   ├── libgudev1-219-30.el7_3.6.x86_64.rpm
   ├── libxml2-2.9.1-6.el7_2.3.x86_64.rpm
   ├── pciutils-libs-3.5.1-1.el7.x86_64.rpm
   ├── python-urlgrabber-3.10-8.el7.noarch.rpm
   ├── systemd-219-30.el7_3.6.x86_64.rpm
   ├── systemd-libs-219-30.el7_3.6.x86_64.rpm
   ├── systemd-sysv-219-30.el7_3.6.x86_64.rpm
   └── yum-3.4.3-150.el7.centos.noarch.rpm

At the same level in the directory, write install_salt.sh and grant execution privileges

#!/bin/bash
rpm -Uvh update/*.rpm
rpm -ivh *.rpm
systemctl start salt-master.service
systemctl enable salt-master.service
systemctl status salt-master.service

The service status is normal after installation.

● salt-master.service - The Salt Master Server
   Loaded: loaded (/usr/lib/systemd/system/salt-master.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2017-01-17 13:35:00 CST; 1h 16min ago
 Main PID: 17972 (salt-master)
   Memory: 6.6M
   CGroup: /system.slice/salt-master.service
           ├─17972 /usr/bin/python /usr/bin/salt-master
           ├─17982 /usr/bin/python /usr/bin/salt-master
           ├─17984 /usr/bin/python /usr/bin/salt-master
           ├─17985 /usr/bin/python /usr/bin/salt-master
           ├─17991 /usr/bin/python /usr/bin/salt-master
           ├─17993 /usr/bin/python /usr/bin/salt-master
           ├─17994 /usr/bin/python /usr/bin/salt-master
           ├─17997 /usr/bin/python /usr/bin/salt-master
           ├─18000 /usr/bin/python /usr/bin/salt-master
           ├─18004 /usr/bin/python /usr/bin/salt-master
           └─18005 /usr/bin/python /usr/bin/salt-master

Sal-minion can also be installed offline in a similar way.

Posted by CodeX on Tue, 18 Dec 2018 11:15:05 -0800