Skip to content

Commit

Permalink
mxgrub: Improve code and implement suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenzel committed Aug 24, 2023
1 parent ff28386 commit f8108a1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,23 @@ sub cmd_update {
update_grub_cfg();
}

sub build_microcode {
my ($pattern, $image, $binname) = @_;
sys(<<"EOF");
set -e
DSTDIR=kernel/x86/microcode
mkdir -p /scratch/local/mxgrub-build-microcode/
cd \$_
mkdir -p "\$DSTDIR"
cat $pattern > "\$DSTDIR"/$binname
find . | cpio -o -H newc > $image
rm -rf /scratch/local/mxgrub-build-microcode/
EOF
}

sub cmd_initramfs {
sys('bash','-c','TMPDIR=/scratch/local DSTDIR="$TMPDIR/kernel/x86/microcode"; mkdir -p "$DSTDIR"; cd "$DSTDIR" ; cat /lib/firmware/amd-ucode/microcode_amd*.bin > $DSTDIR/AuthenticAMD.bin ; find . | cpio -o -H newc > /boot/amd-ucode.img ; rm -rf "$TMPDIR/kernel"');
sys('bash','-c','TMPDIR=/scratch/local DSTDIR="$TMPDIR/kernel/x86/microcode"; mkdir -p "$DSTDIR"; cd "$DSTDIR" ; cat /lib/firmware/intel-ucode/* > $DSTDIR/GenuineIntel.bin ; find . | cpio -o -H newc > /boot/intel-ucode.img ; rm -rf "$TMPDIR/kernel"');
build_microcode('/lib/firmware/amd-ucode/microcode_amd*.bin', '/boot/amd-ucode.img', 'AuthenticAMD.bin');
build_microcode('/lib/firmware/intel-ucode/*', '/boot/intel-ucode.img', 'GenuineIntel.bin');
sys('bash','-c','cd /project/admin/initramfs ; find . -name ".git*" -prune -or -print | cpio -H newc -o | gzip > /boot/grub/initramfs.igz');
}

Expand Down

0 comments on commit f8108a1

Please sign in to comment.