Testing support for mkinitcpio

This commit is contained in:
HikariKnight 2022-03-12 18:30:59 +01:00
parent 8c11b69f6d
commit 9870b51c26
No known key found for this signature in database
GPG key ID: E8B239063B022F5A

25
lib/set_MKINITCPIO.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
function set_MKINITCPIO () {
# Get the config paths
source "$SCRIPTDIR/lib/paths.sh"
# Grab the current modules but exclude vfio and vendor-reset
CURRENTMODULES=$(grep -P "^MODULES" /etc/mkinitcpio.conf | perl -pe "s/MODULES=\((.+)\)/\1/")
MODULES="$(grep -P "^MODULES" /etc/mkinitcpio.conf | perl -pe "s/MODULES=\((.+)\)/\1/" | perl -pe "s/\s?(vfio_iommu_type1|vfio_pci|vfio_virqfd|vfio|vendor-reset)\s?//g")"
if [[ $CURRENTMODULES =~ "vendor-reset" ]];
then
perl -pi -e "s/MODULES=\(${CURRENTMODULES}\)/MODULES=\(vendor-reset vfio vfio_iommu_type1 vfio_pci vfio_virqfd ${MODULES}\)/" "$SCRIPTDIR/$MKINITCPIO"
else
perl -pi -e "s/MODULES=\(${CURRENTMODULES}\)/MODULES=\(vfio vfio_iommu_type1 vfio_pci vfio_virqfd ${MODULES}\)/" "$SCRIPTDIR/$MKINITCPIO"
fi
}
function main () {
SCRIPTDIR=$(dirname "$(realpath "$0")" | perl -pe "s/\/\.\.\/lib//" | perl -pe "s/\/lib$//")
set_MKINITCPIO "$1"
}
main "$1"