Eg. when installing from Brave-Browser-universal.pkg, the previous
implementation gave the following `postinstall` errors in
`/var/log/install.log`:
chmod: /Applications/Brave Browser universal.app: No such file or directory
chown: /Applications/Brave Browser universal.app: No such file or directory
chgrp: /Applications/Brave Browser universal.app: No such file or directory
For lowercase referral codes we normalize them to uppercase. When
stripping the referral code from the filename, that means we need to do
a case insensitive replacement. We use perl instead of sed because macOS
uses BSD sed, which doesn't support the "i" flag for regex.
Fixes https://github.com/brave/brave-browser/issues/9785
* If referral code is given in standard format ([a-zA-Z]{3}[0-9]{3}),
convert to uppercase
* Convert the script to #!/bin/bash because it is full of bash-isms
When run against the release channel, this creates a signed install
pkg that parses a referral code (if any) from its filename and
writes it to user-data-dir. When run against any other channel,
no pkg is created.