2018-02-14 06:11:56 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# change this to rename the installer package
|
2018-03-01 21:05:53 +03:00
|
|
|
B_DMG="Barrier-@BARRIER_VERSION@.dmg"
|
2018-02-14 06:11:56 +03:00
|
|
|
|
2018-02-15 09:17:18 +03:00
|
|
|
# sanity check so we don't distribute packages full of debug symbols
|
2018-03-01 21:05:53 +03:00
|
|
|
if [ "@CMAKE_BUILD_TYPE@" != "Release" ]; then
|
2018-02-15 09:17:18 +03:00
|
|
|
echo Will only build installers for Release builds
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-03-01 21:05:53 +03:00
|
|
|
cd @CMAKE_CURRENT_SOURCE_DIR@/build/bundle || exit 1
|
|
|
|
|
2018-03-01 21:27:58 +03:00
|
|
|
B_REREF_SCRIPT=@CMAKE_CURRENT_SOURCE_DIR@/build/bundle/reref_dylibs.sh
|
2018-02-14 22:41:59 +03:00
|
|
|
if [ ! -x $B_REREF_SCRIPT ]; then
|
|
|
|
echo Missing script: $B_REREF_SCRIPT
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-03-01 21:05:53 +03:00
|
|
|
# remove any old copies so there's no confusion about whether this
|
2018-02-14 06:11:56 +03:00
|
|
|
# process completes successfully or not
|
2018-03-01 21:05:53 +03:00
|
|
|
rm -rf temp.dmg $B_DMG
|
2018-02-14 06:11:56 +03:00
|
|
|
|
2018-03-01 21:05:53 +03:00
|
|
|
cd Barrier.app/Contents 2>/dev/null
|
2018-02-14 06:11:56 +03:00
|
|
|
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
|
2018-03-01 21:22:47 +03:00
|
|
|
cp @CMAKE_RUNTIME_OUTPUT_DIRECTORY@/* . || exit 1
|
2018-02-14 06:11:56 +03:00
|
|
|
|
2018-02-14 22:41:59 +03:00
|
|
|
# copy the qt platform plugin
|
|
|
|
# TODO: this is hacky and will probably break if there is more than one qt
|
|
|
|
# version installed. need a better way to find this library
|
|
|
|
B_COCOA=$(find /usr/local/Cellar/qt -type f -name libqcocoa.dylib | head -1)
|
|
|
|
if [ $? -ne 0 ] || [ "x$B_COCOA" = "x" ]; then
|
|
|
|
echo "Could not find cocoa platform plugin"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mkdir platforms
|
|
|
|
cp $B_COCOA platforms/ || exit 1
|
|
|
|
|
|
|
|
# make sure we can r/w all these binaries
|
|
|
|
chmod -R u+rw * || exit 1
|
|
|
|
|
|
|
|
# only one executable (barrier) needs non-system libraries although it's
|
|
|
|
# libraries can call each other. use a recursive script to handle the
|
|
|
|
# re-referencing
|
|
|
|
$B_REREF_SCRIPT barrier || exit 1
|
|
|
|
# the cocoa platform plugin also needs to know where to find the qt libraries.
|
|
|
|
# because it exists in a subdirectory we append ../ to the relative path of the
|
|
|
|
# libraries in its metadata
|
|
|
|
$B_REREF_SCRIPT platforms/libqcocoa.dylib ../ || exit 1
|
2018-02-14 06:11:56 +03:00
|
|
|
|
|
|
|
# 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 ../../..
|
2018-03-01 21:05:53 +03:00
|
|
|
hdiutil create -size 64m -fs HFS+ -volname "Barrier" temp.dmg || exit 1
|
|
|
|
hdiutil attach temp.dmg -mountpoint mnt || exit 1
|
2018-02-14 06:11:56 +03:00
|
|
|
cp -r Barrier.app mnt/ || exit 1
|
|
|
|
hdiutil detach mnt || exit 1
|
2018-03-01 21:05:53 +03:00
|
|
|
hdiutil convert temp.dmg -format UDZO -o $B_DMG || exit 1
|
|
|
|
rm temp.dmg
|
2018-02-14 06:11:56 +03:00
|
|
|
|
|
|
|
echo "Installer created successfully"
|