Skip to content

Commit 9e91486

Browse files
committed
testing: Add gentoo
Add make-initrd tests on gentoo. This is preparation for an additional musl compatibility check, which is more convenient to do on gentoo. Signed-off-by: Alexey Gladkov <[email protected]>
1 parent aad49b5 commit 9e91486

File tree

5 files changed

+360
-1
lines changed

5 files changed

+360
-1
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ jobs:
7979
name: [
8080
"altlinux",
8181
"fedora",
82+
"gentoo",
8283
"ubuntu",
8384
]
8485
fail-fast: true
@@ -116,6 +117,7 @@ jobs:
116117
name: [
117118
"altlinux",
118119
"fedora",
120+
"gentoo",
119121
"ubuntu",
120122
]
121123
testcase: [
@@ -150,6 +152,9 @@ jobs:
150152
- name: altlinux
151153
testcase: zfs-partition
152154

155+
- name: gentoo
156+
testcase: zfs-partition
157+
153158
fail-fast: false
154159
steps:
155160
- name: "Prepare Node"

testing/ks-gentoo-initrd.cfg

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
%post --erroronfail
2+
set -xefu
3+
4+
export PATH="/srv/.build/dest/usr/sbin:/srv/.build/dest/usr/bin:$PATH"
5+
kver="$(find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' -quit)"
6+
7+
mkdir -p /proc /sys /dev
8+
9+
mount -t proc proc /proc
10+
mount -t sysfs sysfs /sys
11+
mount -t devtmpfs devfs /dev
12+
13+
! blkid -L "EFI" >/dev/null ||
14+
mount -t efivarfs none /sys/firmware/efi/efivars
15+
16+
blkid
17+
findmnt
18+
19+
tee /etc/initrd.mk <<-EOF
20+
IMAGEFILE = /boot/initramfs-\$(KERNEL)\$(IMAGE_SUFFIX).img
21+
AUTODETECT = all
22+
`[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon`
23+
EOF
24+
25+
tee /sbin/init.once <<-EOF
26+
#!/bin/sh
27+
printf '\n\n\n%s\n\n\n' 'IT WORKS!'
28+
exec systemctl reboot
29+
EOF
30+
chmod +x /sbin/init.once
31+
32+
tee -a /usr/lib/systemd/system/init-once.service <<-EOF
33+
[Unit]
34+
Description=Make-initrd target
35+
DefaultDependencies=no
36+
After=systemd-user-sessions.service plymouth-quit-wait.service
37+
Before=system-getty.slice
38+
[Service]
39+
Type=oneshot
40+
ExecStart=/sbin/init.once
41+
RemainAfterExit=yes
42+
StandardOutput=tty
43+
[Install]
44+
WantedBy=sysinit.target
45+
EOF
46+
47+
systemctl enable init-once
48+
49+
env -i PATH="$PATH" \
50+
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
51+
52+
cp -vLf -- "/lib/modules/$kver/vmlinuz" "/boot/vmlinuz-$kver"
53+
54+
if blkid -L "EFI" >/dev/null; then
55+
bootctl install
56+
57+
bootdir="$(bootctl --print-esp-path)"
58+
59+
mkdir -p -- "$bootdir"/loader/entries
60+
mv -f -- \
61+
"/boot/vmlinuz-$kver" \
62+
"/boot/initramfs-$kver.img" \
63+
"$bootdir"
64+
65+
tee "$bootdir"/loader/loader.conf <<-EOF
66+
default default-kernel
67+
timeout 0
68+
EOF
69+
70+
tee "$bootdir"/loader/entries/default-kernel.conf <<-EOF
71+
title Default Linux
72+
linux /vmlinuz-$kver
73+
initrd /initramfs-$kver.img
74+
options console=ttyS0,115200n8 @CMDLINE@
75+
EOF
76+
77+
bootctl --no-pager
78+
else
79+
grub_install="$( for f in grub-install grub2-install; do type -P "$f" && break; done )"
80+
grub_mkconfig="$( for f in grub-mkconfig grub2-mkconfig; do type -P "$f" && break; done )"
81+
grub_params="/etc/default/grub"
82+
83+
tee -a "$grub_params" <<-EOF
84+
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
85+
GRUB_DEFAULT=0
86+
GRUB_TIMEOUT=3
87+
GRUB_TERMINAL_INPUT='serial console'
88+
GRUB_TERMINAL_OUTPUT='serial console'
89+
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
90+
GRUB_DISABLE_LINUX_UUID=true
91+
GRUB_DISABLE_LINUX_PARTUUID=true
92+
GRUB_ENABLE_BLSCFG=false
93+
GRUB_DEVICE=root=LABEL=ROOT
94+
EOF
95+
96+
bootdev=$(findmnt -k -no SOURCE -T /boot)
97+
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
98+
syspath="${syspath%/*}/uevent"
99+
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
100+
101+
"$grub_install" "$bootdev"
102+
103+
grub_bootdir="$( find /boot -type d \( -name 'grub' -o -name 'grub2' \) )"
104+
105+
"$grub_mkconfig" -o "$grub_bootdir/grub.cfg"
106+
107+
cat "$grub_params"
108+
fi
109+
110+
{
111+
find /boot \! -type d -printf '%M %p\n'
112+
find /boot -type l -printf '%M %p -> %l\n'
113+
} | sort -t\ -k1,1
114+
115+
umount /proc /sys /dev
116+
%end

testing/packages-gentoo

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
MAKE_INITRD_PACKAGES="app-alternatives/cpio app-arch/tar dev-build/make"
5+
MAKE_INITRD_PACKAGES+=" dev-libs/elfutils net-libs/libtirpc sys-apps/coreutils"
6+
MAKE_INITRD_PACKAGES+=" sys-apps/findutils sys-apps/grep sys-apps/kmod sys-apps/util-linux"
7+
MAKE_INITRD_PACKAGES+=" virtual/libcrypt:= virtual/udev app-arch/bzip2 app-arch/xz-utils"
8+
MAKE_INITRD_PACKAGES+=" app-text/scdoc sys-libs/zlib app-arch/zstd dev-libs/json-c"
9+
10+
MAKE_INITRD_PACKAGES_DEVEL="$MAKE_INITRD_PACKAGES dev-build/autoconf dev-build/automake"
11+
MAKE_INITRD_PACKAGES_DEVEL+=" dev-util/intltool sys-devel/bison sys-devel/flex"
12+
MAKE_INITRD_PACKAGES_DEVEL+=" virtual/pkgconfig"
13+
14+
KERNEL_PACKAGES="sys-kernel/gentoo-kernel-bin"
15+
16+
INIT_PACKAGES="sys-apps/systemd"
17+
18+
#ZFS_PACKAGES="sys-fs/zfs sys-fs/zfs-kmod"
19+
ZFS_PACKAGES=""
20+
21+
SYSIMAGE_PACKAGES="$MAKE_INITRD_PACKAGES $INIT_PACKAGES"
22+
SYSIMAGE_PACKAGES+=" app-admin/pwgen sys-fs/mdadm sys-fs/lvm2 sys-fs/cryptsetup"
23+
SYSIMAGE_PACKAGES+=" sys-fs/btrfs-progs sys-fs/e2fsprogs sys-fs/xfsprogs sys-fs/dosfstools"
24+
SYSIMAGE_PACKAGES+=" sys-boot/grub"
25+
SYSIMAGE_PACKAGES+=" $ZFS_PACKAGES"
26+
27+
KICKSTART_PACKAGES="$MAKE_INITRD_PACKAGES_DEVEL $INIT_PACKAGES"
28+
KICKSTART_PACKAGES+=" sys-fs/e2fsprogs sys-fs/btrfs-progs sys-fs/xfsprogs sys-fs/dosfstools"
29+
KICKSTART_PACKAGES+=" sys-fs/cryptsetup sys-fs/lvm2 sys-fs/mdadm sys-apps/util-linux"
30+
KICKSTART_PACKAGES+=" net-misc/rsync net-misc/wget app-arch/unzip app-arch/tar"
31+
KICKSTART_PACKAGES+=" app-arch/cpio app-admin/pwgen app-arch/zstd sys-fs/f2fs-tools"
32+
KICKSTART_PACKAGES+=" $ZFS_PACKAGES"

testing/sh-functions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ pack_sysimage()
6666
#!/bin/bash -efux
6767
6868
bytes=\$(du -sb /image |cut -f1)
69-
bytes=\$(( \$bytes + ( ( \$bytes * 30 ) / 100 ) ))
69+
bytes=\$(( \$bytes * 2 ))
7070
7171
dd count=1 bs=\$bytes if=/dev/zero of=/host/$workdir/sysimage.img
7272
/sbin/mke2fs -t ext3 -L SYSIMAGE -d /image /host/$workdir/sysimage.img

testing/testing-gentoo-local

Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
#!/bin/bash -efu
2+
# SPDX-License-Identifier: GPL-3.0-or-later
3+
4+
topdir="$(readlink -ev "$0")"
5+
topdir="${topdir%/*/*}"
6+
7+
. "$topdir/testing/sh-functions"
8+
9+
readonly VENDOR=gentoo
10+
readonly ARCH=x86_64
11+
readonly IMAGE=gentoo/stage3:systemd
12+
13+
. "$topdir/testing/packages-$VENDOR"
14+
15+
if [ "$#" -gt 1 ]; then
16+
TESTNAME="$1"; shift
17+
eval $(sed -n -e 's/^# param //p' "$topdir/testing/$TESTNAME.cfg")
18+
else
19+
TESTNAME=
20+
fi
21+
22+
readonly builddir=/srv
23+
24+
readonly workdir="testing/cache/$VENDOR/$TESTNAME"
25+
readonly logdir="testing/logs/$VENDOR/$TESTNAME"
26+
readonly statusdir="$topdir/testing/status"
27+
28+
readonly top_workdir="$topdir/$workdir"
29+
readonly top_logdir="$topdir/$logdir"
30+
31+
prepare_testsuite
32+
33+
n=$(grep -c '^processor' /proc/cpuinfo 2>/dev/null || echo 1)
34+
n=$(( $n * 2 ))
35+
36+
emerge_args="--quiet --ask=n --getbinpkg --autounmask-write --jobs=$n --newuse --update"
37+
38+
image_cleanup()
39+
{
40+
printf '%s ||:; ' \
41+
"find /usr/share/locale/ -mindepth 3 -maxdepth 3 -type f -name '*.mo' -delete" \
42+
"find /usr/share/doc/ -mindepth 1 -delete" \
43+
"find /usr/share/groff/ -mindepth 1 -delete" \
44+
"find /usr/share/info/ -mindepth 1 -delete" \
45+
"find /usr/share/man/ -mindepth 1 -delete" \
46+
"find /var/tmp/portage/ -mindepth 1 -delete" \
47+
"find /usr/src/ -mindepth 1 -delete" \
48+
"find /lib/firmware $(find_ignore_firmware) -delete" \
49+
"find /lib/modules $(find_ignore_kmodules) -delete"
50+
printf '\n'
51+
}
52+
53+
for step in "$@"; do
54+
case "$step" in
55+
create-images)
56+
run podman image build --squash --force-rm \
57+
--pull=missing \
58+
-t "localhost/image-$VENDOR:sysimage" \
59+
-f - <<-EOF
60+
FROM $IMAGE
61+
ENV FEATURES="-ipc-sandbox -network-sandbox -pid-sandbox"
62+
ENV USE="boot lvm -initramfs"
63+
RUN getuto >/dev/null
64+
RUN emerge-webrsync --quiet
65+
RUN emerge $emerge_args $KERNEL_PACKAGES
66+
RUN emerge $emerge_args $SYSIMAGE_PACKAGES
67+
RUN emerge --depclean --with-bdeps=n --ask=n
68+
RUN $(image_depmod)
69+
RUN \
70+
find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' | while read -r kver; do \
71+
for i in vmlinuz System.map config; do \
72+
if [ -f "/lib/modules/\$kver/\$i" ]; then \
73+
cp -vL "/lib/modules/\$kver/\$i" "/lib/modules/\$kver/\$i.real"; \
74+
rm -v "/lib/modules/\$kver/\$i"; \
75+
mv -v "/lib/modules/\$kver/\$i.real" "/lib/modules/\$kver/\$i"; \
76+
fi; \
77+
done; \
78+
done;
79+
RUN $(image_cleanup)
80+
RUN \
81+
for i in \$(portageq pkgdir) \$(portageq distdir) \$(portageq get_repo_path / gentoo); do \
82+
find "\$i" -mindepth 1 -delete; \
83+
done
84+
RUN mkdir -p /srv
85+
EOF
86+
87+
run podman image build --squash --force-rm \
88+
--pull=never \
89+
-t "localhost/image-$VENDOR:devel" \
90+
-f - <<-EOF
91+
FROM localhost/image-$VENDOR:sysimage
92+
ENV USE="boot lvm -initramfs"
93+
RUN emerge-webrsync --quiet
94+
RUN emerge $emerge_args $KERNEL_PACKAGES
95+
RUN emerge $emerge_args $KICKSTART_PACKAGES
96+
RUN emerge --depclean --with-bdeps=n --ask=n
97+
RUN $(image_depmod)
98+
RUN $(image_cleanup)
99+
RUN mkdir -p /srv
100+
EOF
101+
;;
102+
build-sources)
103+
gh_group_start "building from git tree"
104+
105+
cat_exec "$top_workdir/run.sh" <<-EOF
106+
#!/bin/bash -efux
107+
108+
cd "$builddir"
109+
rc=0
110+
111+
./autogen.sh
112+
./configure \
113+
--enable-local-build \
114+
--with-runtimedir=/lib/initrd1 || rc=\$?
115+
116+
if [ "\$rc" != 0 ]; then
117+
echo '========================================='
118+
cat config.log
119+
exit 1
120+
fi
121+
122+
make || rc=\$?
123+
124+
if [ "\$rc" != 0 ]; then
125+
echo '========================================='
126+
cat config.log
127+
exit 1
128+
fi
129+
EOF
130+
run podman run --rm -i --volume="$topdir:$builddir" \
131+
"localhost/image-$VENDOR:devel" \
132+
"$builddir/$workdir/run.sh"
133+
134+
gh_group_end
135+
;;
136+
build-sysimage)
137+
gh_group_start "packing sysimage"
138+
pack_sysimage
139+
gh_group_end
140+
;;
141+
build-kickstart)
142+
gh_group_start "creating kickstart image"
143+
144+
cat_exec "$top_workdir/run.sh" <<-EOF
145+
#!/bin/bash -efux
146+
147+
kver="\$(find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' -quit)"
148+
149+
cat > /etc/initrd.mk <<EOF1
150+
AUTODETECT =
151+
IMAGEFILE = /boot/initrd-ks.img
152+
DISABLE_FEATURES += ucode
153+
FEATURES = add-modules add-udev-rules kickstart qemu rdshell modules-virtio modules-blockdev
154+
MODULES_ADD += sd_mod
155+
MODULES_PRELOAD += virtio-blk virtio-scsi virtio-pci
156+
KICKSTART_CONFIGS = $builddir/$workdir/ks.cfg
157+
PUT_PROGS += pwgen
158+
EOF1
159+
160+
for i in vmlinuz System.map config; do
161+
[ ! -e "/lib/modules/\$kver/\$i" ] || cp -vL "/lib/modules/\$kver/\$i" "/boot/\$i-\$kver"
162+
done
163+
164+
export PATH="$builddir/.build/dest/usr/sbin:$builddir/.build/dest/usr/bin:\$PATH"
165+
166+
$builddir/.build/dest/usr/sbin/make-initrd -v -k \$kver
167+
168+
cp -vL /boot/vmlinuz-\$kver $builddir/$workdir/boot-ks-vmlinuz
169+
cp -vL /boot/initrd-ks.img $builddir/$workdir/boot-ks-initrd.img
170+
EOF
171+
172+
podman run --rm -i \
173+
--volume="$topdir:$builddir" \
174+
"localhost/image-$VENDOR:devel" \
175+
"$builddir/$workdir/run.sh"
176+
177+
gh_group_end
178+
;;
179+
run-kickstart)
180+
gh_group_start "creating qemu kickstart disks"
181+
182+
BOOT_PROG=
183+
BOOT_KERNEL="$top_workdir/boot-ks-vmlinuz"
184+
BOOT_INITRD="$top_workdir/boot-ks-initrd.img"
185+
BOOT_APPEND='console=ttyS0,115200n8 quiet rdlog=console ksfile=ks.cfg'
186+
187+
qemu_setup_cpu
188+
qemu_setup_kickstart_disks
189+
qemu_exec
190+
191+
gh_group_end
192+
;;
193+
run-boot)
194+
gh_group_start "checking the ability to boot"
195+
196+
qemu_setup_cpu
197+
qemu_setup_boot_disks
198+
qemu_exec
199+
200+
gh_group_end
201+
;;
202+
*)
203+
fatal "unknown step: $step"
204+
;;
205+
esac
206+
done

0 commit comments

Comments
 (0)