blob: 316204ceef921de54a49cd32c6214fdf1d673ea0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/bin/bash
# Single-entry, systemd-compliant kernel-install hook for CachyOS
set -e
COMMAND="$1" # add | remove
KERNEL_VERSION="$2" # e.g. 6.18.4-1-cachyos
# Only act on CachyOS kernels
case "$KERNEL_VERSION" in
*cachyos*) ;;
*) exit 0 ;;
esac
BOOT_ROOT="${KERNEL_INSTALL_BOOT_ROOT:-/boot}"
ENTRY_DIR="$BOOT_ROOT/loader/entries"
ENTRY_FILE="$ENTRY_DIR/raveos.conf"
# --------------------------------------------------
# Fixed CachyOS kernel paths (non-versioned)
# --------------------------------------------------
LINUX_IMAGE="/vmlinuz-linux-cachyos"
INITRAMFS_IMAGE="/initramfs-linux-cachyos.img"
# --------------------------------------------------
# Microcode (must be first initrd)
# --------------------------------------------------
MICROCODE=""
[ -f "$BOOT_ROOT/intel-ucode.img" ] && MICROCODE="/intel-ucode.img"
[ -f "$BOOT_ROOT/amd-ucode.img" ] && MICROCODE="/amd-ucode.img"
# --------------------------------------------------
# Root device detection
# --------------------------------------------------
# findmnt can come back empty depending on the chroot/mount-namespace
# context this hook runs in (e.g. during pacstrap). Fall back to
# /proc/mounts, and finally /etc/fstab (once it exists), before giving up.
ROOT_SRC="$(findmnt -no SOURCE / || true)"
ROOT_FS="$(findmnt -no FSTYPE / || true)"
ROOT_OPTS="$(findmnt -no OPTIONS / || true)"
if [ -z "$ROOT_SRC" ]; then
ROOT_SRC="$(awk '$2 == "/" {print $1; exit}' /proc/mounts)"
ROOT_FS="$(awk '$2 == "/" {print $3; exit}' /proc/mounts)"
ROOT_OPTS="$(awk '$2 == "/" {print $4; exit}' /proc/mounts)"
fi
if [ -z "$ROOT_SRC" ] && [ -f /etc/fstab ]; then
ROOT_SRC="$(awk '$2 == "/" {print $1; exit}' /etc/fstab)"
ROOT_FS="$(awk '$2 == "/" {print $3; exit}' /etc/fstab)"
ROOT_OPTS="$(awk '$2 == "/" {print $4; exit}' /etc/fstab)"
fi
# /proc/mounts and /etc/fstab may give "UUID=xxxx"/"PARTUUID=xxxx" directly
# instead of a /dev/ path -- resolve to an actual device node so the blkid
# lookups below work either way.
case "$ROOT_SRC" in
UUID=*|PARTUUID=*|LABEL=*)
RESOLVED="$(blkid -t "$ROOT_SRC" -o device 2>/dev/null || true)"
[ -n "$RESOLVED" ] && ROOT_SRC="$RESOLVED"
;;
esac
OPTIONS="rw quiet splash"
# LUKS
if [[ "$ROOT_SRC" == /dev/mapper/* ]]; then
UUID="$(blkid -s UUID -o value "$ROOT_SRC" || true)"
if [ -n "$UUID" ]; then
OPTIONS="cryptdevice=UUID=$UUID:cryptroot root=/dev/mapper/cryptroot $OPTIONS"
else
OPTIONS="root=$ROOT_SRC $OPTIONS"
fi
else
PARTUUID="$(blkid -s PARTUUID -o value "$ROOT_SRC" || true)"
[ -n "$PARTUUID" ] && OPTIONS="root=PARTUUID=$PARTUUID $OPTIONS"
fi
# --------------------------------------------------
# Btrfs subvolume support
# --------------------------------------------------
if [ "$ROOT_FS" = "btrfs" ]; then
SUBVOL="$(echo "$ROOT_OPTS" | tr ',' '\n' | grep '^subvol=' || true)"
[ -n "$SUBVOL" ] && OPTIONS="$OPTIONS rootflags=$SUBVOL"
fi
mkdir -p "$ENTRY_DIR"
case "$COMMAND" in
add)
{
echo "title RaveOS Linux (CachyOS Kernel)"
echo "linux $LINUX_IMAGE"
[ -n "$MICROCODE" ] && echo "initrd $MICROCODE"
echo "initrd $INITRAMFS_IMAGE"
echo "options $OPTIONS"
} > "$ENTRY_FILE"
;;
remove)
# Only remove entry if this was the last CachyOS kernel
rm -f "$ENTRY_FILE"
;;
*)
exit 0
;;
esac
|