Skip to content

Commit 7bcf788

Browse files
committedJan 2, 2025··
testing: Reduce the difference in creating initramfs between different vendors
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
·
2.54.02.51.0
1 parent ede6b7d commit 7bcf788

File tree

6 files changed

+182
-130
lines changed

6 files changed

+182
-130
lines changed
 

‎.github/workflows/ci.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,9 @@ jobs:
110110
"zfs-partition",
111111
]
112112
exclude:
113-
- name: fedora
114-
testcase: efi-partition
115-
- name: fedora
116-
testcase: efi-reqpartition
117113
- name: fedora
118114
testcase: zfs-partition
119115

120-
- name: ubuntu
121-
testcase: efi-partition
122-
- name: ubuntu
123-
testcase: efi-reqpartition
124-
125116
- name: altlinux
126117
testcase: zfs-partition
127118

‎testing/packages-fedora

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MAKE_INITRD_PACKAGES_DEVEL+=" json-c-devel"
1111

1212
KERNEL_PACKAGES="kernel kernel-modules"
1313

14-
BOOTLOADER_EFI_PACKAGES="grub2-efi-x64 grub2-efi-x64-modules"
14+
BOOTLOADER_EFI_PACKAGES="systemd-boot-unsigned"
1515
BOOTLOADER_PC_PACKAGES="grub2-pc grub2-pc-modules"
1616

1717
SYSIMAGE_BASE_PACKAGES="$MAKE_INITRD_PACKAGES $KERNEL_PACKAGES systemd"

‎testing/packages-ubuntu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ MAKE_INITRD_PACKAGES_DEVEL+=" libjson-c-dev"
1111

1212
KERNEL_PACKAGES="linux-generic"
1313

14-
BOOTLOADER_EFI_PACKAGES="grub-efi"
14+
BOOTLOADER_EFI_PACKAGES="systemd-boot systemd-boot-efi"
1515
BOOTLOADER_PC_PACKAGES="grub-pc"
1616

1717
SYSIMAGE_BASE_PACKAGES="$MAKE_INITRD_PACKAGES $KERNEL_PACKAGES systemd"
Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
%post --erroronfail
22
set -xefu
33

4-
mkdir -p /proc
5-
mount -t proc proc /proc
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)"
66

7-
mkdir -p /sys
8-
mount -t sysfs sysfs /sys
7+
mkdir -p /proc /sys /dev
98

10-
mkdir -p /dev
9+
mount -t proc proc /proc
10+
mount -t sysfs sysfs /sys
1111
mount -t devtmpfs devfs /dev
1212

1313
! blkid -L "EFI" >/dev/null ||
@@ -16,76 +16,74 @@
1616
blkid
1717
findmnt
1818

19-
echo "ENABLE=no" > /etc/sysconfig/framebuffer
20-
2119
tee /etc/initrd.mk <<-EOF
20+
IMAGEFILE = /boot/initrd-\$(KERNEL)\$(IMAGE_SUFFIX).img
2221
AUTODETECT = all
2322
`[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon`
2423
EOF
2524

26-
kver="$(readlink -ev /boot/vmlinuz)"
27-
kver="${kver##*/vmlinuz-}"
28-
29-
env -i PATH="$PATH" \
30-
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
31-
3225
tee /sbin/init.once <<-EOF
3326
#!/bin/sh
34-
echo; echo;
35-
echo 'IT WORKS!'
36-
echo; echo;
37-
exec reboot
27+
printf '\n\n\n%s\n\n\n' 'IT WORKS!'
28+
exec systemctl reboot
3829
EOF
3930
chmod +x /sbin/init.once
4031

41-
tee -a /etc/inittab <<-EOF
42-
z0:3:once:/sbin/init.once
43-
EOF
44-
4532
tee -a /usr/lib/systemd/system/init-once.service <<-EOF
4633
[Unit]
4734
Description=Make-initrd target
4835
DefaultDependencies=no
4936
After=systemd-user-sessions.service plymouth-quit-wait.service
5037
Before=system-getty.slice
51-
5238
[Service]
5339
Type=oneshot
5440
ExecStart=/sbin/init.once
5541
RemainAfterExit=yes
5642
StandardOutput=tty
57-
5843
[Install]
5944
WantedBy=sysinit.target
6045
EOF
6146

