From b93ba7d1e876e81ac1d21b256fe9fcd580cb9fc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Wed, 2 Mar 2022 23:45:15 +0100 Subject: =?UTF-8?q?Add=20=C2=B5Code-updates=20to=20syslinux=20initrd.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifests/init.pp | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/manifests/init.pp b/manifests/init.pp index 8428b5c..d7bd375 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -42,14 +42,27 @@ class syslinux ( $device = $facts['mountpoints']['/']['device'] $partuuid = $facts['blkid'][$device]['PARTUUID'] + + $cpus = $facts['processors']['models'] + $has_amd = $cpus.any |$i| { $i =~ /AMD/ } + $has_intel = $cpus.any |$i| { $i =~ /Intel/ } + + if $has_amd { ensure_packages(['amd-ucode']) } + if $has_intel { ensure_packages(['intel-ucode']) } + $entries = $boot_entries.map |$key, $entry| { case $entry['type'] { 'linux': { $extra_args = $entry['extra_args'] $initrd = $entry['initrd'] + $initrd_multi = [ + if $has_amd { '../amd-ucode.img' }, + if $has_intel { '../intel-ucode.img' }, + "../arch/${initrd}", + ].filter |$i| { $i != undef }.join(',') $hash = { 'APPEND' => "root=PARTUUID=${partuuid} rw ${extra_args}", - 'INITRD' => "../arch/${initrd}", + 'INITRD' => $initrd_multi, 'LINUX' => "../arch/vmlinuz-${kernel}", } } @@ -99,11 +112,23 @@ class syslinux ( mode => '0555', content => @("EOF"/$) #!/bin/sh + # File managed by Puppet IFS='\n' read data cp "/\$data" "${efi_root}/EFI/arch/vmlinuz-${kernel}" | EOF } + file { '/usr/libexec/move-ucode': + ensure => file, + mode => '0555', + content => @("EOF"/$) + #!/bin/sh + # File managed by Puppet + IFS='\n' read data + cp "/\$data" "${efi_root}/EFI/" + | EOF + } + pacman::hook { 'install-kernel': priority => 60, # something less than /usr/share/libalpm/hooks/90-mkinitcpio-install.hook trigger => { @@ -116,4 +141,18 @@ class syslinux ( exec => '/usr/libexec/move-kernel', needsTargets => true , } + + + pacman::hook { 'install-ucode-initrd': + priority => 60, + trigger => { + type => 'Path', + operation => [ 'Install', 'Upgrade' ], + target => [ 'boot/*-ucode.img', ], + }, + description => 'Moving µCode-updates to EFI', + when => 'PostTransaction', + exec => '/usr/libexec/move-ucode', + needsTargets => true , + } } -- cgit v1.2.3