MacOS
This commit is contained in:
@@ -10,8 +10,11 @@ if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
OS="${ID}"
|
||||
OS_LIKE="${ID_LIKE:-}"
|
||||
elif [ "$(uname -s)" = "Darwin" ]; then
|
||||
OS="macos"
|
||||
OS_LIKE="darwin"
|
||||
else
|
||||
echo "Unable to detect operating system: /etc/os-release not found."
|
||||
echo "Unable to detect operating system: /etc/os-release not found and host is not macOS."
|
||||
return 1 2>/dev/null || exit 1
|
||||
fi
|
||||
|
||||
@@ -27,6 +30,10 @@ is_fedora_family() {
|
||||
[[ "$OS" == "fedora" || "$OS" == "bazzite" || " $OS_LIKE " == *" fedora "* || " $OS_LIKE " == *" rhel "* ]]
|
||||
}
|
||||
|
||||
is_macos() {
|
||||
[[ "$OS" == "macos" ]]
|
||||
}
|
||||
|
||||
is_atomic_fedora() {
|
||||
is_fedora_family && command -v rpm-ostree >/dev/null 2>&1 && [ -f /run/ostree-booted ]
|
||||
}
|
||||
@@ -126,6 +133,22 @@ install_packages() {
|
||||
return 0
|
||||
fi
|
||||
|
||||
if is_macos; then
|
||||
if ! command -v brew >/dev/null 2>&1; then
|
||||
echo "Homebrew is required on macOS. Install it from https://brew.sh first."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local pkg
|
||||
for pkg in "${packages[@]}"; do
|
||||
if brew list --formula "$pkg" >/dev/null 2>&1; then
|
||||
continue
|
||||
fi
|
||||
brew install "$pkg"
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Unsupported OS: $OS"
|
||||
return 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user