|
1 | 1 | %post --erroronfail |
2 | 2 | set -xefu |
3 | 3 |
|
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)" |
6 | 6 |
|
7 | | - mkdir -p /sys |
8 | | - mount -t sysfs sysfs /sys |
| 7 | + mkdir -p /proc /sys /dev |
9 | 8 |
|
10 | | - mkdir -p /dev |
| 9 | + mount -t proc proc /proc |
| 10 | + mount -t sysfs sysfs /sys |
11 | 11 | mount -t devtmpfs devfs /dev |
12 | 12 |
|
| 13 | + ! blkid -L "EFI" >/dev/null || |
| 14 | + mount -t efivarfs none /sys/firmware/efi/efivars |
| 15 | + |
13 | 16 | blkid |
14 | 17 | findmnt |
15 | 18 |
|
|
19 | 22 | `[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon` |
20 | 23 | EOF |
21 | 24 |
|
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 | | - |
29 | 25 | tee /sbin/init.once <<-EOF |
30 | 26 | #!/bin/sh |
31 | | - echo; echo; |
32 | | - echo 'IT WORKS!' |
33 | | - echo; echo; |
| 27 | + printf '\n\n\n%s\n\n\n' 'IT WORKS!' |
34 | 28 | exec systemctl reboot |
35 | 29 | EOF |
36 | 30 | chmod +x /sbin/init.once |
|
41 | 35 | DefaultDependencies=no |
42 | 36 | After=systemd-user-sessions.service plymouth-quit-wait.service |
43 | 37 | Before=system-getty.slice |
44 | | - |
45 | 38 | [Service] |
46 | 39 | Type=oneshot |
47 | 40 | ExecStart=/sbin/init.once |
48 | 41 | RemainAfterExit=yes |
49 | 42 | StandardOutput=tty |
50 | | - |
51 | 43 | [Install] |
52 | 44 | WantedBy=sysinit.target |
53 | 45 | EOF |
54 | 46 |
|
55 | 47 | systemctl enable init-once |
56 | 48 |
|
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" |
76 | 51 |
|
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 |
79 | 109 |
|
80 | 110 | umount /proc /sys /dev |
81 | 111 | %end |
0 commit comments