centos7.9制作rpm离线源

@


在centos7.9的环境联网环境下,制作一个软件包的离线源,使用yumdownloader命令制作一些特殊软件包需要逐个拉去依赖,而使用repotrack则一键拉取,并下载所需依赖,以下进行测试

制作vsftpd离线源

下载制作工具

[root@localhost ~]# yum install createrepo -y
[root@localhost ~]# yum install yum-utils -y

创建测试目录

[root@localhost ~]# mkdir vsftpd
[root@localhost ~]# cd vsftpd/
[root@localhost vsftpd]#

下载vsftpd rpm包

[root@localhost vsftpd]# yumdownloader --resolve vsftpd

创建离线源元数据

[root@localhost vsftpd]# createrepo .
[root@localhost vsftpd]# ls
repodata  vsftpd-3.0.2-29.el7_9.x86_64.rpm

测试

[root@localhost vsftpd]# mv /etc/yum.repos.d/* /home/
[root@localhost vsftpd]# cat /etc/yum.repos.d/test.repo
[ftp]
name=ftp
baseurl=file:///root/vsftpd
ggpcheck=0
enabled=1
[root@localhost vsftpd]# yum clean all;yum repolist
Loaded plugins: fastestmirror
Cleaning repos: ftp
Cleaning up list of fastest mirrors
Other repos take up 176 M of disk space (use --verbose for details)
Loaded plugins: fastestmirror
Determining fastest mirrors
ftp                                                                                              | 2.9 kB  00:00:00
ftp/primary_db                                                                                   | 2.4 kB  00:00:00
repo id                                                    repo name                                              status
ftp                                                        ftp                                                    1
repolist: 1
[root@localhost vsftpd]# yum install -y vsftpd

特殊情况

需要提供安装公钥,数字前面

Downloading packages:
warning: /var/cache/yum/x86_64/7/ftp/packages/ceph-deploy-2.0.1-0.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 460f3994: NOKEY
Public key for ceph-deploy-2.0.1-0.noarch.rpm is not installed
ceph-deploy-2.0.1-0.noarch.rpm                                                                   | 286 kB  00:00:00


Public key for ceph-deploy-2.0.1-0.noarch.rpm is not installed

需要修改打开 /etc/yum.conf 文件,找到 gpgcheck 选项,并将其设置为 0。这将禁用所有仓库的GPG检查。

[root@localhost ~]# sed -i 's/gpgcheck=1/gpgcheck=0/'g /etc/yum.conf

当制作需要依赖的离线源时

[root@localhost ~]# yum install python2-pip.noarch -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-14.el7 will be installed
--> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-14.el7.noarch
--> Finished Dependency Resolution
Error: Package: python2-pip-8.1.2-14.el7.noarch (ftp)
           Requires: python-setuptools
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

则需要把差的依赖拉取到离线源文件中,此处我使用一台机器制作离线源,开启vsftp给另一台机器做测试

[root@storage01 repo-test]# yumdownloader --resolve python-setuptools
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
--> Running transaction check
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be reinstalled
--> Finished Dependency Resolution
python-setuptools-0.9.8-7.el7.noarch.rpm                                                         | 397 kB  00:00:00
[root@storage01 repo-test]# ls
ceph-14.2.22-0.el7.x86_64.rpm         ceph-radosgw-14.2.22-0.el7.x86_64.rpm     repodata
ceph-common-14.2.22-0.el7.x86_64.rpm  python2-pip-8.1.2-14.el7.noarch.rpm
ceph-deploy-2.0.1-0.noarch.rpm        python-setuptools-0.9.8-7.el7.noarch.rpm
[root@storage01 repo-test]# createrepo .
Spawning worker 0 with 2 pkgs
Spawning worker 1 with 2 pkgs
Spawning worker 2 with 1 pkgs
Spawning worker 3 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
#每次打入新的离线源都需要重新生成repodata元数据
[root@localhost ~]# cat /etc/yum.repos.d/test.repo
[ftp]
name=ftp
baseurl=ftp://192.168.200.30/repo-test
ggpcheck=0
enabled=1

需要将下载所需的所有依赖打入即可安装

Dependency Installed:
  python-backports.x86_64 0:1.0-8.el7              python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
  python-ipaddress.noarch 0:1.0.16-2.el7           python-setuptools.noarch 0:0.9.8-7.el7

Complete!
[root@localhost ~]# yum install python2-pip.noarch -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package python2-pip-8.1.2-14.el7.noarch already installed and latest version
Nothing to do
[root@localhost ~]#
[root@storage01 repo-test]# ls
ceph-14.2.22-0.el7.x86_64.rpm          python-backports-1.0-8.el7.x86_64.rpm
ceph-common-14.2.22-0.el7.x86_64.rpm   python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
ceph-deploy-2.0.1-0.noarch.rpm         python-ipaddress-1.0.16-2.el7.noarch.rpm
ceph-radosgw-14.2.22-0.el7.x86_64.rpm  python-setuptools-0.9.8-7.el7.noarch.rpm
python2-pip-8.1.2-14.el7.noarch.rpm    repodata

