diff --git a/microcode_ctl.spec b/microcode_ctl.spec index 9670ac0..055aa13 100644 --- a/microcode_ctl.spec +++ b/microcode_ctl.spec @@ -12,7 +12,7 @@ Summary: CPU microcode updates for Intel x86 processors Name: microcode_ctl Version: %{intel_ucode_version} -Release: 3%{?dist} +Release: 4%{?dist} Epoch: 4 License: CC0 and Redistributable, no modification permitted URL: https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files @@ -545,6 +545,10 @@ rm -rf %{buildroot} %changelog +* Tue Aug 01 2023 Eugene Syromiatnikov - 4:20230214-4 +- Avoid spurious find failures due to calls on directories that may not exist + (#2225681). + * Wed Jun 28 2023 Eugene Syromiatnikov - 4:20230214-3 - Force locale to C in check_caveats, reload_microcode, and update_ucode (#2218104). diff --git a/update_ucode b/update_ucode index 932cff7..4a033a8 100644 --- a/update_ucode +++ b/update_ucode @@ -17,6 +17,11 @@ usage() debug() { [ 0 = "$verbose" ] || echo "$*" >&2; } +# Calls find only if the first argument exists and is a directory. +# Avoids spurious "find: '...' No such file or directory" for the directories +# that may not exist. +find_d() { [ \! -d "$1" ] || find "$@"; } + MC_DIR=/usr/share/microcode_ctl INTEL_UCODE_DIR=intel-ucode DATA_DIR=/usr/share/microcode_ctl/ucode_with_caveats @@ -81,7 +86,7 @@ add|remove|refresh|list) if [ -z "$kernel" ]; then debug "No kernel versions provided, scanning..." - kvers=$(find /lib/modules/ -name '[2-9].*' -print) + kvers=$(find_d /lib/modules/ -name '[2-9].*' -print) for k_dir in $kvers; do k="${k_dir#/lib/modules/}" [ ! -e "${k_dir}/symvers.gz" ] || { @@ -90,7 +95,7 @@ add|remove|refresh|list) } done - kvers=$(find /lib/firmware/ -name '[2-9].*' -print) + kvers=$(find_d /lib/firmware/ -name '[2-9].*' -print) for k_dir in $kvers; do k="${k_dir#/lib/firmware/}" [ ! -d "$k_dir" ] || { @@ -131,7 +136,7 @@ while :; do refresh|remove|list) debug " Removing old files from ${FW_DIR}/${INTEL_UCODE_DIR}" if [ 0 = "$remove_cleanup" ]; then - find "${MC_DIR}/${INTEL_UCODE_DIR}" \ + find_d "${MC_DIR}/${INTEL_UCODE_DIR}" \ -maxdepth 1 -mindepth 1 \ -type f -printf '%f\n' else @@ -154,7 +159,7 @@ while :; do done [ "xlist" = "x$action" ] || { # Removing possible dangling symlinks - find "${FW_DIR}/${INTEL_UCODE_DIR}" \ + find_d "${FW_DIR}/${INTEL_UCODE_DIR}" \ -maxdepth 1 -mindepth 1 \ -type l -printf '%p\n' \ | while read -r fname; do @@ -216,7 +221,7 @@ fi | while read -r i; do debug " Removing \"$paths\" (part of $action)..." for p in $(printf "%s" "$paths"); do - find "$DATA_DIR/$i" -path "$DATA_DIR/$i/$p" \ + find_d "$DATA_DIR/$i" -path "$DATA_DIR/$i/$p" \ -printf "%P\n" done | while read -r path; do [ -e "$FW_DIR/$k/readme-$i" ] || { @@ -274,7 +279,7 @@ fi | while read -r i; do } for p in $(printf "%s" "$paths"); do - find "$DATA_DIR/$i" -path "$DATA_DIR/$i/$p" \ + find_d "$DATA_DIR/$i" -path "$DATA_DIR/$i/$p" \ -printf "%P\n" done | while read -r path; do [ ! -e "$FW_DIR/$k/$path" ] || { @@ -307,7 +312,7 @@ done debug "Checking for dangling symlinks..." for k in $(echo "$kernel"); do debug " Processing kernel version \"$k\"" - find "${FW_DIR}/${k}" \ + find_d "${FW_DIR}/${k}" \ -mindepth 1 -type l -printf '%p\n' \ | while read -r fname; do [ -e "$fname" ] || {