pkgbuild open URL using default browser
After echoing some values of preinstall to a temp file and some advice from comments in https://stackoverflow.com/questions/35619036/, I found the following:


$SUDO_USER is empty
logname is root
✅$USER has the correct value


So adopting the script as follows fixes it.  The link is opened in the default browser.

sudo -u "$USER" open "https://apple.stackexchange.com/"


As an aside, the following I had expected to work but it DID NOT work.  This technique still opens in Safari, unfortunately.

su "$USER" -c "open https://apple.stackexchange.com"


So, use sudo -u "$USER" and it should work.