信创那点事: 自建yum源

最近再折腾信创,陆续可能会写一些,遇到的一些坑

场景

我们需要离线交付一些软件,但是他们需要依赖系统包,手动安装比较繁琐,这里采取将相关包下载缓存下来,搭建本地yum源或者apt源,这里简单以yum为例

环境

  • 腾讯云鲲鹏服务器SK1(目前是白名单开放, 上海二区)
  • 麒麟V10 SP2镜像(需要自行解决授权问题)

搭建本地源

最好是全新环境,当前目录下有个zt-yum目录, 完成路径应该是/root/zt-yum, 这个名字路径都看个人喜好

梳理所需依赖包

我举个测试用的包nfs-utils

下载相关包

仅下载不安装

yum --downloadonly --downloaddir=/root/zt-yum install nfs-utils

注意,如果你是已经安装的环境,需要将install改成reinstall
特别注意,如果是reinstall极大可能导致下载的依赖包不全

生成元数据

目前主流使用createrepo来创建yum源的。

createrepo -p -o zt-yum

上面这条命令就是将原数据存储到zt-yum目录下

配置本地源

cat /etc/yum.repos.d/local.repo

[zt-yum]
name=zt-yum
baseurl=file:///root/zt-yum
gpgcheck=0
enabled=1
priority=1

测试

简单测试,具体需要到离线环境测试

yum makecache

打包

.
├── etc
│   └── yum.repos.d
│       └── zt.repo
├── opt
│   └── quickon
│       └── zt-yum
└── yum.tgz

6 directories, 2 files

这个是我实际打出来的离线源压缩包格式,复制到离线环境

tar xf yum.tgz -C /
yum makecache
yum install nfs-utils

完美到这里就结束了

Sponsor

Like this article? $1 reward

Comments

According to the relevant laws and regulations of the People's Republic of China, the comment function of the current website has been disabled. If you need to comment, please visit ysicing.me, but the comments still need to be reviewed by AI.