Alpine Linux Porting (1.11?)

进场大修的一天,拿了包高血压药。在候诊间持续debug人生XD
依旧先上个进度图:

+ mkdir -p /sysroot/sys /sysroot/proc /sysroot/dev
+ mount -o bind /sys /sysroot/sys
+ mount -o bind /proc /sysroot/proc
+ mount -o bind /dev /sysroot/dev
+ '[' -n  ]
+ apk add --root /sysroot --repository /main --initramfs-diskless-boot --progress --no-network --clean-protected alpine-base openssl
(1/21) Installing musl (1.2.2-r6)
(2/21) Installing busybox (1.34.0-r5)
Executing busybox-1.34.0-r5.post-install
(3/21) Installing alpine-baselayout (3.2.0-r18)
Executing alpine-baselayout-3.2.0-r18.pre-install
Executing alpine-baselayout-3.2.0-r18.post-install
(4/21) Installing busybox-ifupdown (1.34.0-r5)
(5/21) Installing openrc (0.44.5-r0)
Executing openrc-0.44.5-r0.post-install
(6/21) Installing alpine-conf (3.12.0-r0)
(7/21) Installing libcrypto3 (3.0.0-r2)
(8/21) Installing libssl3 (3.0.0-r2)
(9/21) Installing ca-certificates-bundle (20191127-r6)
(10/21) Installing libretls (3.3.4-r1)
(11/21) Installing ssl_client (1.34.0-r5)
(12/21) Installing zlib (1.2.11-r3)
(13/21) Installing apk-tools (2.12.7-r1)
(14/21) Installing busybox-suid (1.34.0-r5)
(15/21) Installing busybox-initscripts (3.3-r1)
Executing busybox-initscripts-3.3-r1.post-install
(16/21) Installing scanelf (1.3.3-r0)
(17/21) Installing musl-utils (1.2.2-r6)
(18/21) Installing libc-utils (0.7.2-r3)
(19/21) Installing alpine-keys (2.3-r1)
(20/21) Installing alpine-base (3.15.0_alpha20210804-r0)
(21/21) Installing openssl (3.0.0-r2)
Executing busybox-1.34.0-r5.trigger
OK: 8 MiB in 21 packages
+ umount /sysroot/sys /sysroot/proc /sysroot/dev
+ eend 0
+ local msg
+ '[' 0 '=' 0 ]
+ echo 'Installing packages to root filesystem: ok.'
[    6.516422] Installing packages to root filesystem: ok.
......
+ '[' '!' -x /sysroot/init ]
+ '[' no '!=' no ]
+ echo '/init not found in new root. Launching emergency recovery shell'
/init not found in new root. Launching emergency recovery shell
+ echo 'Type exit to continue boot.'
Type exit to continue boot.
+ /bin/busybox sh
sh: can't access tty; job control turned off
/ # 

冲到apk组出「半残的」rootfs,这时是个怪异的状况,主要是在新rootfs中,/init不存在,照理来说他是openrc的symbolic link,这点在sysmted也是类似的设计,但是土炮的结果 — —

/sysroot # ln -s ./sbin/openrc ./init
/sysroot # chroot . /init
 * Caching service dependencies ...
 [ ok ]
grep: /proc/filesystems: No such file or directory
 * You are attempting to run an openrc service on a
 * system which openrc did not boot.
 * You may be inside a chroot or you may have used
 * another initialization system to boot this system.
 * In this situation, you will get unpredictable results!
 * If you really want to do this, issue the following command:
 * touch /run/openrc/softlevel
 * ERROR: devfs failed to start
grep: /proc/filesystems: No such file or directory

似乎还是不理想QQ

然而走到这步,其实已经是debug过一轮状况。首先,还是要感谢Linux系统程序工程师救火的MVP— — QEMU。在我第一轮把mmap2 syscall num fix过的libc推进去重编後,initramfs中的apk装东西、跟search时都会segfault掉。

然而我在使用几篇的小技巧,:bootstrap riscv32 aports时,可以在 bootstrap.sh 中把 sysroot 留住(加上 abuild -r -R),原本我只是想要继续用qemu linux-user mode来比较好debug,但是却发现竟然是好的!?

这下就有趣了,老实说还是懒得直接看code,想直接对一次坏掉跟好的粗略差别,於是我就开启了系统呼叫的tracer来看: qemu-riscv32 -strace -L /path/to/extracted ./sbin/apk -X /home/ruinland/packages/main -U --arch riscv32 --allow-untrusted search alpine 2>&1 | failed_apk.log

跟可以正常运作的版本一比较,发现了这道:
504224 openat(5,"ruinland-6151dfc0.rsa.pub",O_RDONLY|O_LARGEFILE|O_CLOEXEC) = 7

あややや,竟然是拿来bootstrap world的key没塞进initramfs的/etc/apk/keys惹得祸。在前後我们还发现了 Unknown syscall 62 这点,不过这个真的蛮诡异的、因为llseek在qemu的source里面就是62号、musl porting我也是这样填,可能还得找时间验证这是怎麽拐错的。

下一篇的进度,应该会是想办法看看ARM那边冲到能开机时,到底装了哪些套件、有什麽是我riscv32 world还没bootstrap到的。


<<:  那些被忽略但很好用的 Web API / BroadcastChannel

>>:  成为 Scrum Master:更基本的部分

第二十九天:版面组合与重构

金鱼都能懂的网页切版:26、27 版面组合 https://codepen.io/mikeyam/p...

从 JavaScript 角度学 Python(21) - Requests

前言 在 JavaScript 中 AJAX 是一个非常重要的基础功,毕竟现在很流行前後端分离,因此...

Day 28 - State Monad III

嗨大家好,真希望一天能有 48 小时,不然这主题都要分到四部曲了,没错,应该会有四部曲! 抱歉了! ...

Day 11. 来学习如何切换场景!2

有鉴於Junior Programmer: Manage scene flow and data课程...

Day.26 实务应用 - 实作表自动分区管理( event / procedure / partition )_1

procedure简单来说就跟写程序一样,只是procedure是运用资料库的程序语言,透过不同语...