我们在这篇文章中,介绍了借助sbuild搭建Debian package的交叉编译环境,如果在这个 独立的环境
外部,使用sbuild
命令,即可启动Debian package的整个编译流程。 但是有时候我们需要一步一步滴、chroot到这个独立的环境去编译(最少明确每一步在干什么),就需要掌握Debian build package的原生命令了。今天我们介绍dpkg-buildpackage的一些用法,更权威的请参考这里
在外部使用 sbuild
命令可以由chroot自己解决软件依赖的问题,但是使用dpkg-buildpackage
不会这么做。解决自动依赖的命令目前还在探索中,需要后面进行补充。
update: 解决依赖问题可以参考这里
mk-build-deps --install --root sudo --remove
可以不使用 remove.
具体的命令就是:
dpkg-buildpackage --sanitize-env -us -uc -b -rfakeroot
解析:
-us
: unsigned source package
-uc
: unsigned .buildinfo and .changes file
http://ftp.kr.debian.org/debian-ports//pool-riscv64/main/i/icu/libicu-dev_70.1-2_riscv64.deb
http://ftp.kr.debian.org/debian-ports//pool-riscv64/main/i/icu/libicu70_70.1-2_riscv64.deb
http://ftp.kr.debian.org/debian-ports//pool-riscv64/main/i/icu/icu-devtools_70.1-2_riscv64.deb
2020.01.03-2022.02.25
现在觉得时间过得真的很快,依稀记得我当时报道的那一天,到今天正式走完审批流程,我的第一份正式工作就这么结束了。
首先感谢公司,是公司给了我这个平台,让我能够接触到不同的人物、大佬、技术领导、业务领导,其正规的流程化、专业化的公司管理制度,也为自我管理树立了一个良好的榜样。
真诚的感谢给予我指导的各级领导、导师,从入职到独挡一面,从工作到家庭,太多美好的会议,当然,不好的回忆就烟消云散吧。 感谢同事在平常的互帮互助,至少甩锅的,都是我不认识的 :(
海宁这地方挺好,人的脾气也不暴躁,踢球的也不少。当然,除了公司外,海宁其他的选择并不多。
如果这2年,自己有什么进展或者需要反思的地方,那可是这一篇文章不够用的。
自己过去2年留下的遗憾,希望能够在接下来的三年弥补。达成自己与老板既定的目标,加油!
涉足Debian社区快两周了,也大体上知道了Debian开发的一些流程。但是某些东西还是停留在纸上,所有的东西都要动手去实践。
Debian社区是比较古老的、比较geek的氛围。尤其是,主导这个社区的是一群德国佬(核心开发者,肯定也有其他地区的),出于语言、 文化等方面的影响,新人尤其是像我这种新手想要融入进去,一开始还是不少受挫折。老板说的对,脸皮厚,三观正就可以了(.
这篇文章的主要目的是把最后在开发过程中遇到的一些有用的资源放在这里以方便自己后面的工作。通过这些文档或者指南,我还是 认为,在软件行业,只有开源开发者或者 “自由职业者”才会打造经典的作品。
New#Official_port 这里面有几个installer的东西还没有定下来。
https://db.debian.org/machines.cgi
rv-rr44-01 and rv-mullvad-0x are Unleashed boards
rv-osuosl-0x are Unmatched boards
Other are QEMU VMs.
以上buildd machines的信息在 2023/07/23 以后无效了,或者说早就不存在了。
https://buildd.debian.org/stats/
https://buildd.debian.org/status/recent.php?pkg=&a=riscv64&suite=sid&limit=250
deb https://mirrors.tencent.com/debian-ports sid main non-free
deb https://mirror.iscas.ac.cn/debian-ports/ unstable main
还有几个比较重要的wiki:
服务器是:irc.oftc.net
,相关的几个channal:
#debian-bugs
#debian-buildd: Teams/DebianBuildd
##debian-mentors: Support for new contributors with questions on packaging and Debian infrastructure projects/services. See also the debian-mentors mailing list.
#debian-ports: https://www.ports.debian.org/
#debian-riscv: Debian RISC-V port
#devscripts: devscripts
#debci
#debian-golang
#debian-python
#debian-qa
#debian-rust
#debian-toolchain
#reproducible-builds
#llvm
https://wiki.debian.org/ArchitectureSpecificsMemo
在做debian port时,主要会用到以下两个列表:
以下几个资源是展示的目前Debian包在riscv上编译的情况。
比如,这种类型的ftbfs:
ceph: FTBFS on riscv64: undefined reference to `__atomic_exchange_1'
解决方案是参考 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=953003
Description: Link with -pthread instead of -lpthread to fix FTBFS on riscv64
Forwarded: no
Last-Update: 2020-03-01
--- ceph-14.2.7.orig/CMakeLists.txt
+++ ceph-14.2.7/CMakeLists.txt
@@ -28,6 +28,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_S
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(LINUX ON)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
FIND_PACKAGE(Threads)
elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD ON)
https://lists.debian.org/debian-boot/2019/06/msg00017.html
目前有一个有趣的页面,记录了目前DD作为sponsor upload了多少了package:
sponsorstats最惊人的是第一名的gregoa,upload了1663个package,这也就是说,十年的话,每年也得166+。当然,加油啊!
Email contact: [email protected] | Subscribe to mailing list/View archives |
IRC: #debian-js on irc.oftc.net network
If you are new to javascript packaging, you can contact Debian Javascript Mentors channel via Matrix https://matrix.to/#/#debian-js-mentors:poddery.com or IRC: #debian-browserify on irc.oftc.net network
作为Debian的开发者,还需要订阅以下邮件列表:
Announcements of development issues like policy changes, important release issues &c. Only messages signed by a Debian developer will be accepted by this list.
注意,只有DD发的信才有可能被这个列表接受。
General news about the distribution and the project. The current events and news about Debian are summarized in the Debian Weekly News, a newsletter regularly posted on this list.
Helping newbie developers
作为一名潜在的开发人员,还应该订阅这个针对新手打包的列表。
当然,这里还有一个辅佐材料 Debian Mentors Faq可以扩展自己的知识面,加深对Debian的workfolw的理解。
以下是我push的一些port riscv的情况,方便自己查看。
软件名称 | bug url | 是否有patch | 最新状态 | 说明 |
---|---|---|---|---|
sofia-sip | link | yes | apply patch 后可以编译riscv64 deb | 需要推动patch merge into ports’s repo |
yubiserver | link | 无 | 自己可以fix | |
tbb | 无 | 正在生成(02/22) | 无 |
cargo popt cron ntp (这些包是请求帮助的)
nodejs(正在进行) go rust
fix riscv BTFTS 的packages.
vimer@debian-local:~/git/jimtcl/jimtcl-0.81$ debuild
dpkg-buildpackage -us -uc -ui --changes-option=-sa
dpkg-buildpackage: info: source package jimtcl
dpkg-buildpackage: info: source version 0.81+dfsg0-1
dpkg-buildpackage: info: source distribution experimental
dpkg-buildpackage: info: source changed by vimer <[email protected]>
dpkg-source --before-build .
dpkg-buildpackage: info: host architecture amd64
fakeroot debian/rules clean
dh clean
debian/rules override_dh_auto_clean
make[1]: 进入目录“/home/vimer/git/jimtcl/jimtcl-0.81”
dh_auto_clean
rm -f autosetup/jimsh0.c
rm -f libjim.so*
rm -f tests/exec.tmp1
rm -Rf static/
make[1]: 离开目录“/home/vimer/git/jimtcl/jimtcl-0.81”
dh_clean
dpkg-source -b .
dpkg-source: info: using source format '3.0 (quilt)'
dpkg-source: info: building jimtcl using existing ./jimtcl_0.81+dfsg0.orig.tar.gz
dpkg-source: info: using patch list from debian/patches/series
patching file Makefile.in
Hunk #1 FAILED at 177.
1 out of 1 hunk FAILED
dpkg-source: info: the patch has fuzz which is not allowed, or is malformed
dpkg-source: info: if patch '0001-Use-footer-style-none-in-asciidoc-call.patch' is correctly applied by quilt, use 'quilt refresh' to update it
dpkg-source: error: LC_ALL=C patch -t -F 0 -N -p1 -u -V never -E -b -B .pc/0001-Use-footer-style-none-in-asciidoc-call.patch/ --reject-file=- < jimtcl-0.81.orig.1TfyhX/debian/patches/0001-Use-footer-style-none-in-asciidoc-call.patch subprocess returned exit status 1
dpkg-buildpackage: error: dpkg-source -b . subprocess returned exit status 2
debuild: fatal error at line 1182:
dpkg-buildpackage -us -uc -ui --changes-option=-sa failed
解决方案就是 refactor it.因为上游已经有了相关的fix,可以去掉。
上一周定的任务目前没有完成,低估了成为一个maintainer的难度;NMU如果不是活跃的开发者一般也是拒绝。
研究下,看看如何提供buildd service。
完成一个nodsjs port riscv64.
计划:
完成 rust-sys-info 的riscv64 ftbtfs: [done] https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/295
adopt https://github.com/nhorman/dropwatch
完成:
[Fix Debian ftbfs issue] [rust-sys-info] https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/295 https://salsa.debian.org/rust-team/debcargo-conf/-/merge_requests/296 [openvswitch] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1009969. [ncl] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010056 [openmsx] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1010148. [(re)open upstream issue] [vscode support riscv64] https://github.com/microsoft/vscode/issues/147751
[rust-fasteval test fail on riscv64] https://github.com/likebike/fasteval/issues/19
[dealii build fail in riscv64] https://github.com/dealii/dealii/issues/13639
[kexec-tool support riscv64] http://lists.infradead.org/pipermail/kexec/2022-April/024684.html [rust-sys-info] https://github.com/FillZpp/sys-info-rs/issues/105
在前面的文章中, 我们使用sbuild创建schroot搭建riscv64的交叉编译环境,其实是ok的。但是在测试sip这个deb时遇到一点麻烦,现象是schroot只有build这个riscv arch的deb有问题,其他的deb没有问题。但是,为了修复这个问题,schroot暂时还没有找到 如何在编译进行中查看的具体的编译产物 的方法,故这里根据 john的提示,记录下如何创建 基于qemu的sbuild.
当然,还需要参考这个教程
apt-get install sbuild qemu-user-static binfmt-support schroot devscripts debian-ports-archive-keyring
执行命令:
执行这一步时,一定把路径cd 到/srv/chroots
下面,当然,不进入那里面问题也不大,只能在当前目录使用吧。
sudo debootstrap --foreign --no-check-gpg --include=debian-ports-archive-keyring --arch=riscv64 \
unstable sid-riscv64-sbuild http://ftp.ports.debian.org/debian-ports/
参数解析:
--foreign
有的机器需要,有的机器不需要;
--arch
: Set the target architecture
--include=alpha,beta
: Comma separated list of packages which will be added to download and extract lists.
上面的命令得执行一段时间,然后最后就可以看见如下的提示:
...
I: Configuring libc-bin...
I: Base system installed successfully.
这个时候就会在 /srv/chroots 目录下创建了一个 名为sid-riscv64-sbuild
的rootfs。
vimer@debian:/srv$ ls
chroots sid-riscv64-sbuild
# chroots是我之前创建的,可不理会
vimer@debian:/srv$ tree -L 2
.
├── chroots
│ └── sid-sbuild.tgz
└── sid-riscv64-sbuild
├── bin -> usr/bin
├── boot
├── dev
├── etc
├── home
├── lib -> usr/lib
├── media
├── mnt
├── opt
├── proc
├── root
├── run
├── sbin -> usr/sbin
├── srv
├── sys
├── tmp
├── usr
└── var
添加用户成为sbuild的一员:
vimer@debian:/srv$ sudo adduser vimer sbuild
The user `vimer' is already a member of `sbuild'.
#因为我也是之前添加过,暂时不必理会
将qemu的静态可执行程序移动到对应的rootfs中:
vimer@debian:/srv$ sudo cp -av /usr/bin/qemu-riscv64-static /srv/chroots/sid-riscv64-sbuild/usr/bin/
'/usr/bin/qemu-riscv64-static' -> '/srv/chroots/sid-riscv64-sbuild/usr/bin/qemu-riscv64-static'
进入chroot进行验证:
vimer@debian:/srv$ sudo chroot sid-riscv64-sbuild
root@debian:/# uname -a
Linux debian 4.19.0-18-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) riscv64 GNU/Linux
vimer@debian-local:~$ cat /etc/schroot/chroot.d/sid-riscv64-sbuild
[sid-riscv64-sbuild]
description=Debian sid chroot for riscv64
type=directory
directory=/srv/chroots/sid-riscv64-sbuild
#groups=Debian,guest,d-i
#profile=dsa
#aliases=sid
groups=root,sbuild,vimer,buildd
root-groups=root,sbuild,vimer,buildd
#command-prefix=
#source-root-users=glaubitz,sbuild,buildd
#run-setup-scripts=true
#run-exec-scripts=true
#deb http://ftp.ports.debian.org/debian-ports unstable main
deb http://deb.debian.org/debian sid main #视情况打开
deb-src http://deb.debian.org/debian/ sid main
# 以下的ports sources是这次添加进来的,参看上面的解释或者以下的url:
# https://wiki.debian.org/RISC-V#Package_repository
deb http://ftp.ports.debian.org/debian-ports/ sid main
deb http://ftp.ports.debian.org/debian-ports/ unreleased main
deb-src http://ftp.ports.debian.org/debian-ports/ sid main
然后就可以chroot这里面做相应的打包测试了。
因为整个arch为riscv所以可以直接在chroot中直接使用相关的编译命令。
如果source code已经有了完整了 debian/
目录,我们可以直接使用以下命令:
root@debian:/home/build_test/sip/sofia-sip-1.12.11+20110422.1# dpkg-buildpackage -rfakeroot -us -uc
这个过程中,提示缺少啥就安装啥就可以。
在chroot内部执行编译命令,哪里都好就是速度太慢,巨慢的那种。
上面的基本环境搭建好之后,就可以进行相关的测试了。
首先使用apt source
命令,下载你要移植的包,比如这个 tbb
# 1. apt source tbb
# 2. subild cmd
sudo sbuild --arch=riscv64 -d sid-riscv64-sbuild
这篇文章非常有价值,解决了我真实想解决的问题。
还有我自己的文章debian quilt usage
参考这里 最简单的测试就是重新`apt sourc这个package的source code,然后直接打patch就行。 正常的patch(对除了debian/rules文件外的patch)都可以:
$ quilt import -P fix-foobar.patch /tmp/patch
Importing patch /tmp/patch (stored as fix-foobar.patch)
$ quilt push
Applying patch fix-foobar.patch
[...]
Now at patch fix-foobar.patch
The -P option allows to select the name of the patch file created in debian/patches/. As you see, the new patch file is recorded in debian/patches/series but not applied by default, we’re thus doing it with quilt push.
那么,如果针对的是 debian/rules的patch,应该使用下面的patch命令进行打patch。
根据这篇文章
首先安装:
sudo apt install devscripts dpatch fakeroot dh-make
如果只是测试,没必要在debian目录下新建patches目录(假设没有这个目录的话),但是正规的package,一般需要这个目录的。
sudo mkdir patches
[sudo] password for vimer:
vimer@debian:~/build_test/sip/sofia-sip-1.12.11+20110422.1/debian$ ls
changelog copyright libsofia-sip-ua-dev.install libsofia-sip-ua-glib-dev.install sofia-sip-bin.install
compat libsofia-sip-ua0.install libsofia-sip-ua-glib3.install patches sofia-sip-doc.docs
control libsofia-sip-ua0.symbols libsofia-sip-ua-glib3.symbols rules
以这个patch https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=978498为例,其实在这个debian bugs thread中我们是不容易找到patch的,我们需要find下patch
字段。
找到以后,比如这个sofia-sip-retooling.patch,然后可以直接click或者保存附件就行。
但是,最直接的方式却不支持了,比如wget https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=978498;filename=sofia-sip-retooling.patch;msg=10
或者”curl”命令。这个问题Debian社区的人居然不重视???能不能有点geek的乐趣,还得去浏览器下载,哈哈!
探究了一番后发现,是由于wget在接受这个参数时,默认把url中的特殊字符给截断了,其实主要是由于”?”引发的。前面这句话也许有纰漏,大佬说是由于shell引起的,确实是截断的,但是为什么会截断,我觉得后面有必要研究一下。
后来试了一下,在脚本中把URL加上双引号就可以使用curl
下载patch了,这样也好,后面写个脚本把url传进去,然后输出文件可以根据patch来输出。
这个事看看后面能不能给dget提交个patch。
拿到patch后,可以使用下面的命令进行apply patch to source code.
~$
vimer@debian:/tmp/sip/sofia-sip-1.12.11+20110422.1$ sudo < /tmp/sofia-sip-retooling.patch patch -p1
patching file debian/rules
其实上面的用法也不太明确,更直接的用法就可以(首先在debian目录下):
$ patch -p1 < ~/Fix_ftbfs_riscv64.patch
patching file debian/rules
有时候我们需要多次测试修改效果,所以,得需要回到一个没有patch的clean状态:
patch -R -p1 debian/rules < ~/Fix_ftbfs_riscv64.patch
patching file debian/rules
当然,不指定修改的 mod-files也是可以的:
$ patch -R -p1 < ~/Fix_ftbfs_riscv64.patch
patching file debian/rules