|
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 | 13 | ! blkid -L "EFI" >/dev/null || |
|
22 | 22 | `[ ! -f /etc/initrd.mk.addon ] || cat /etc/initrd.mk.addon` |
23 | 23 | EOF |
24 | 24 |
|
25 | | - grub_install="$( for f in grub-install grub2-install; do type -P "$f" && break; done )" |
26 | | - grub_mkconfig="$( for f in grub-mkconfig grub2-mkconfig; do type -P "$f" && break; done )" |
27 | | - grub_bootdir="$( find /boot -type d \( -name 'grub' -o -name 'grub2' \) )" |
28 | | - grub_params="/etc/default/grub" |
29 | | - |
30 | | - kver="$(find /lib/modules -mindepth 1 -maxdepth 1 -printf '%f\n' -quit)" |
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 | | - |
37 | 25 | tee /sbin/init.once <<-EOF |
38 | 26 | #!/bin/sh |
39 | | - echo; echo; |
40 | | - echo 'IT WORKS!' |
41 | | - echo; echo; |
| 27 | + printf '\n\n\n%s\n\n\n' 'IT WORKS!' |
42 | 28 | exec systemctl reboot |
43 | 29 | EOF |
44 | 30 | chmod +x /sbin/init.once |
|
49 | 35 | DefaultDependencies=no |
50 | 36 | After=systemd-user-sessions.service plymouth-quit-wait.service |
51 | 37 | Before=system-getty.slice |
52 | | - |
53 | 38 | [Service] |
54 | 39 | Type=oneshot |
55 | 40 | ExecStart=/sbin/init.once |
56 | 41 | RemainAfterExit=yes |
57 | 42 | StandardOutput=tty |
58 | | - |
59 | 43 | [Install] |
60 | 44 | WantedBy=sysinit.target |
61 | 45 | EOF |
62 | 46 |
|
63 | 47 | systemctl enable init-once |
64 | 48 |
|
65 | | - tee -a "$grub_params" <<-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_DISABLE_LINUX_PARTUUID=true |
73 | | - GRUB_ENABLE_BLSCFG=false |
74 | | - GRUB_DEVICE=root=LABEL=root |
75 | | - EOF |
76 | | - |
77 | | - bootdev=$(findmnt -k -no SOURCE -T /boot) |
78 | | - syspath="$(readlink -ev "/sys/class/block/${bootdev#/dev/}")" |
79 | | - syspath="${syspath%/*}/uevent" |
80 | | - bootdev="$(sed -n -e 's,^DEVNAME=,/dev/,p' "$syspath")" |
| 49 | + env -i PATH="$PATH" \ |
| 50 | + /srv/.build/dest/usr/sbin/make-initrd -k "$kver" |
81 | 51 |
|
82 | | - "$grub_install" "$bootdev" |
83 | | - "$grub_mkconfig" -o "$grub_bootdir/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/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 |
84 | 104 |
|
85 | | - cat "$grub_params" |
86 | 105 | { |
87 | 106 | find /boot \! -type d -printf '%M %p\n' |
88 | 107 | find /boot -type l -printf '%M %p -> %l\n' |
|
0 commit comments