62-
systemctl enable init-once ||:
47+
systemctl enable init-once
48+
49+
env -i PATH="$PATH" \
50+
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
51+
52+
grub_install="$( for f in grub-install grub2-install; do type -P "$f" && break; done )"
53+
grub_mkconfig="$( for f in grub-mkconfig grub2-mkconfig; do type -P "$f" && break; done )"
54+
grub_bootdir="$( find /boot -type d \( -name 'grub' -o -name 'grub2' \) )"
55+
grub_params="/etc/sysconfig/grub2"
6356

64-
tee -a /etc/sysconfig/grub2 <<-EOF
65-
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 fastboot @CMDLINE@'
57+
tee -a "$grub_params" <<-EOF
58+
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
6659
GRUB_TIMEOUT=3
6760
GRUB_TERMINAL_INPUT='serial console'
6861
GRUB_TERMINAL_OUTPUT='serial console'
6962
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
7063
EOF
7164

72-
if ! blkid -L "EFI" >/dev/null; then
73-
bootdev=$(findmnt -k -no SOURCE -T /boot)
74-
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
75-
syspath="${syspath%/*}/uevent"
76-
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
77-
78-
grub-install "$bootdev"
65+
if blkid -L "EFI" >/dev/null; then
66+
"$grub_install" \
67+
--root-directory "/" \
68+
--boot-directory "/boot" \
69+
--efi-directory "/boot/efi" \
70+
#
7971
else
80-
strace -e %file efibootmgr ||:
81-
grub-install \
82-
--root-directory "/" \
83-
--boot-directory "/boot" \
84-
--efi-directory "/boot/efi" \
85-
#
72+
bootdev=$(findmnt -k -no SOURCE -T /boot)
73+
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
74+
syspath="${syspath%/*}/uevent"
75+
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
76+
77+
"$grub_install" "$bootdev"
8678
fi
8779

88-
grub-mkconfig -o /boot/grub/grub.cfg
80+
"$grub_mkconfig" -o "$grub_bootdir/grub.cfg"
81+
82+
cat "$grub_params"
83+
{
84+
find /boot \! -type d -printf '%M %p\n'
85+
find /boot -type l -printf '%M %p -> %l\n'
86+
} | sort -t\ -k1,1
8987

9088
umount /proc /sys /dev
9189
%end

‎testing/testing-fedora-ks-initrd.cfg

Lines changed: 68 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
%post --erroronfail
22
set -xefu
33

4-
mkdir -p /proc
5-
mount -t proc proc /proc
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)"
66

7-
mkdir -p /sys
8-
mount -t sysfs sysfs /sys
7+
mkdir -p /proc /sys /dev
98

10-
mkdir -p /dev
9+
mount -t proc proc /proc
10+
mount -t sysfs sysfs /sys
1111
mount -t devtmpfs devfs /dev
1212

13+
! blkid -L "EFI" >/dev/null ||
14+
mount -t efivarfs none /sys/firmware/efi/efivars
15+
1316
blkid
1417
findmnt
1518

@@ -19,18 +22,9 @@
1922
`[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon`
2023
EOF
2124

22-
kver="$(find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' -quit)"
23-
24-
export PATH="/srv/.build/dest/usr/sbin:/srv/.build/dest/usr/bin:$PATH"
25-
26-
env -i PATH="$PATH" \
27-
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
28-
2925
tee /sbin/init.once <<-EOF
3026
#!/bin/sh
31-
echo; echo;
32-
echo 'IT WORKS!'
33-
echo; echo;
27+
printf '\n\n\n%s\n\n\n' 'IT WORKS!'
3428
exec systemctl reboot
3529
EOF
3630
chmod +x /sbin/init.once
@@ -41,41 +35,77 @@
4135
DefaultDependencies=no
4236
After=systemd-user-sessions.service plymouth-quit-wait.service
4337
Before=system-getty.slice
44-
4538
[Service]
4639
Type=oneshot
4740
ExecStart=/sbin/init.once
4841
RemainAfterExit=yes
4942
StandardOutput=tty
50-
5143
[Install]
5244
WantedBy=sysinit.target
5345
EOF
5446

5547
systemctl enable init-once
5648

57-
tee -a /etc/default/grub <<-EOF
58-
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
59-
GRUB_TIMEOUT=3
60-
GRUB_TERMINAL_INPUT='serial console'
61-
GRUB_TERMINAL_OUTPUT='serial console'
62-
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
63-
GRUB_DISABLE_LINUX_UUID=true
64-
GRUB_DISABLE_LINUX_PARTUUID=true
65-
GRUB_ENABLE_BLSCFG=false
66-
GRUB_DEVICE=root=LABEL=root
67-
EOF
68-
69-
bootdev=$(findmnt -k -no SOURCE -T /boot)
70-
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
71-
syspath="${syspath%/*}/uevent"
72-
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
73-
74-
grub2-install "$bootdev"
75-
grub2-mkconfig -o /boot/grub2/grub.cfg
49+
env -i PATH="$PATH" \
50+
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
7651

