Debian Codegraph @

lib/iucode-scan-versions

raw
1 #!/bin/sh
2
3 # needrestart - Restart daemons after library updates.
4 #
5 # Authors:
6 # Thomas Liske <[email protected]>
7 #
8 # Copyright Holder:
9 # 2013 - 2025 (C) Thomas Liske <[email protected]>
10 #
11 # License:
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this package; if not, write to the Free Software
24 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
26 # handle verbose mode
27 if [ "$1" = "1" ]; then
28 set -x
29 fi
30
31 # filter for processor signature (and flags if available)
32 sig=$(iucode_tool --scan-system 2>&1 | grep -oE '[^[:space:]]+$') #'
33 if [ -r /sys/devices/system/cpu/cpu0/microcode/processor_flags ]; then
34 filter="-s $sig,"$(cat /sys/devices/system/cpu/cpu0/microcode/processor_flags)
35 else
36 filter="-S"
37 fi
38
39 # allow local command override
40 test -r /etc/needrestart/iucode.sh && . /etc/needrestart/iucode.sh
41
42 # early boot initrd (required at least on Arch Linux)
43 if type bsdtar > /dev/null 2>&1 ; then
44 imgfiles=""
45 for img in /boot/intel-ucode.img /boot/early_ucode.cpio ; do
46 if [ -r "$img" ]; then
47 imgfiles="$imgfiles $img"
48 fi
49 done
50
51 if [ -n "$imgfiles" ]; then
52 cat $imgfiles | bsdtar -Oxf /dev/stdin | iucode_tool -l $filter -tb - 2>&1
53 exit $?
54 fi
55 fi
56
57 # look for microcode updates in the filesystem
58 IUCODE_TOOL_EXTRA_OPTIONS=""
59
60 test -r /etc/default/intel-microcode && . /etc/default/intel-microcode
61
62 # do not scan if adding Intel microcode to initrd is disabled
63 test "$IUCODE_TOOL_INITRAMFS" = "no" && exit 0
64
65 # run iucode_tool to scan for microcodes
66 if [ -n "$(find /usr/share/misc -maxdepth 1 -type f -name 'intel-microcode*' -perm /u+r)" ]; then
67 exec iucode_tool -l $filter --ignore-broken -tb /lib/firmware/intel-ucode -ta /usr/share/misc/intel-microcode* 2>&1
68 exit $?
69 fi
70
71 iucode_tool -l $filter --ignore-broken $IUCODE_TOOL_EXTRA_OPTIONS -tb /lib/firmware/intel-ucode 2>&1 | grep "$sig"