repotrack命令

该命令会把下载的rpm包以及所涉及的所有依赖进行拉取,可能会下载多一些

[root@storage01 repo-test]# cd ..
[root@storage01 opt]# mkdir repo-test2
[root@storage01 opt]# cd repo-test2
[root@storage01 repo-test2]# repotrack python2-pip.noarch
Downloading basesystem-10.0-7.el7.centos.noarch.rpm
Downloading bash-4.2.46-34.el7.x86_64.rpm
Downloading bzip2-libs-1.0.6-13.el7.x86_64.rpm
Downloading ca-certificates-2020.2.41-70.0.el7_8.noarch.rpm
Downloading centos-release-7-9.2009.0.el7.centos.x86_64.rpm
Downloading chkconfig-1.7.6-1.el7.x86_64.rpm
Downloading coreutils-8.22-24.el7.x86_64.rpm
Downloading expat-2.1.0-12.el7.x86_64.rpm
Downloading filesystem-3.2-25.el7.x86_64.rpm
Downloading gawk-4.0.2-4.el7_3.1.x86_64.rpm
Downloading gdbm-1.10-8.el7.x86_64.rpm
Downloading glibc-2.17-317.el7.x86_64.rpm
Downloading glibc-common-2.17-317.el7.x86_64.rpm
Downloading gmp-6.0.0-15.el7.x86_64.rpm
Downloading grep-2.20-3.el7.x86_64.rpm
Downloading info-5.1-5.el7.x86_64.rpm
Downloading keyutils-libs-1.5.8-3.el7.x86_64.rpm
Downloading krb5-libs-1.15.1-50.el7.x86_64.rpm
Downloading libacl-2.2.51-15.el7.x86_64.rpm
Downloading libattr-2.4.46-13.el7.x86_64.rpm
Downloading libcap-2.22-11.el7.x86_64.rpm
Downloading libcom_err-1.42.9-19.el7.x86_64.rpm
Downloading libdb-5.3.21-25.el7.x86_64.rpm
Downloading libffi-3.0.13-19.el7.x86_64.rpm
Downloading libgcc-4.8.5-44.el7.x86_64.rpm
Downloading libselinux-2.5-15.el7.x86_64.rpm
Downloading libsepol-2.5-10.el7.x86_64.rpm
Downloading libstdc++-4.8.5-44.el7.x86_64.rpm
Downloading libtasn1-4.10-1.el7.x86_64.rpm
Downloading libverto-0.2.5-4.el7.x86_64.rpm
Downloading ncurses-5.9-14.20130511.el7_4.x86_64.rpm
Downloading ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
Downloading ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm
Downloading nspr-4.21.0-1.el7.x86_64.rpm
Downloading nss-softokn-freebl-3.44.0-8.el7_7.x86_64.rpm
Downloading nss-util-3.44.0-4.el7_7.x86_64.rpm
Downloading openssl-libs-1.0.2k-19.el7.x86_64.rpm
Downloading p11-kit-0.23.5-3.el7.x86_64.rpm
Downloading p11-kit-trust-0.23.5-3.el7.x86_64.rpm
Downloading pcre-8.32-17.el7.x86_64.rpm
Downloading popt-1.13-16.el7.x86_64.rpm
Downloading python-2.7.5-89.el7.x86_64.rpm
Downloading python-backports-1.0-8.el7.x86_64.rpm
Downloading python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
Downloading python-ipaddress-1.0.16-2.el7.noarch.rpm
Downloading python-libs-2.7.5-89.el7.x86_64.rpm
Downloading python-setuptools-0.9.8-7.el7.noarch.rpm
Downloading python2-pip-8.1.2-14.el7.noarch.rpm
Downloading readline-6.2-11.el7.x86_64.rpm
Downloading sed-4.2.2-7.el7.x86_64.rpm
Downloading setup-2.8.71-11.el7.noarch.rpm
Downloading sqlite-3.7.17-8.el7_7.1.x86_64.rpm
Downloading tzdata-2020a-1.el7.noarch.rpm
Downloading zlib-1.2.7-18.el7.x86_64.rpm
[root@storage01 repo-test2]# createrepo .
Spawning worker 0 with 14 pkgs
Spawning worker 1 with 14 pkgs
Spawning worker 2 with 13 pkgs
Spawning worker 3 with 13 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
[root@storage01 repo-test2]# ls
basesystem-10.0-7.el7.centos.noarch.rpm          libtasn1-4.10-1.el7.x86_64.rpm
bash-4.2.46-34.el7.x86_64.rpm                    libverto-0.2.5-4.el7.x86_64.rpm
bzip2-libs-1.0.6-13.el7.x86_64.rpm               ncurses-5.9-14.20130511.el7_4.x86_64.rpm
ca-certificates-2020.2.41-70.0.el7_8.noarch.rpm  ncurses-base-5.9-14.20130511.el7_4.noarch.rpm
centos-release-7-9.2009.0.el7.centos.x86_64.rpm  ncurses-libs-5.9-14.20130511.el7_4.x86_64.rpm
chkconfig-1.7.6-1.el7.x86_64.rpm                 nspr-4.21.0-1.el7.x86_64.rpm
coreutils-8.22-24.el7.x86_64.rpm                 nss-softokn-freebl-3.44.0-8.el7_7.x86_64.rpm
expat-2.1.0-12.el7.x86_64.rpm                    nss-util-3.44.0-4.el7_7.x86_64.rpm
filesystem-3.2-25.el7.x86_64.rpm                 openssl-libs-1.0.2k-19.el7.x86_64.rpm
gawk-4.0.2-4.el7_3.1.x86_64.rpm                  p11-kit-0.23.5-3.el7.x86_64.rpm
gdbm-1.10-8.el7.x86_64.rpm                       p11-kit-trust-0.23.5-3.el7.x86_64.rpm
glibc-2.17-317.el7.x86_64.rpm                    pcre-8.32-17.el7.x86_64.rpm
glibc-common-2.17-317.el7.x86_64.rpm             popt-1.13-16.el7.x86_64.rpm
gmp-6.0.0-15.el7.x86_64.rpm                      python-2.7.5-89.el7.x86_64.rpm
grep-2.20-3.el7.x86_64.rpm                       python2-pip-8.1.2-14.el7.noarch.rpm
info-5.1-5.el7.x86_64.rpm                        python-backports-1.0-8.el7.x86_64.rpm
keyutils-libs-1.5.8-3.el7.x86_64.rpm             python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
krb5-libs-1.15.1-50.el7.x86_64.rpm               python-ipaddress-1.0.16-2.el7.noarch.rpm
libacl-2.2.51-15.el7.x86_64.rpm                  python-libs-2.7.5-89.el7.x86_64.rpm
libattr-2.4.46-13.el7.x86_64.rpm                 python-setuptools-0.9.8-7.el7.noarch.rpm
libcap-2.22-11.el7.x86_64.rpm                    readline-6.2-11.el7.x86_64.rpm
libcom_err-1.42.9-19.el7.x86_64.rpm              repodata
libdb-5.3.21-25.el7.x86_64.rpm                   sed-4.2.2-7.el7.x86_64.rpm
libffi-3.0.13-19.el7.x86_64.rpm                  setup-2.8.71-11.el7.noarch.rpm
libgcc-4.8.5-44.el7.x86_64.rpm                   sqlite-3.7.17-8.el7_7.1.x86_64.rpm
libselinux-2.5-15.el7.x86_64.rpm                 tzdata-2020a-1.el7.noarch.rpm
libsepol-2.5-10.el7.x86_64.rpm                   zlib-1.2.7-18.el7.x86_64.rpm
libstdc++-4.8.5-44.el7.x86_64.rpm

