mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00

- Allow specifying user through `/var/tmp/.homebrew_pkg_user.plist` - Improve permission handling - Correctly write API cache - Add `preinstall` script to fail if we can't get a valid user Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
18 lines
554 B
Bash
Executable File
18 lines
554 B
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
homebrew_pkg_user_plist="/var/tmp/.homebrew_pkg_user.plist"
|
|
if [[ -f "${homebrew_pkg_user_plist}" ]] && [[ -n $(defaults read "${homebrew_pkg_user_plist}" HOMEBREW_PKG_USER) ]]
|
|
then
|
|
exit 0
|
|
fi
|
|
|
|
homebrew_pkg_user=$(echo "show State:/Users/ConsoleUser" | scutil | awk '/Name :/ { print $3 }')
|
|
if [[ "${homebrew_pkg_user}" =~ _mbsetupuser|loginwindow|root ]] || [[ -z "${homebrew_pkg_user}" ]]
|
|
then
|
|
echo "No valid user for Homebrew installation. Log in before install or specify an install user."
|
|
exit 1
|
|
else
|
|
exit 0
|
|
fi
|