summarylogtreecommitdiffstats
path: root/dracut-install
blob: 681461a02bbd3c905344f774c1a763ee8212f9ab (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
#!/bin/bash -e

all=0
lines=()

while read -r line; do
	if [[ "${line}" != */vmlinuz ]]; then
		# triggers when it's a change to dracut files
		all=1
		continue
	fi

	lines+=("${line%/vmlinuz}")

	pkgbase="$(<"${lines[-1]}/pkgbase")"
	install -Dm644 "${line}" "/boot/vmlinuz-${pkgbase}"
done

if (( all )); then
	lines=(/usr/lib/modules/*)
fi

for line in "${lines[@]}"; do
	if ! pacman -Qqo "${line}/pkgbase" &> /dev/null; then
		# if pkgbase does not belong to any package then skip this kernel
		continue
	fi

	pkgbase="$(<"${line}/pkgbase")"
	kver="${line##*/}"

	echo ":: Building initramfs for ${pkgbase} (${kver})"
	dracut --force --hostonly --no-hostonly-cmdline "/boot/initramfs-${pkgbase}.img" "${kver}"

	echo ":: Building fallback initramfs for ${pkgbase} (${kver})"
	dracut --force --no-hostonly "/boot/initramfs-${pkgbase}-fallback.img" "${kver}"
done