Anolis系统下mock构建RPM包

1. 安装 Mock 工具

确保你的系统已安装 mock:

sudo yum install -y mock
sudo usermod -a -G mock $(whoami)  # 将当前用户加入 mock 组
newgrp mock  # 刷新用户组(或重新登录)

2. 配置 Mock 使用 yuhua仓库

创建 yuhua的 Mock 配置文件

1.新建文件 /etc/mock/yuhua-30-x86_64.cfg,内容如下:

[root@localhost ~]# cat /etc/mock/yuhua-30-x86_64.cfg 
include('templates/yuhua-30.tpl')

config_opts['root'] = 'yuhua-30-x86_64'
config_opts['description'] = 'YuHuaXinKe Linux 30'
config_opts['target_arch'] = 'x86_64'
config_opts['legal_host_arches'] = ('x86_64',)
[root@localhost ~]# 

2.新建文件 /etc/mock/templates/yuhua-30.tpl,内容如下:

[root@localhost ~]# cd /etc/mock/templates/
[root@localhost templates]# vi yuhua-30.tpl 
[root@localhost templates]# cat yuhua-30.tpl 
config_opts['chroot_setup_cmd'] = 'install tar gcc-c++  anolis-release which xz sed make bzip2 gzip gcc coreutils unzip diffutils cpio bash gawk rpm-build info patch util-linux findutils grep'
config_opts['dist'] = 'yh30'  # only useful for --resultdir variable subst
config_opts['releasever'] = '30'
config_opts['package_manager'] = 'dnf'
config_opts['description'] = 'YuHuaXinKe 30'
config_opts['extra_chroot_dirs'] = [ '/run/lock', ]
config_opts['macros']['%dist'] = '.yh30'  # 覆盖 %dist 宏
config_opts['macros']['%_vendor'] = 'yuhua'  # 覆盖供应商标识

#config_opts['bootstrap_image'] = 'docker.io/openanolis/anolisos:8'

config_opts['dnf.conf'] = """
[main]
keepcache=1
debuglevel=2
reposdir=/dev/null
logfile=/var/log/yum.log
retries=20
obsoletes=1
gpgcheck=0
assumeyes=1
syslog_ident=mock
syslog_device=
mdpolicy=group:primary
best=1
install_weak_deps=0
protected_packages=
module_platform_id=platform:yh30
user_agent={{ user_agent }}_=_=

[BaseOS]
name=AnolisOS-$releasever - BaseOS
baseurl=https://mirrors.openanolis.cn/anolis/23/os/x86_64/os/
enabled=1
#gpgkey=file:///usr/share/distribution-gpg-keys/anolis/RPM-GPG-KEY-ANOLIS
#gpgcheck=1

"""

3. 初始化 Mock 构建环境

mock -r yuhua-30-x86_64 --init 
  1. 下载并构建 SRPM

1.​下载 zip 的 SRPM

wget https://mirrors.openanolis.cn/anolis/23/os/source/Packages/zip-3.0-24.an23.src.rpm

2.二构建 RPM

mock -r yuhua-30-x86_64 --rebuild zip-3.0-24.an23.src.rpm

4.获取构建结果

构建成功后,RPM 包会保存在:

[root@localhost result]# ll
总用量 2108
-rw-rw-r-- 1 root mock   44275 326 17:41 build.log
-rw-rw-r-- 1 root mock    1933 326 17:41 hw_info.log
-rw-rw-r-- 1 root mock   20108 326 17:41 installed_pkgs.log
-rw-rw-r-- 1 root mock  115722 326 17:41 root.log
-rw-rw-r-- 1 root mock    1348 326 17:41 state.log
-rw-r--r-- 1 root mock 1131399 326 17:41 zip-3.0-24.yh30.src.rpm
-rw-r--r-- 1 root mock  186848 326 17:41 zip-3.0-24.yh30.x86_64.rpm
-rw-r--r-- 1 root mock  334241 326 17:41 zip-debuginfo-3.0-24.yh30.x86_64.rpm
-rw-r--r-- 1 root mock  220354 326 17:41 zip-debugsource-3.0-24.yh30.x86_64.rpm
-rw-r--r-- 1 root mock   85808 326 17:41 zip-doc-3.0-24.yh30.noarch.rpm
[root@localhost result]# pwd
/var/lib/mock/yuhua-30-x86_64/result
[root@localhost result]# 

5.其他

mock -r yuhua-30-x86_64 --scrub=all  # 彻底清理旧环境
# 进入 chroot 环境调试
mock -r anolis-23-x86_64 --shell
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

黑蛋同志

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值