I’ve noticed the deadlock test in `cask/system_command_spec.rb` appears to fail spuriously, e. g. in #4529.
Details:
https://travis-ci.org/Homebrew/brew/jobs/406827725#L297-L318
With the spec taking 2 seconds on average on my 2017 MBP, I feel it’s
entirely plausible for the aging test-bot hardware to get knocked by
the 15-second timeout.
Given that the spec will pass early anyway if it passes, I feel it’s
reasonable to bump the timeout to 30 seconds.
This commit solves an issue where the environment handed to
`/usr/sbin/installer` is not the same as the environment used by the
graphical PKG installer.
This is evident in some post-install scripts, e. g. the
`component-10.pkg/Scripts/postinstall` script in the `dymo-label`
cask. The code says:
```
USER_ID=`id -u ${USER}`
launchctl bootstrap gui/$USER_ID /Library/LaunchAgents/com.dymo.dls.webservice.plist
```
The graphical installer will export e. g. `USER=alice`, and
everything works as intended.
However, `brew cask install` does not override `sudo`’s default,
which is `USER=ROOT`. This violates the assumptions in the script.
This commit fixes the issue by configuring `sudo` to override the
following environment variables with the proper user name:
- `LOGNAME`
- `USER`
- `USERNAME`