77-
ls -la /boot
78-
cat /etc/default/grub
52+
if blkid -L "EFI" >/dev/null; then
53+
bootctl install
54+
55+
bootdir="$(bootctl --print-esp-path)"
56+
57+
mkdir -p -- "$bootdir"/loader/entries
58+
mv -f -- \
59+
"/boot/vmlinuz-$kver" \
60+
"/boot/initramfs-$kver.img" \
61+
"$bootdir"
62+
63+
tee "$bootdir"/loader/loader.conf <<-EOF
64+
default default-kernel
65+
timeout 0
66+
EOF
67+
68+
tee "$bootdir"/loader/entries/default-kernel.conf <<-EOF
69+
title Default Linux
70+
linux /vmlinuz-$kver
71+
initrd /initramfs-$kver.img
72+
options console=ttyS0,115200n8 @CMDLINE@
73+
EOF
74+
75+
bootctl --no-pager
76+
else
77+
grub_install="$( for f in grub-install grub2-install; do type -P "$f" && break; done )"
78+
grub_mkconfig="$( for f in grub-mkconfig grub2-mkconfig; do type -P "$f" && break; done )"
79+
grub_bootdir="$( find /boot -type d \( -name 'grub' -o -name 'grub2' \) )"
80+
grub_params="/etc/default/grub"
81+
82+
tee -a "$grub_params" <<-EOF
83+
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
84+
GRUB_TIMEOUT=3
85+
GRUB_TERMINAL_INPUT='serial console'
86+
GRUB_TERMINAL_OUTPUT='serial console'
87+
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
88+
GRUB_DISABLE_LINUX_UUID=true
89+
GRUB_DISABLE_LINUX_PARTUUID=true
90+
GRUB_ENABLE_BLSCFG=false
91+
GRUB_DEVICE=root=LABEL=root
92+
EOF
93+
94+
bootdev=$(findmnt -k -no SOURCE -T /boot)
95+
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
96+
syspath="${syspath%/*}/uevent"
97+
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
98+
99+
"$grub_install" "$bootdev"
100+
"$grub_mkconfig" -o "$grub_bootdir/grub.cfg"
101+
102+
cat "$grub_params"
103+
fi
104+
105+
{
106+
find /boot \! -type d -printf '%M %p\n'
107+
find /boot -type l -printf '%M %p -> %l\n'
108+
} | sort -t\ -k1,1
79109

80110
umount /proc /sys /dev
81111
%end

‎testing/testing-ubuntu-ks-initrd.cfg

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,30 @@
11
%post --erroronfail
22
set -xefu
33

4-
mkdir -p /proc
5-
mount -t proc proc /proc
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)"
66

7-
mkdir -p /sys
8-
mount -t sysfs sysfs /sys
7+
mkdir -p /proc /sys /dev
98

10-
mkdir -p /dev
9+
mount -t proc proc /proc
10+
mount -t sysfs sysfs /sys
1111
mount -t devtmpfs devfs /dev
1212

13+
! blkid -L "EFI" >/dev/null ||
14+
mount -t efivarfs none /sys/firmware/efi/efivars
15+
1316
blkid
1417
findmnt
1518

16-
cat /etc/fstab
17-
18-
# Hack. Drop symlink if any.
19-
cat /etc/os-release > /etc/os-release.$$
20-
rm -f /etc/os-release
21-
mv /etc/os-release.$$ /etc/os-release
22-
2319
tee /etc/initrd.mk <<-EOF
2420
IMAGEFILE = /boot/initrd.img-\$(KERNEL)\$(IMAGE_SUFFIX)
2521
AUTODETECT = all
2622
`[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon`
2723
EOF
2824

