问题描述
在我的 Packages.app
的 preinstall
脚本中,我能够从删除 install.sh
检查的 brew 的 sudo
的修改版本安装 brew:
#!/bin/bash
##preinstall
if brew ls --versions wget > /dev/null; then
# The package is installed
osascript -e 'tell app "Finder" to display dialog "The package is installed"'
else
# The package is not installed
osascript -e 'tell app "Finder" to display dialog "The package is not installed"'
/usr/bin/su root -c ./brew-install.sh
fi
exit 0
这是我从 brew 的 install.sh
中删除以使其工作的行:
if [[ "${EUID:-${UID}}" == "0" ]]; then
我不知道 "${EUID:-${UID}}"
到底是什么。
这是我迄今为止尝试失败的方法,而不是使用 su root
:
# /bin/bash -c ./brew-install.sh
# sudo dseditgroup -o edit -a $USER -t user admin
# sudo /usr/bin/su $USER -c ./brew-install.sh
# /usr/bin/su ladmin -c ./brew-install.sh
# nohup /usr/bin/su $USER -c /bin/bash -c ./brew-install.sh &
特别是尝试从这里将 $USER
添加到 admin
组:https://apple.stackexchange.com/a/76096/261453
任何想法/解决方案?
解决方法
您可以使用 brew 的“untar install”选项在没有 root 的情况下安装 Brew: Why brew installation needs sudo access?
在此处查看 Brew 文档: https://docs.brew.sh/Installation#untar-anywhere
如果 Brew 仍因 root
原因而阻塞,您可以修改 Library/Homebrew/bin/brew.sh
以删除 root
检查,然后从 postinstall
rm
现有 {{ 1}} 并将 if 替换为您在 brew.sh
的脚本添加资源中添加的副本: