Create mkinitcpio presets
This commit is contained in:
parent
5b44ed0eeb
commit
85b85ac4a3
5 changed files with 74 additions and 6 deletions
7
PKGBUILD
7
PKGBUILD
|
@ -1,5 +1,5 @@
|
|||
pkgname=eos-systemd-boot
|
||||
pkgver=0.03
|
||||
pkgver=0.1
|
||||
pkgrel=1
|
||||
pkgdesc='Enables systemd-boot automation using kernel-install on EndeavourOS'
|
||||
arch=(any)
|
||||
|
@ -20,9 +20,4 @@ package()
|
|||
# mask the default loaderentry creator
|
||||
mkdir -p "${pkgdir}/etc/kernel/install.d"
|
||||
touch "${pkgdir}/etc/kernel/install.d/90-loaderentry.install"
|
||||
|
||||
# mask the mkinitcpio hooks
|
||||
mkdir -p "${pkgdir}/etc/pacman.d/hooks"
|
||||
touch "${pkgdir}/etc/pacman.d/hooks/90-mkinitcpio-install.hook"
|
||||
touch "${pkgdir}/etc/pacman.d/hooks/60-mkinitcpio-remove.hook"
|
||||
}
|
||||
|
|
10
src/etc/pacman.d/hooks/60-mkinitcpio-remove.hook
Normal file
10
src/etc/pacman.d/hooks/60-mkinitcpio-remove.hook
Normal file
|
@ -0,0 +1,10 @@
|
|||
[Trigger]
|
||||
Type = Path
|
||||
Operation = Remove
|
||||
Target = usr/lib/modules/*/vmlinuz
|
||||
|
||||
[Action]
|
||||
Description = Removing mkinitcpio presets...
|
||||
When = PreTransaction
|
||||
Exec = /usr/share/libalpm/scripts/kernel-install-mkinitcpio-remove
|
||||
NeedsTargets
|
11
src/etc/pacman.d/hooks/90-mkinitcpio-install.hook
Normal file
11
src/etc/pacman.d/hooks/90-mkinitcpio-install.hook
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Trigger]
|
||||
Type = Path
|
||||
Operation = Install
|
||||
Operation = Upgrade
|
||||
Target = usr/lib/modules/*/vmlinuz
|
||||
|
||||
[Action]
|
||||
Description = Installing mkinitcpio presets...
|
||||
When = PostTransaction
|
||||
Exec = /usr/share/libalpm/scripts/kernel-install-mkinitcpio-install
|
||||
NeedsTargets
|
|
@ -0,0 +1,38 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
while read -r line; do
|
||||
|
||||
if ! read -r pkgbase > /dev/null 2>&1 < "${line%/vmlinuz}/pkgbase"; then
|
||||
# if the kernel has no pkgbase, we skip it
|
||||
continue
|
||||
fi
|
||||
|
||||
# parse the input
|
||||
version=$(basename "${line%/vmlinuz}")
|
||||
vmlinuz="/${line}"
|
||||
packagename=$(cat ${line%/vmlinuz}/pkgbase)
|
||||
|
||||
preset_file="/etc/mkinitcpio.d/${packagename}.preset"
|
||||
|
||||
# get the machine-id
|
||||
machineid=$(cat /etc/machine-id)
|
||||
if [[ -z ${machineid} ]]; then
|
||||
echo "Failed to get the machine ID"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Find the configured esp
|
||||
esp=$(bootctl -p)
|
||||
|
||||
# create a preset compatible with kernel-install
|
||||
preset_file="/etc/mkinitcpio.d/${packagename}.preset"
|
||||
echo ":: Modifying ${preset_file}"
|
||||
|
||||
echo 'ALL_config="/etc/mkinitcpio.conf"' > ${preset_file}
|
||||
echo 'ALL_kver="'"${esp}/${machineid}/${version}/linux"'"' >> ${preset_file}
|
||||
echo 'PRESETS=('default' 'fallback')' >> ${preset_file}
|
||||
echo 'default_image="'"${esp}/${machineid}/${version}/initrd"'"' >> ${preset_file}
|
||||
echo 'fallback_image="'"${esp}/${machineid}/${version}/initrd-fallback"'"' >> ${preset_file}
|
||||
echo 'fallback_options="-S autodetect"' >> ${preset_file}
|
||||
|
||||
done
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
while read -r line; do
|
||||
if ! read -r pkgbase > /dev/null 2>&1 < "${line%/vmlinuz}/pkgbase"; then
|
||||
# if the kernel has no pkgbase, we skip it
|
||||
continue
|
||||
fi
|
||||
|
||||
# remove the preset for the package being removed
|
||||
preset="/etc/mkinitcpio.d/${pkgbase}.preset"
|
||||
if [[ -e ${preset} ]]; then
|
||||
rm ${preset}
|
||||
fi
|
||||
done
|
Loading…
Add table
Reference in a new issue