Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified macOS installation to only use native tools #46

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# This script installs the Brave browser using the OS's package manager
# Requires: coreutils, grep, sh, sudo/doas (except macOS)
# Requires: coreutils, grep, sh, sudo/doas
# Source: https://github.com/brave/install.sh

# Browser requirements
Expand Down Expand Up @@ -36,7 +36,7 @@ main() {

## Find and/or install the necessary tools

if [ "$(id -u)" = 0 ] || [ "$os" = Darwin ]; then
if am_admin; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we ever want to install using sudo on macos

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would only happen if the user is not in the admin group, which is necessary to install in /Applications without sudo.

Or is there something else that would be better to do in this case?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't seem right, but I guess I have never really used an account that isn't in the admin group. I think it's likely very uncommon

sudo=""
elif available sudo; then
sudo="sudo"
Expand Down Expand Up @@ -111,19 +111,12 @@ main() {
fi

elif [ "$os" = Darwin ]; then
if available brew; then
NONINTERACTIVE=1 show brew install --cask brave-browser
mihaiplesa marked this conversation as resolved.
Show resolved Hide resolved
echo "Installation complete! Start Brave by typing: open -a Brave\ Browser"
else
if available curl || available wget; then
dmg="$(mktemp ~/Downloads/Brave-Browser-XXXXXXXX.dmg)"
show $curl -L https://laptop-updates.brave.com/latest/osx >"${dmg:?}"
show open "$dmg"
else
show open https://laptop-updates.brave.com/latest/osx
fi
echo "Please follow the usual installation steps with the downloaded Brave-Browser.dmg"
fi
trap '[ -d /Volumes/Brave\ Browser ] && $sudo hdiutil detach -force -quiet /Volumes/Brave\ Browser' EXIT
show $sudo hdiutil attach -quiet https://laptop-updates.brave.com/latest/osx
show $sudo rsync -a --del /Volumes/Brave\ Browser/Brave\ Browser.app /Applications/
mihaiplesa marked this conversation as resolved.
Show resolved Hide resolved
show $sudo hdiutil detach -force -quiet /Volumes/Brave\ Browser || true
echo "Installation complete! Start Brave by typing: open -a Brave\ Browser"
exit

else
error "Could not find a supported package manager. Only apt, dnf, eopkg, paru/pikaur/yay, yum and zypper are supported." "" \
Expand All @@ -133,13 +126,12 @@ main() {
"$(cat /etc/os-release || true)"
fi

if [ "$os" != Darwin ]; then
printf "Installation complete! Start Brave by typing: "
basename "$(command -v brave-browser || command -v brave)"
fi
printf "Installation complete! Start Brave by typing: "
basename "$(command -v brave-browser || command -v brave)"
}

# Helpers
am_admin() { [ "$(id -u)" = 0 ] || ( [ "$os" = Darwin ] && id -Gn|grep -Fwq admin ); }
available() { command -v "${1:?}" >/dev/null; }
error() { exec >&2; printf "Error: "; printf "%s\n" "${@:?}"; exit 1; }
newer() { [ "$(printf "%s\n%s" "$1" "$2"|sort -V|head -n1)" = "${2:?}" ]; }
Expand Down
Loading