1 |
commit: 7b6bd40db6c1ab8531a8ee40bede229673f42c1f |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Dec 28 20:45:53 2019 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Dec 29 12:57:25 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7b6bd40d |
7 |
|
8 |
sys-kernel/vanilla-kernel: Enable qemu-based testing |
9 |
|
10 |
Run a quick test whether the built kernel can boot a simple distribution |
11 |
based on Tiny Core Linux. |
12 |
|
13 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
14 |
|
15 |
sys-kernel/vanilla-kernel/Manifest | 2 + |
16 |
.../vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild | 73 +++++++++++++++++++++- |
17 |
2 files changed, 72 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/sys-kernel/vanilla-kernel/Manifest b/sys-kernel/vanilla-kernel/Manifest |
20 |
index 64ab1f46f8c..a3a71cc7a0d 100644 |
21 |
--- a/sys-kernel/vanilla-kernel/Manifest |
22 |
+++ b/sys-kernel/vanilla-kernel/Manifest |
23 |
@@ -1,3 +1,5 @@ |
24 |
DIST linux-5.4.3-arch1.i686.config 241295 BLAKE2B 795b6286bd1e7dc6aa5c1428e7bf08c204ce6c8cbee57863e9f64f8990790cc4398a7d062b54c89b1b80640f02a40fce028d9397725db0f968e8028b0611a20f SHA512 8c7387ded21c02b9cffee0e6d61a7040c44deae21764f743f7719f0d1c7adf684f6b62a501fe31709787ba741859e55fc3b8a3d3d27e52c09f2d8604212bf0a7 |
25 |
DIST linux-5.4.4.arch1-1.amd64.config 241587 BLAKE2B 71db76bf30a8d7f4dc680399b9f9fbb4236d1938bb86e23eb1ab236a667a959fc1cff788f7e432c43a6173e1bac4e20f3a6c3391d84275d46f1f66bd338bf538 SHA512 34d66658963dbd72fa3e96f2c5d5bccafb781fa14f6ebafe7859953929ba2fbb112f1435ca68cec8389d789cf0efa81d5fc0f5ac6dfa23a704348ab83709e9db |
26 |
DIST linux-5.4.6.tar.xz 109454640 BLAKE2B 8619492fedd4ae489a811561f72285b69deb827bb1db1f65be2a128d3bcbb69bdeec6b73650e1e8f72b18e5016c2df092bc77ee38be756d35f2903ecf0db1687 SHA512 9e1153e80303d6d5016856a25f3757259a3a428bad11208192315088d1f1a09957f5b8e966ab8cb5842ce1a740760f87474066294f8b410e9c44c810838bcdac |
27 |
+DIST tinycorelinux-10.1-amd64.qcow2 16842752 BLAKE2B e013e76503c335739a9623c0901ca791937a0e6b177854535cadec1e2c2cd2df588283ed3128cf652595f32264fbfe5b3bd3a8c97665fd4da344e308535be366 SHA512 c3aeb20ff8769da9211694b7f701907cc7ae7582cdfad2c2fdc008d97ebcbd9dc08245b4e8f8450e1cb304bd705345a11fe79f901a47979fee91443841d55641 |
28 |
+DIST tinycorelinux-10.1-x86.qcow2 14876672 BLAKE2B 3c760eb7438b13261e52ecfaa33a53649ced95f1ab40aae52134b8cdc31a16d7aa0d6a6dd716e268ed148e9d77a10b7c700b141b61d70c82d271ffe88e8e2a3c SHA512 9964538dc42f232a11949f74b61d46422ea5da3bdc253a217119bd0b8a750c40fd2da0b07157067be9ac0226472614f210a1248114df0d331df390979867a895 |
29 |
|
30 |
diff --git a/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild b/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild |
31 |
index 62465876eca..26f4a9a172c 100644 |
32 |
--- a/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild |
33 |
+++ b/sys-kernel/vanilla-kernel/vanilla-kernel-5.4.6-r1.ebuild |
34 |
@@ -6,6 +6,7 @@ EAPI=7 |
35 |
inherit mount-boot savedconfig toolchain-funcs |
36 |
|
37 |
MY_P=linux-${PV} |
38 |
+TCL_VER=10.1 |
39 |
AMD64_CONFIG_VER=5.4.4.arch1-1 |
40 |
AMD64_CONFIG_HASH=f101331956bb37080dce191ca789a5c44fac9e69 |
41 |
I686_CONFIG_VER=5.4.3-arch1 |
42 |
@@ -17,17 +18,24 @@ SRC_URI="https://cdn.kernel.org/pub/linux/kernel/v5.x/${MY_P}.tar.xz |
43 |
amd64? ( |
44 |
https://git.archlinux.org/svntogit/packages.git/plain/trunk/config?h=packages/linux&id=${AMD64_CONFIG_HASH} |
45 |
-> linux-${AMD64_CONFIG_VER}.amd64.config |
46 |
+ test? ( |
47 |
+ https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-amd64.qcow2 |
48 |
+ ) |
49 |
) |
50 |
x86? ( |
51 |
https://git.archlinux32.org/packages/plain/core/linux/config.i686?id=${I686_CONFIG_HASH} |
52 |
-> linux-${I686_CONFIG_VER}.i686.config |
53 |
+ test? ( |
54 |
+ https://dev.gentoo.org/~mgorny/dist/tinycorelinux-${TCL_VER}-x86.qcow2 |
55 |
+ ) |
56 |
)" |
57 |
S=${WORKDIR}/${MY_P} |
58 |
|
59 |
LICENSE="GPL-2" |
60 |
SLOT="${PV}" |
61 |
KEYWORDS="~amd64 ~x86" |
62 |
-IUSE="+initramfs" |
63 |
+IUSE="+initramfs test" |
64 |
+RESTRICT="!test? ( test ) test? ( userpriv )" |
65 |
|
66 |
# install-DEPEND actually |
67 |
# note: we need installkernel with initramfs support! |
68 |
@@ -39,7 +47,13 @@ RDEPEND=" |
69 |
initramfs? ( >=sys-kernel/dracut-049-r2 )" |
70 |
BDEPEND=" |
71 |
sys-devel/bc |
72 |
- virtual/libelf" |
73 |
+ virtual/libelf |
74 |
+ test? ( |
75 |
+ dev-tcltk/expect |
76 |
+ sys-kernel/dracut |
77 |
+ amd64? ( app-emulation/qemu[qemu_softmmu_targets_x86_64] ) |
78 |
+ x86? ( app-emulation/qemu[qemu_softmmu_targets_i386] ) |
79 |
+ )" |
80 |
|
81 |
pkg_pretend() { |
82 |
mount-boot_pkg_pretend |
83 |
@@ -112,7 +126,60 @@ src_compile() { |
84 |
} |
85 |
|
86 |
src_test() { |
87 |
- : |
88 |
+ local image_arch=${ARCH} |
89 |
+ local kern_arch=x86 |
90 |
+ local qemu_arch=$(usex amd64 x86_64 i386) |
91 |
+ |
92 |
+ emake O="${WORKDIR}"/build "${MAKEARGS[@]}" \ |
93 |
+ INSTALL_MOD_PATH="${T}" modules_install |
94 |
+ |
95 |
+ dracut \ |
96 |
+ --conf /dev/null \ |
97 |
+ --confdir /dev/null \ |
98 |
+ --no-hostonly \ |
99 |
+ --kmoddir "${T}/lib/modules/${PV}" \ |
100 |
+ "${T}/initrd" "${PV}" || die |
101 |
+ cp "${DISTDIR}/tinycorelinux-${TCL_VER}-${image_arch}.qcow2" \ |
102 |
+ "${T}/fs.qcow2" || die |
103 |
+ |
104 |
+ cd "${T}" || die |
105 |
+ cat > run.sh <<-EOF || die |
106 |
+ #!/bin/sh |
107 |
+ exec qemu-system-${qemu_arch} \ |
108 |
+ -m 256M \ |
109 |
+ -display none \ |
110 |
+ -no-reboot \ |
111 |
+ -kernel '${WORKDIR}/build/arch/${kern_arch}/boot/bzImage' \ |
112 |
+ -initrd '${T}/initrd' \ |
113 |
+ -serial mon:stdio \ |
114 |
+ -hda '${T}/fs.qcow2' \ |
115 |
+ -append 'root=/dev/sda console=ttyS0,115200n8' |
116 |
+ EOF |
117 |
+ chmod +x run.sh || die |
118 |
+ # TODO: initramfs does not let core finish starting on some systems, |
119 |
+ # figure out how to make it better at that |
120 |
+ expect - <<-EOF || die "Booting kernel failed" |
121 |
+ set timeout 900 |
122 |
+ spawn ./run.sh |
123 |
+ expect { |
124 |
+ "Kernel panic" { |
125 |
+ send_error "\n* Kernel panic" |
126 |
+ exit 1 |
127 |
+ } |
128 |
+ "Entering emergency mode" { |
129 |
+ send_error "\n* Initramfs failed to start the system" |
130 |
+ exit 1 |
131 |
+ } |
132 |
+ "Core 10.1" { |
133 |
+ send_error "\n* Booted to login" |
134 |
+ exit 0 |
135 |
+ } |
136 |
+ timeout { |
137 |
+ send_error "\n* Kernel boot timed out" |
138 |
+ exit 2 |
139 |
+ } |
140 |
+ } |
141 |
+ EOF |
142 |
} |
143 |
|
144 |
src_install() { |