Symlink brew caller only on intel cpu

This commit is contained in:
T. R. Bernstein
2025-10-18 00:54:21 +02:00
parent d4d03b0bb3
commit 59f627914d

View File

@@ -102,12 +102,14 @@ function getHomebrewRepositoryPath() {
function createBrewCallerScript() { function createBrewCallerScript() {
ensureLocalBinFolder ensureLocalBinFolder
local uname_machine=$(/usr/bin/uname -m)
local username=${homebrew_username} local username=${homebrew_username}
local homebrewRepositoryPath="$(getHomebrewRepositoryPath)" local homebrewRepositoryPath="$(getHomebrewRepositoryPath)"
local brewCallerPath="${homebrewRepositoryPath}/bin/brew-caller" local brewCallerPath="${homebrewRepositoryPath}/bin/brew-caller"
local brewCallerSymlink="/usr/local/bin/brew" local brewCallerSymlink="/usr/local/bin/brew"
[[ -f "${brewCallerPath}" ]] && rm "${brewCallerPath}" [[ -f "${brewCallerPath}" ]] && rm "${brewCallerPath}"
[[ -f "${brewCallerSymlink}" || -h "${brewCallerSymlink}" ]] && rm "${brewCallerSymlink}" [[ -f "${brewCallerSymlink}" || -h "${brewCallerSymlink}" ]] && rm "${brewCallerSymlink}"
[[ ${uname_machine} == "arm64" ]] && brewCallerPath=${brewCallerSymlink}
cat <<- BREWCALLER | clang -x c -O2 -Wall -o "${brewCallerPath}" - cat <<- BREWCALLER | clang -x c -O2 -Wall -o "${brewCallerPath}" -
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
@@ -186,7 +188,7 @@ function createBrewCallerScript() {
BREWCALLER BREWCALLER
chown root:admin ${brewCallerPath} chown root:admin ${brewCallerPath}
chmod 4550 ${brewCallerPath} chmod 4550 ${brewCallerPath}
ln -s "${brewCallerPath}" "${brewCallerSymlink}" [[ ${uname_machine} == "arm64" ]] || ln -s "${brewCallerPath}" "${brewCallerSymlink}"
} }
function createBrewPeriodicScript() { function createBrewPeriodicScript() {