29-
kver="$(readlink -ev /boot/vmlinuz)"
30-
kver="${kver##*/vmlinuz-}"
31-
32-
export PATH="/srv/.build/dest/usr/sbin:/srv/.build/dest/usr/bin:$PATH"
33-
34-
env -i PATH="$PATH" \
35-
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
36-
3725
tee /sbin/init.once <<-EOF
3826
#!/bin/sh
39-
echo; echo;
40-
echo 'IT WORKS!'
41-
echo; echo;
27+
printf '\n\n\n%s\n\n\n' 'IT WORKS!'
4228
exec systemctl reboot
4329
EOF
4430
chmod +x /sbin/init.once
@@ -49,36 +35,83 @@
4935
DefaultDependencies=no
5036
After=systemd-user-sessions.service plymouth-quit-wait.service
5137
Before=system-getty.slice
52-
5338
[Service]
5439
Type=oneshot
5540
ExecStart=/sbin/init.once
5641
RemainAfterExit=yes
5742
StandardOutput=tty
58-
5943
[Install]
6044
WantedBy=sysinit.target
6145
EOF
6246

6347
systemctl enable init-once
6448

65-
tee -a /etc/default/grub <<-EOF
66-
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
67-
GRUB_TIMEOUT=3
68-
GRUB_TERMINAL_INPUT='serial console'
69-
GRUB_TERMINAL_OUTPUT='serial console'
70-
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
71-
GRUB_DISABLE_LINUX_UUID=true
72-
GRUB_DEVICE=root=LABEL=root
73-
EOF
74-
75-
bootdev=$(findmnt -k -no SOURCE -T /boot)
76-
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
77-
syspath="${syspath%/*}/uevent"
78-
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
49+
env -i PATH="$PATH" \
50+
/srv/.build/dest/usr/sbin/make-initrd -k "$kver"
7951

80-
grub-install "$bootdev"
81-
grub-mkconfig -o /boot/grub/grub.cfg
52+
if blkid -L "EFI" >/dev/null; then
53+
bootctl install
54+
55+
bootdir="$(bootctl --print-esp-path)"
56+
57+
mkdir -p -- "$bootdir"/loader/entries
58+
mv -f -- \
59+
"/boot/vmlinuz-$kver" \
60+
"/boot/initrd.img-$kver" \
61+
"$bootdir"
62+
63+
tee "$bootdir"/loader/loader.conf <<-EOF
64+
default default-kernel
65+
timeout 0
66+
EOF
67+
68+
tee "$bootdir"/loader/entries/default-kernel.conf <<-EOF
69+
title Default Linux
70+
linux /vmlinuz-$kver
71+
initrd /initrd.img-$kver
72+
options console=ttyS0,115200n8 @CMDLINE@
73+
EOF
74+
75+
bootctl --no-pager
76+
else
77+
grub_install="$( for f in grub-install grub2-install; do type -P "$f" && break; done )"
78+
grub_mkconfig="$( for f in grub-mkconfig grub2-mkconfig; do type -P "$f" && break; done )"
79+
grub_bootdir="$( find /boot -type d \( -name 'grub' -o -name 'grub2' \) )"
80+
grub_params="/etc/default/grub"
81+
82+
tee -a "$grub_params" <<-EOF
83+
GRUB_CMDLINE_LINUX_DEFAULT='console=ttyS0,115200n8 @CMDLINE@'
84+
GRUB_TIMEOUT=3
85+
GRUB_TERMINAL_INPUT='serial console'
86+
GRUB_TERMINAL_OUTPUT='serial console'
87+
GRUB_SERIAL_COMMAND='serial --unit=0 --speed=115200'
88+
GRUB_DISABLE_LINUX_UUID=true
89+
GRUB_DEVICE=root=LABEL=root
90+
EOF
91+
92+
# Hack. Drop symlink. This change is necessary to avoid an error:
93+
# /etc/grub.d/10_linux_zfs: 403: .: cannot open /tmp/zfsmnt.QMGi2Y/etc/os-release: No such file
94+
if [ -L /etc/os-release ]; then
95+
cat /etc/os-release > /etc/os-release.$$
96+
rm -f /etc/os-release
97+
mv /etc/os-release.$$ /etc/os-release
98+
fi
99+
100+
bootdev=$(findmnt -k -no SOURCE -T /boot)
101+
syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")"
102+
syspath="${syspath%/*}/uevent"
103+
bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")"
104+
105+
"$grub_install" "$bootdev"
106+
"$grub_mkconfig" -o "$grub_bootdir/grub.cfg"
107+
108+
cat "$grub_params"
109+
fi
110+
111+
{
112+
find /boot \! -type d -printf '%M %p\n'
113+
find /boot -type l -printf '%M %p -> %l\n'
114+
} | sort -t\ -k1,1
82115

83116
umount /proc /sys /dev
84117
%end

0 commit comments

Comments
 (0)
Please sign in to comment.