9. centos - local repo (createrepo)

 

 

 


用 yum 直接安裝本地的 rpm 包

 

yum localinstall /home/myrpmdir/*.rpm

 


設定

 

建立 repos 的 Config

cat > /etc/yum.repos.d/MyPackage.repo << EOF
[MyPackage]
name=Local Packages
baseurl=file:///home/MyPackage
enabled=1
gpgcheck=0
EOF

Checking

yum repolist

repo id            repo name
AppStream          CentOS-8 - AppStream
BaseOS             CentOS-8 - Base
MyPackage          Local Packages
...

修改 yum 設定

sed -i '/^best=/ c\best=False' /etc/yum.conf

sed -i '/^skip_if_unavailable=/ c\skip_if_unavailable=True' /etc/yum.conf

設定說明

best (The default is True)

False => do not fail if the latest version cannot be installed and go with the lower version.

skip_if_unavailable (The default is False)

If enabled, DNF will continue running and disable the repository that couldn't be synchronized for any reason.

如果不修正設定, 就要用 "--repo MyPackage"

yum install tcpdump --repo MyPackage

 


DL rpm package

 

[方法1]

[1] DL Package: yum download rpm only

yum install -y yum-utils

yumdownloader vim tcpdump

[2] Check package dependence

yumdownloader --destdir /home/MyPackage --resolve vim

由於 yumdownloader check package 不準確, 陪份要人手 check

[1]

yum install vim

[2]

rpm -qpR vim-enhanced-8.0.1763-13.el8.x86_64.rpm

[3]

yum -q deplist vim-enhanced-8.0.1763-13.el8.x86_64.rpm | grep provider

yum -q deplist vim-common-2:8.0.1763-13.el8.x86_64  | grep provider

[方法2]

dnf download vim                    # 下載到當前 Folder

dnf download --resolve vim      # 在當前系統找出未有的依賴 Package

(1/4): vim-filesystem-8.0.1763-16.el8.noarch.rp 145 kB/s |  48 kB     00:00
(2/4): gpm-libs-1.20.7-17.el8.x86_64.rpm        416 kB/s |  38 kB     00:00
(3/4): vim-enhanced-8.0.1763-16.el8.x86_64.rpm  2.4 MB/s | 1.4 MB     00:00
(4/4): vim-common-8.0.1763-16.el8.x86_64.rpm    5.5 MB/s | 6.3 MB     00:01

 


Create a repodata

 

yum install -y createrepo

tree -L 1 /home/MyPackages

/home/MyPackages
└── Packages                # rpm package 放在這裡

1 directory, 0 files

# 建立了 /home/MyPackages/repodata

# 行完 createrepo update 後要 "yum clean all"

createrepo /home/MyPackages

Directory walk started
Directory walk done - 37 packages
Temporary output repo path: MyPackage/.repodata/
Preparing sqlite DBs
Pool started (with 5 workers)
Pool finished

ls /home/MyPackages

Packages  repodata             # 新建立了 Folder - repodata

 


Toubelshoot

 

Error:

Not able to install python3 on Redhat 8 offline mode

No available modular metadata for modular package 'python36-3.6.8-2.module_el8.1.0+245+c39af44f.x86_64', 
  it cannot be installed on the system
Error: No available modular metadata for modular package

Fix:

Take a look at repo2module project.

modulemd-tools

Collection of tools for parsing and generating modulemd YAML files

Assuming you have several modular rpms in ./my-custom-repo/Packages:

modular rpms names like python36-3.6.8-2.`module`_el8.1.0+245+c39af44f.x86_64.rpm

Run:

cd my-custom-repo

# create traditional rpm repocreaterepo_c .

# generate modules meta info

repo2module  -s stable -d . modules.yaml

# adjust modules meta info to traditional rpm repo

modifyrepo_c --mdtype=modules modules.yaml repodata/

After all this work, you can find a file names like xxxx-modules.yaml.gz in repodata dir.

The repo should work now.

 


 

 

 

Creative Commons license icon Creative Commons license icon