Gentoo Riscv Keyword
前言
记录一下如何在gentoo上做riscv keyword工作的,这篇文章是从我的notion上面直接拷贝过来的部分内容可能还需要更新后续有空的时候会更新。
环境准备
这里我准备的是一个Gentoo amd64架构的虚拟机来做Gentoo Riscv Keywording的工作,如果你想要安装Gentoo系统的话可以参考https://t.me/gentoocn/40 中的一些文章,除此之外我们还需要qemu来去模拟riscv。
桌面应用的测试可以用到 lxd 具体可以参考这篇文章来折腾 https://wiki.gentoo.org/wiki/User:Juippis/The_ultimate_testing_system_with_lxd
测试pr可以看这篇文章两篇文章: https://wiki.gentoo.org/wiki/Incus/Gentoo_Github_pullrequest_testing
https://wiki.gentoo.org/wiki/Incus
在Gentoo系统上我们需要以下软件:
| 名称 | 用途描述 | 备注 | 
|---|---|---|
| app-emulation/qemu | 用于在amd64下模拟riscv | 可以参考https://gitlab.com/cwittlut/riscv-chroot-env | 
| sys-apps/bubblewrap | 类似与chroot | 非特权的沙盒工具 | 
| www-client/pybugz | bugz的客户端 | 
除了一个必要的Gentoo系统之外,我们还需要以下账号:
| 网站 | 用途 | 
|---|---|
| https://bugs.gentoo.org/ | 用于在Gentoo Bugzllia上提Bug | 
| https://github.com/ | 用于在官方Gentoo Portage Mirrors创建PR | 
在commit的时候我们还需要一个签名密钥,这个我们可以使用opengpg来生成,具体可以参考:
我们需要给自己的commit进行签名,需要生成一个gpg key
Keyword 流程
我们这里一个比较简单的包terraform来做此篇Keywording流程的演示。

目前可以看到是还没有riscv的适配,接下来我们就以这个包进行keywording。
riscv 环境设置
设置USE并安装qemu:
echo "app-emulation/qemu static-user QEMU_USER_TARGETS: riscv32 riscv64" >>/etc/portage/package.use/qemu
emerge -vj app-emulation/qemu --autounmask创建二进制包:
quickpkg app-emulation/qemuRegister binary format handlers
[ -d /proc/sys/fs/binfmt_misc ] || modprobe binfmt_misc
[ -f /proc/sys/fs/binfmt_misc/register ] || mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
echo ':riscv64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xf3\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-riscv64:' > /proc/sys/fs/binfmt_misc/register启动服务并添加到开机启动:
rc-service qemu-binfmt start
rc-update add qemu-binfmt default创建一个riscv环境,首先下载cwittlut的riscv-chroot-env到本地:
git clone https://gitlab.com/cwittlut/riscv-chroot-env创建对应的rootfs
./riscv-chroot-env/getLatest.sh # 下载最新的rootfs
sudo ./createRootFS.sh # 创建rootfs
sudo ./chroot.sh# 进入choot环境如图所示我们现在就进入到了chroot环境中:

git设置(宿主机)
首先我们fork官方的仓库到自己的github账号中,然后将仓库克隆到本地:
git clone https://github.com/slchris/gentoogit需要设置用户名以及邮箱,这部分是为了commit签名,建议是真实姓名:
cd gentoo
git config --local user.name "Chris Su"
git config --local user.email "[email protected]"
git config --local pull.rebase true
git config --local --unset pull.ff
git config --local push.default simple
git config --local format.signoff yes
git config --local user.signingkey 0x45D10727855239D3
git config --local commit.gpgsign 1
git config --local push.gpgsign 0 # github no supportbugz 设置(宿主机)
在安装完成bugz客户端后需要配置一下key:
~/.bugzrc
[Gentoo]
base = https://bugs.gentoo.org/xmlrpc.cgi
search_statuses = CONFIRMED, IN_PROGRESS, UNCONFIRMED
user = [email protected]
password = My_PassWord提bug(宿主机)
bugz post --version unspecified --component "Keywording" \
--product "Gentoo Linux" \
--op-sys Linux \
--platform All \
--priority Normal \
--severity normal \
--alias "" \
--assigned-to "" \
--cc "" \
--url "" \
--append-command "" \
-t "dev-lang/R: ~riscv keyword request" \
-d "add ~riscv keyword"keywording(宿主机)
建议在keyword ebuild之前去同步master分支的内容:

同步完成之后本地拉最新的代码,然后切出对应的分支:
git pull && git checkout -b aa # aa 换成要keyword对应包的名字给对应的包打上keyword
ekeyword ~riscv app-metrics/prometheus/prometheus-2.36.2.ebuild或者是使用natta去 keywordreq
nattka apply -a riscv  --keywordreq  865633测试包(在qemu-user)
tatt也要配置一下:
arch=riscv
unmaskdir="/etc/portage/package.accept_keywords"
repodir="/var/db/repos/gentoo"
emergeopts="--autounmask-keep-keywords=y --autounmask-use=y --autounmask-continue --autounmask-write"
buildlogdir="./tatt/logs"
usecombis=1
rdeps=0zbt在 leo的overlay https://github.com/Leo3418/leo3418-ebuild-repo.git
生成依赖
zbt -r gentoo/  ls --tatt app-metrics/prometheus在git repo里面生成依赖:
nattka make-package-list -a riscv app-metrics/prometheus生成测试的脚本
tatt -f zbt--app-metrics--prometheus执行测试脚本
./zbt--app-metrics--prometheus-useflags.sh也可以通过nattka来生成对应的依赖:
nattka --repo gentoo/  make-package-list -a riscv www-apps/rt将测试的结果贴到bugz的评论,如下图所示:
 生成对应的commit
生成对应的commit
nattka commit -a riscv 865633扫描commit的内容:
pkgcheck scan --commits推送到github:
git pushpr
在github页面上提pr,等待开发人员处理。
同时要在bugz页面上将github 的pr链接过去。
如果长时间没有发现被处理的话可以在irc ping一下开发者
如果你觉得这篇文章对你有所帮助,欢迎赞赏~
赞赏