createrepo 创建仓库

在生产环境,经常需要自己编译和维护 rpm包管理器 包,提供内部系统安装。此时,构建自己的软件仓库,就能够非常方便使用 yum / DNF包管理器 进行规模化自动安装。

安装 createrepo 工具

  • 安装工具:

在CentOS/RHEL中安装 createrepo
yum install createrepo

配置

  • 将需要索引的rpm放到指定目录,例如, CentOS 7环境编译GlusterFS 11 后获得的所有rpm包存放到 glusterfs/11.0/CentOS/7.2 目录下

  • 执行以下命令构建索引:

CentOS 7环境编译GlusterFS 11 构建的rpm包创建索引
createrepo glusterfs/11.0/CentOS/7.2

完成后,在rpm包目录下创建了一个 repodata 目录,其中就包含了rpm包目录的索引配置

  • 创建repository配置文件:

创建一个简单的 glusterfs_repo.sh 脚本生成 glusterfs-11.repo

cat << EOF > glusterfs-11.repo
[centos-gluster11]
name=CentOS-$releasever - Gluster 11
baseurl=http://REPO:8080/glusterfs/11.0/CentOS/7.2/
enabled=1
gpgcheck=0
EOF

repo=$1
sed -i "s/REPO/$repo/g" glusterfs-11.repo

参考