feat(darwin): update check_cpu_flag() to support Darwin

This commit is contained in:
Martin Wimpress 2024-05-14 18:22:43 +01:00 committed by Martin Wimpress
parent 6000546e35
commit 178619d673
1 changed files with 14 additions and 4 deletions

View File

@ -244,12 +244,22 @@ function get_cpu_info() {
}
function check_cpu_flag() {
local HOST_CPU_FLAG="${1}"
local HOST_CPU_FLAG=""
if [ ${DARWIN} -eq 1 ]; then
HOST_CPU_FLAG="${1}^^"
if sysctl -n machdep.cpu.features | grep -o "${HOST_CPU_FLAG}" > /dev/null; then
return 0
else
return 1
fi
else
HOST_CPU_FLAG="${1},,"
if lscpu | grep -o "^Flags\b.*: .*\b${HOST_CPU_FLAG}\b" > /dev/null; then
return 0
else
return 1
fi
fi
}
function efi_vars() {