测试

[root@localhost ~]# yum remove python2-pip.noarch -y
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-14.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                        Arch                      Version                         Repository               Size
========================================================================================================================
Removing:
 python2-pip                    noarch                    8.1.2-14.el7                    @ftp                    7.2 M

Transaction Summary
========================================================================================================================
Remove  1 Package

Installed size: 7.2 M
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : python2-pip-8.1.2-14.el7.noarch                                                                      1/1
  Verifying  : python2-pip-8.1.2-14.el7.noarch                                                                      1/1

Removed:
  python2-pip.noarch 0:8.1.2-14.el7

Complete!
[root@localhost ~]#
[root@localhost ~]# cat /etc/yum.repos.d/test.repo
[ftp]
name=ftp
baseurl=ftp://192.168.200.30/repo-test2
ggpcheck=0
enabled=1
[root@localhost ~]# yum install python2-pip.noarch -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
ftp                                                                                              | 2.9 kB  00:00:00
ftp/primary_db                                                                                   |  42 kB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-14.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                        Arch                      Version                          Repository              Size
========================================================================================================================
Installing:
 python2-pip                    noarch                    8.1.2-14.el7                     ftp                    1.7 M

Transaction Summary
========================================================================================================================
Install  1 Package

Total download size: 1.7 M
Installed size: 7.2 M
Downloading packages:
python2-pip-8.1.2-14.el7.noarch.rpm                                                              | 1.7 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-pip-8.1.2-14.el7.noarch                                                                      1/1
  Verifying  : python2-pip-8.1.2-14.el7.noarch                                                                      1/1

Installed:
  python2-pip.noarch 0:8.1.2-14.el7

Complete!
[root@localhost ~]# yum clean all;yum repolist
Loaded plugins: fastestmirror
Cleaning repos: ftp
Cleaning up list of fastest mirrors
Other repos take up 176 M of disk space (use --verbose for details)
Loaded plugins: fastestmirror
Determining fastest mirrors
ftp                                                                                              | 2.9 kB  00:00:00
ftp/primary_db                                                                                   |  42 kB  00:00:00
repo id                                                    repo name                                              status
ftp                                                        ftp                                                    54
repolist: 54
[root@localhost ~]#
posted @ 2023-06-15 12:42  huhy  阅读(178)  评论(0编辑  收藏  举报