From a4c725aa84c4bc6f5ff999ee86fdfd74346730d2 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 30 Jun 2017 14:53:29 +0200 Subject: [PATCH 1/2] mxgrub: Factor out initramfs code to `create_initramfs` --- mxgrub/create_initramfs | 37 +++++++++++++++++++++++++++++++++++++ mxgrub/mxgrub | 2 +- 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 mxgrub/create_initramfs diff --git a/mxgrub/create_initramfs b/mxgrub/create_initramfs new file mode 100644 index 00000000..4a761e0b --- /dev/null +++ b/mxgrub/create_initramfs @@ -0,0 +1,37 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "You need to supply an initrd file name" + exit 1 +fi + +# Prepare microcode updates for AMD and Intel processors +DSTDIR=kernel/x86/microcode +INITRDNAME="$1" +INITRDPATH=/boot/grub/"$INITRDNAME".igz +INITRDDIR="$TMPDIR"/"$INITRDNAME" +mkdir -p "$INITRDDIR" +cd "$INITRDDIR" +mkdir -p "$DSDDIR" + +if [ -d /lib/firmware/amd-ucode ]; then + cat /lib/firmware/amd-ucode/microcode_amd*.bin > "$DSTDIR"/AuthenticAMD.bin +fi + +if [ -d /lib/firmware/intel-ucode ]; then + cat /lib/firmware/intel-ucode/* > "$DSTDIR"/GenuineIntel.bin +fi + +find . | cpio -o -H newc > "$TMPDIR"/ucode.cpio + +cd .. + +# Clean up +rm -rf "$INITRDDIR" + +cd /project/admin/initramfs +find .|cpio -H newc -o | gzip > "$TMPDIR"/"$INITRDNAME" + +# +cat ucode.cpio $INITRDNAME > /boot/grub/"$INITRDNAME" +rm "$TMPDIR"/ucode.cpio "$TMPDIR"/"$INITRDNAME" diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index 5c80f866..c991e0f7 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -252,7 +252,7 @@ sub cmd_update { } sub cmd_initramfs { - sys('bash','-c','cd /project/admin/initramfs;find .|cpio -H newc -o | gzip > /boot/grub/initramfs.igz'); + sys('/project/mxtools/mxgrub/create_initramfs', 'initramfs'); } our ($opt_list,$opt_update,$opt_initramfs,$opt_test); From 0bad22b0a1bf48be1eede9ee76452914fc48104e Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 30 Jun 2017 17:02:43 +0200 Subject: [PATCH 2/2] mxgrub: Install binary in path --- mxgrub/create_initramfs | 14 +++++++++----- mxgrub/mxgrub | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) mode change 100644 => 100755 mxgrub/create_initramfs diff --git a/mxgrub/create_initramfs b/mxgrub/create_initramfs old mode 100644 new mode 100755 index 4a761e0b..658b52e4 --- a/mxgrub/create_initramfs +++ b/mxgrub/create_initramfs @@ -1,5 +1,7 @@ #!/bin/sh +set -x + if [ -z "$1" ]; then echo "You need to supply an initrd file name" exit 1 @@ -9,10 +11,10 @@ fi DSTDIR=kernel/x86/microcode INITRDNAME="$1" INITRDPATH=/boot/grub/"$INITRDNAME".igz -INITRDDIR="$TMPDIR"/"$INITRDNAME" +INITRDDIR="$TMPDIR/$INITRDNAME" mkdir -p "$INITRDDIR" cd "$INITRDDIR" -mkdir -p "$DSDDIR" +mkdir -p "$DSTDIR" if [ -d /lib/firmware/amd-ucode ]; then cat /lib/firmware/amd-ucode/microcode_amd*.bin > "$DSTDIR"/AuthenticAMD.bin @@ -22,7 +24,9 @@ if [ -d /lib/firmware/intel-ucode ]; then cat /lib/firmware/intel-ucode/* > "$DSTDIR"/GenuineIntel.bin fi +ls -ltr "$TMPDIR" find . | cpio -o -H newc > "$TMPDIR"/ucode.cpio +ls -ltr "$TMPDIR" cd .. @@ -30,8 +34,8 @@ cd .. rm -rf "$INITRDDIR" cd /project/admin/initramfs -find .|cpio -H newc -o | gzip > "$TMPDIR"/"$INITRDNAME" +find .|cpio -H newc -o | gzip > "$TMPDIR/$INITRDNAME.igz" # -cat ucode.cpio $INITRDNAME > /boot/grub/"$INITRDNAME" -rm "$TMPDIR"/ucode.cpio "$TMPDIR"/"$INITRDNAME" +cat "$TMPDIR"/ucode.cpio "$TMPDIR/$INITRDNAME.igz" > /boot/grub/"$INITRDNAME.igz" +rm "$TMPDIR"/ucode.cpio "$TMPDIR"/"$INITRDNAME.igz" diff --git a/mxgrub/mxgrub b/mxgrub/mxgrub index c991e0f7..5fb288fc 100755 --- a/mxgrub/mxgrub +++ b/mxgrub/mxgrub @@ -252,7 +252,7 @@ sub cmd_update { } sub cmd_initramfs { - sys('/project/mxtools/mxgrub/create_initramfs', 'initramfs'); + sys('create_initramfs', 'initramfs'); } our ($opt_list,$opt_update,$opt_initramfs,$opt_test);