rpm-mock工具使用
# rpmbuild多环境构建的工具
# 用户基础安装
useradd -m shuttle-slave -s /bin/bash
/etc/mock/build.cfg 777权限
ln -s /home/shuttle-slave/rpmbuild /root/rpmbuild
/etc/sudoers.d/shuttle-slave shuttle-slave ALL=NOPASSWD: ALL
python import requests ; pip2 install requests
# 安装基础依赖
yum install make wget curl gcc rpm-build mock python3-mock、mock、python2、python2-requests dnf epel-release -y
# 安装mock工具
dnf install mock
# mock初始化 平台配置等都在/etc/mock目录下
mock -r epel-7-x86_64 --init
# 创建rpmbuild标准目录
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
# 构建rpm源码包
rpmbuild -bs package.spec
# 然后切换目录到SRPMS可以看到src.rpm包, 默认会放到/var/lib/mock/epel-7-x86_64/result目录下
mock -r epel-7-x86_64 rebuild package.src.rpm
# 通过加--resultdir参数来指定rpm文件的生成目录
mock -r epel-7-x86_64 rebuild package-1.1-1.src.rpm --resultdir=/home/builder/rpms
# 最后通过clean来清理环境
mock -r epel-7-x86_64 --clean
# 初始化构建环境
mock -v -r build --init --clean --scrub=all
# mock默认存储的目录
/var/lib/mock/ 初始化默认目录
/var/cache/mock/ 缓存目录
# 临时仓库安装
dnf -c /tmp/repo.conf -y --setopt="tsflags=nodocs" install mock
# podman需要额外加参数 --cap-add=SYS_ADMIN
docker run -d --name uos_amd_02 --cap-add=SYS_ADMIN localhost/uos_amd_rpm /bin/sh -c "while true;do echo 1;sleep 10;done"