From 71a20eedec4a86b778cc1167039cc18ef6760f5b Mon Sep 17 00:00:00 2001 From: walker0643 <> Date: Tue, 13 Feb 2018 22:11:56 -0500 Subject: [PATCH] automate building mac installer --- build_mac_installer.sh | 61 +++++++++++++++++++ .../bundle/Barrier.app/Contents/Info.plist.in | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100755 build_mac_installer.sh diff --git a/build_mac_installer.sh b/build_mac_installer.sh new file mode 100755 index 00000000..8a815047 --- /dev/null +++ b/build_mac_installer.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +# change this to rename the installer package +B_DMG="Barrier-v1.9.dmg" + +# sanity check so we don't distribute packages full of debug symbols +echo Make sure you have built the Release version!! +echo Press Enter to continue or Ctrl+C to abort +read + +cd $(dirname $0) + +# remove any old copies so there's no confusion about whever this +# process completes successfully or not +rm -rf build/bundle/{bundle.dmg,$B_DMG} + +B_BINARY_PATH=$(pwd)/build/bin +cd build/bundle/Barrier.app/Contents 2>/dev/null +if [ $? -ne 0 ]; then + echo Please make sure that the build completed successfully + echo before trying to create the installer. + exit 1 +fi + +# MacOS folder holds the executables, non-system libraries, +# and the startup script +rm -rf MacOS +mkdir MacOS || exit 1 +cd MacOS || exit 1 + +# copy all executables +cp ${B_BINARY_PATH}/* . || exit 1 + +# only one executable (barrier) needs non-system libraries. +# get a list of them and make local copies +B_LIBS=$(otool -XL barrier | awk '{ print $1 }' | grep -Ev '^(/usr/lib|/System)') +[ $? -ne 0 ] && exit 1 +for B_SRC in $B_LIBS; do + cp $B_SRC . || exit 1 + B_DST=@executable_path/$(basename $B_SRC) + # adjust the executable's metadata to point to the local copy + # rather than the system-wide copy which would only exist on + # a development machine + install_name_tool -change $B_SRC $B_DST barrier || exit 1 +done + +# create a startup script that will change to the binary directory +# before starting barrier +printf "%s\n" "#!/bin/sh" "cd \$(dirname \$0)" "exec ./barrier" > barrier.sh +chmod +x barrier.sh + +# create the DMG to be distributed in build/bundle +cd ../../.. +hdiutil create -size 32m -fs HFS+ -volname "Barrier" bundle.dmg || exit 1 +hdiutil attach bundle.dmg -mountpoint mnt || exit 1 +cp -r Barrier.app mnt/ || exit 1 +hdiutil detach mnt || exit 1 +hdiutil convert bundle.dmg -format UDZO -o $B_DMG || exit 1 +rm bundle.dmg + +echo "Installer created successfully" diff --git a/dist/macos/bundle/Barrier.app/Contents/Info.plist.in b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in index 277963ae..b973f5e9 100644 --- a/dist/macos/bundle/Barrier.app/Contents/Info.plist.in +++ b/dist/macos/bundle/Barrier.app/Contents/Info.plist.in @@ -6,7 +6,7 @@ CFBundleDisplayName Barrier CFBundleExecutable - barrier + barrier.sh CFBundleIconFile Barrier.icns CFBundleIdentifier