summarylogtreecommitdiffstats
path: root/dracut-install.sh
blob: a36514213cc81239db95e889fc9af85ec0f36698 (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
#!/usr/bin/env bash

args=('--force' '--strip' '--aggressive-strip' '--reproducible')

while read -r line; do
	if [[ "$line" == 'usr/lib/modules/'+([^/])'/pkgbase' ]]; then
		read -r pkgbase < "/${line}"
		kver="${line#'usr/lib/modules/'}"
		kver="${kver%'/pkgbase'}"

		install -Dm0644 "/${line%'/pkgbase'}/vmlinuz" "/boot/vmlinuz-${pkgbase}"

		# detect if the ESP directory is /boot or /efi
		efi_dirpath="/boot/EFI/Linux"
		if [ -d "/efi/EFI" ]; then
			efi_dirpath="/efi/EFI/Linux"
		fi

		dracut "${args[@]}" --kver "$kver" --uefi "${efi_dirpath}/${pkgbase}.efi"
		#dracut --no-hostonly --no-hostonly-cmdline "${args[@]}" "/boot/initramfs-${pkgbase}-fallback.img" --kver "$kver"
		
		sbctl sign -s -o  "${efi_dirpath}/${pkgbase}.efi"  "${efi_dirpath}/${pkgbase}.efi"

		if [ -f "${efi_dirpath}/${pkgbase}-fallback.efi" ]; then
			sbctl sign -s -o  "${efi_dirpath}/${pkgbase}-fallback.efi"  "${efi_dirpath}/${pkgbase}-fallback.efi"
		fi
	fi
done