diff --git a/VERSION b/VERSION index a4c528c..7b30067 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.53 +0.1.54 diff --git a/formula/ih-core.rb b/formula/ih-core.rb index b3b6daf..ab3f7c2 100644 --- a/formula/ih-core.rb +++ b/formula/ih-core.rb @@ -1,5 +1,5 @@ class IhCore < Formula - VERSION="0.1.53" + VERSION="0.1.54" desc "Brew formula for installing core tools used at Included Health engineering." homepage "https://github.com/ConsultingMD/homebrew-ih-public" license "CC BY-NC-ND 4.0" diff --git a/lib/core/rancher/step.sh b/lib/core/rancher/step.sh index 7a5c3f0..4408378 100644 --- a/lib/core/rancher/step.sh +++ b/lib/core/rancher/step.sh @@ -12,6 +12,8 @@ RANCHER_AUGMENT_DST="$IH_DEFAULT_DIR/11_rancher.sh" PLIST_SRC="$IH_CORE_LIB_DIR/core/rancher/io.rancherdesktop.profile.defaults.plist" PLIST_DST="$HOME/Library/Preferences/io.rancherdesktop.profile.defaults.plist" +REQUIRED_APPLE_SILICON_MACOS_VERSION="13.3" + # Check if the step has been installed and return 0 if it has. # Otherwise return 1. function ih::setup::core.rancher::test() { @@ -51,10 +53,8 @@ function ih::setup::core.rancher::test() { # Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues. # More details: https://github.com/lima-vm/lima/issues/1996 - local macos_version=$(ih::arch::get_macos_version) if ih::arch::is_m2_or_m3_mac; then - if (( $(echo "$macos_version < 13.3" | bc -l) )); then - ih::log::error "macOS version 13.3 or higher is required for M3 Macs." + if ! ih::arch::check_macos_version_compatibility "$REQUIRED_APPLE_SILICON_MACOS_VERSION"; then return 1 elif ! grep -q "vz" "$PLIST_DST"; then ih::log::debug "The PLIST file needs to be updated to use 'vz' for M3 Macs." @@ -163,8 +163,7 @@ function ih::setup::core.rancher::install() { # Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues. # More details: https://github.com/lima-vm/lima/issues/1996 if ih::arch::is_m2_or_m3_mac; then - if (( $(echo "$macos_version < 13.3" | bc -l) )); then - ih::log::error "macOS version 13.3 or higher is required for M3 Macs." + if ! ih::arch::check_macos_version_compatibility "$REQUIRED_APPLE_SILICON_MACOS_VERSION"; then return 1 # Abort the installation for M3 Macs elif ! grep -q "vz" "$PLIST_DST"; then ih::log::debug "Updating PLIST to use 'vz' for Virtualization for M3 Macs." diff --git a/lib/utils/arch.sh b/lib/utils/arch.sh index dce83f7..9c790e4 100644 --- a/lib/utils/arch.sh +++ b/lib/utils/arch.sh @@ -26,6 +26,28 @@ ih::arch::get_macos_version() { sw_vers -productVersion | awk -F '.' '{ printf("%d.%d\n", $1, $2) }' } +ih::arch::check_macos_version_compatibility() { + local required_version="$1" + local current_version=$(ih::arch::get_macos_version) + + # Splitting the current and required versions into major and minor components + IFS='.' read -r current_major current_minor _ <<< "$current_version" + IFS='.' read -r required_major required_minor _ <<< "$required_version" + + # Ensure variables are integers (default to 0 if empty for robust comparison) + current_major=${current_major:-0} + current_minor=${current_minor:-0} + required_major=${required_major:-0} + required_minor=${required_minor:-0} + + if (( current_major > required_major )) || { (( current_major == required_major )) && (( current_minor >= required_minor )); }; then + return 0 # meets minimum requirement + else + ih::log::error "macOS version $required_version or higher is required. Current version: $current_version." + return 1 + fi +} + ih::arch::is_m2_or_m3_mac() { local hw_model=$(sysctl -n machdep.cpu.brand_string) [[ "$hw_model" == *"M2"* ]] || [[ "$hw_model" == *"M3"* ]]