ocspkg使用说明
ocspkg是一个与 RPM 打包系统交互的脚本。 在打包过程中,需要git/koji账户认证、代码/源码包管理、mock/koji编译等, ocspkg基于rpkg 将gitee和koji联通起来,从而实现类似git、koji、mock一体化工具。
安装ocspkg
sudo dnf install ocspkg
申请账号
freeipa账户注册
配置环境
git配置
- gitee公钥配置
- 个人机器,本地用户姓名、邮箱配置:
```
ssh生成本机秘钥,提交公钥到gitee
本地姓名、邮箱配置
git config --global user.email
koji配置
配置kerberos客户端: 安装:
dnf install -y krb5-libs krb5-client #安装kerberos认证
dnf install -y mock koji #安装koji、mock
freeipa账户注册后, kinit klist //如下输出表明配置完成
Ticket cache: KCM:0:86421
Default principal: <username>@OPENCLOUDOS.TECH
Valid starting Expires Service principal
09/05/22 06:52:18 09/06/22 06:51:58 krbtgt/OPENCLOUDOS.TECH@OPENCLOUDOS.TECH
09/05/22 06:52:42 09/06/22 06:51:58 HTTP/build.opencloudos.tech@OPENCLOUDOS.TECH
# 注:若kinit时报错“kinit: Credential cache directory /run/user/0/krb5cc does not exist while getting default ccache”,可手动创建该缓存目录
# mkdir /run/user/$(id -u)/krb5cc -p
# bash-5.1# chmod 750 /run/user/$(id -u)/krb5cc
# bash-5.1# chown $(id -u):$(id -g) /run/user/$(id -u)/krb5cc
修改 /etc/koji.conf
[koji]
server = http://build.stream.opencloudos.tech/kojihub
weburl = http://build.stream.opencloudos.tech/koji
topurl = http://build.stream.opencloudos.tech
authtype = kerberos
principal = <username>@OPENCLOUDOS.TECH
配置文件修改如上,使用kinit初始化
kinit //输入密码
koji -d hello //出现如下输出表示,koji配置完成,enjoy it
2022-09-05 06:52:42,671 [DEBUG] koji: Opening new requests session
2022-09-05 06:52:42,672 [DEBUG] koji: Opening new requests session
successfully connected to hub
hello, <username>!
You are using the hub at https://build.opencloudos.tech/kojihub
Authenticated via GSSAPI
mock配置
添加mock编译时cfg文件(以x86架构为例),vim /etc/mock/opencloudosstream-x86_64.cfg,填入mock配置内容(以下为ocs23配置文件,供参考使用):
# Auto-generated by the Koji build system
config_opts['basedir'] = '/var/lib/mock'
config_opts['chroot_setup_cmd'] = 'groupinstall build'
config_opts['chroothome'] = '/builddir'
config_opts['dnf_warning'] = False
config_opts['package_manager'] = 'dnf'
config_opts['root'] = 'dist-ocs23-build-repo_7286'
config_opts['rpmbuild_networking'] = False
config_opts['rpmbuild_timeout'] = 86400
config_opts['target_arch'] = 'x86_64'
config_opts['use_host_resolv'] = False
config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=https://build.stream.opencloudos.tech/kojifiles/repos/dist-ocs23-build/latest/x86_64\n'
config_opts['plugin_conf']['ccache_enable'] = False
config_opts['plugin_conf']['root_cache_enable'] = False
config_opts['plugin_conf']['yum_cache_enable'] = False
config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'
config_opts['macros']['%_host_cpu'] = 'x86_64'
config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
config_opts['macros']['%_topdir'] = '/builddir/build'
config_opts['macros']['%dist'] = '.ocs23'
config_opts['macros']['%distribution'] = 'Koji Testing'
config_opts['macros']['%packager'] = 'Koji'
config_opts['macros']['%vendor'] = 'Koji'
注:也可以执行以下指令,自行生成mock.cfg。
koji mock-config --tag=dist-ocs23-build -a x86_64
使用方式
当前支持指令 ```
Git-like commands: - clone - co: clone alias. - sources: download tarball. - upload: upload tarball, append to the sources file. - new-sources: upload tarball, override in the sources file. - diff - commit - push
Mock-like commands: - prep - srpm - local: locally test run of rpmbuild producing binary RPMs. - mockbuild: local test build using mock.
Koji-like commands: - scratch-build - build ```