Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

mac - set file mode and group owner for pkg-installed Brave.app #13111

Merged
merged 1 commit into from
Feb 13, 2018
Merged
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
14 changes: 14 additions & 0 deletions build/pkg-scripts/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@
# Extract a referral / promo code from the installer path of the format /dir/path/Setup-Brave-Anything-xxx001.pkg
# where the promo code would be xxx001
installerPath=$1
installationPath=$2
# TODO: ugly to assume the name of the app, especially with multi-channel.
# Luckily for now, release channel is the only channel with a pkg installer.
installationAppPath="$installationPath/Brave.app"
installerPathPromoCodeRegex='.+-([a-zA-Z0-9]{3}[0-9]{3})\s?(?:\([0-9]+\))?\.pkg$'
userDataDir="$HOME/Library/Application Support/brave"
promoCodePath="$userDataDir/promoCode"
# pkg runs this script as root so we need to get current username
userName="$USER"
echo "Installer path is: $installerPath"
echo "Username is: $userName"
echo "Installation app path is: $installationAppPath"

# Fix the permissions on installed .app so that updater has permissions to write new version
# by default pkg with install the .app with root:wheel owner and 'drwxr-xr-x' permission.
# Since the app is run by the user, and the updater built-in to electron does not successfully
# escalate to root permissions, updating will fail.
# We'll allow all standard users of the machine permissions to run and update the app.
sudo chmod -R 775 "$installationAppPath"
sudo chgrp -R staff "$installationAppPath"

# Detect if installer contained a referral promotion code within the filename
if [[ $installerPath =~ $installerPathPromoCodeRegex ]]; then
echo "Installer path matched for promo code"
n=${#BASH_REMATCH[*]}
Expand Down