Skip to content

Commit

Permalink
Fix pkg installer not opening BGMApp if relocated.
Browse files Browse the repository at this point in the history
If the user moved BGMApp and then installed a new version from a .pkg,
BGMApp would be installed to the same place the old version had been
moved to. When pkg/postinstall tried to open BGMApp, it would fail
because it assumed BGMApp would be installed to /Applications.

Also, the installer now fails with an error message if it can't open
BGMApp after finishing the install.

Fixes #164.
  • Loading branch information
kyleneideck committed Oct 4, 2018
1 parent 1a49802 commit ac33909
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# Based on https://github.com/tekezo/Karabiner-Elements/blob/master/make-package.sh
#

# TODO: Code signing. See `man pkgbuild`.
# TODO: Code signing. See `man productbuild`.

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin"; export PATH

Expand Down Expand Up @@ -162,6 +162,7 @@ pkgbuild \

productbuild \
--distribution "pkg/Distribution.xml" \
--identifier "$pkg_identifier" \
--resources "pkgres" \
--package-path "$out_dir" \
"$pkg"
Expand Down
11 changes: 9 additions & 2 deletions pkg/postinstall
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#
# postinstall
#
# Copyright © 2017 Kyle Neideck
# Copyright © 2017, 2018 Kyle Neideck
#

PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
Expand Down Expand Up @@ -50,7 +50,14 @@ bash "post_install.sh" "$xpc_helper_path" "BGMXPCHelper.xpc/Contents/MacOS/BGMXP
killall coreaudiod &>/dev/null) && \
sleep 5

open "${dest_volume}/Applications/Background Music.app"
# Try opening BGMApp using its bundle ID first so the installer can declare it as "relocatable".
# That way, if the user moves BGMApp and then installs a newer version of Background Music, the
# installer will try to find the old version of BGMApp and put the new one in the same place.
#
# If we can't open BGMApp, it very likely didn't install properly, so we fail the install.
open -b com.bearisdriving.BGM.App || \
open "${dest_volume}/Applications/Background Music.app" || \
exit 1

# The installer plays a sound when it finishes, so give BGMApp a second to launch.
sleep 1
Expand Down

0 comments on commit ac33909

Please sign in to comment.