2013-02-16 22:46:17 +00:00
|
|
|
#!/bin/sh
|
2012-10-21 20:38:19 +00:00
|
|
|
#
|
|
|
|
# this simply automates the steps to create a DMG we can ship
|
2013-02-15 09:17:27 +00:00
|
|
|
#
|
|
|
|
# run this from the top subsurface directory
|
|
|
|
|
2015-09-04 19:13:52 +00:00
|
|
|
# find the directory above the sources - typically ~/src
|
|
|
|
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../.. && pwd )
|
|
|
|
|
2023-12-08 18:31:18 +00:00
|
|
|
DMGCREATE=create-dmg
|
2013-02-15 09:17:27 +00:00
|
|
|
|
2013-02-16 06:28:31 +00:00
|
|
|
# same git version magic as in the Makefile
|
2015-09-04 19:13:52 +00:00
|
|
|
# for the naming of volume and dmg we want the 3 digits of the full version number
|
2024-05-11 05:33:54 +00:00
|
|
|
VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version.sh)
|
2013-02-16 06:28:31 +00:00
|
|
|
|
|
|
|
# first build and install Subsurface and then clean up the staging area
|
2017-07-03 18:56:51 +00:00
|
|
|
# make sure we didn't lose the minimum OS version
|
2015-01-02 23:49:08 +00:00
|
|
|
rm -rf ./Subsurface.app
|
2022-04-11 04:46:53 +00:00
|
|
|
if [ -d /Library/Developer/CommandLineTools/SDKs ] ; then
|
|
|
|
SDKROOT=/Library/Developer/CommandLineTools/SDKs
|
|
|
|
elif [ -d /Developer/SDKs ] ; then
|
2020-09-13 00:35:37 +00:00
|
|
|
SDKROOT=/Developer/SDKs
|
|
|
|
elif [ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ] ; then
|
|
|
|
SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
|
|
|
|
else
|
|
|
|
echo "Cannot find SDK sysroot (usually /Developer/SDKs or"
|
|
|
|
echo "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)"
|
|
|
|
exit 1;
|
|
|
|
fi
|
2022-04-11 04:46:53 +00:00
|
|
|
BASESDK=$(ls $SDKROOT | grep "MacOSX1.*\.sdk" | head -1 | sed -e "s/MacOSX//;s/\.sdk//")
|
2020-09-13 00:35:37 +00:00
|
|
|
OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=${BASESDK} -DCMAKE_OSX_SYSROOT=${SDKROOT}/MacOSX${BASESDK}.sdk/"
|
|
|
|
export PKG_CONFIG_PATH=${DIR}/install-root/lib/pkgconfig:$PKG_CONFIG_PATH
|
2022-04-11 04:46:53 +00:00
|
|
|
|
2023-12-08 22:52:14 +00:00
|
|
|
cmake $OLDER_MAC_CMAKE \
|
|
|
|
-DLIBGIT2_FROM_PKGCONFIG=ON \
|
|
|
|
-DLIBGIT2_DYNAMIC=ON \
|
|
|
|
-DFTDISUPPORT=ON \
|
|
|
|
-DMAKE_TESTS=Off \
|
|
|
|
.
|
|
|
|
|
2023-12-08 18:31:18 +00:00
|
|
|
LIBRARY_PATH=${DIR}/install-root/lib make -j
|
2015-09-04 19:13:52 +00:00
|
|
|
LIBRARY_PATH=${DIR}/install-root/lib make install
|
|
|
|
|
|
|
|
# now adjust a few references that macdeployqt appears to miss
|
|
|
|
EXECUTABLE=Subsurface.app/Contents/MacOS/Subsurface
|
2020-10-07 19:46:41 +00:00
|
|
|
for i in libgit2 ; do
|
2015-09-04 19:13:52 +00:00
|
|
|
OLD=$(otool -L ${EXECUTABLE} | grep $i | cut -d\ -f1 | tr -d "\t")
|
2018-05-20 02:52:46 +00:00
|
|
|
if [[ ! -z ${OLD} && ! -f Subsurface.app/Contents/Frameworks/$(basename ${OLD}) ]] ; then
|
2017-07-03 16:36:25 +00:00
|
|
|
# copy the library into the bundle and make sure its id and the reference to it are correct
|
2016-06-05 17:55:13 +00:00
|
|
|
cp ${DIR}/install-root/lib/$(basename ${OLD}) Subsurface.app/Contents/Frameworks
|
|
|
|
SONAME=$(basename $OLD)
|
|
|
|
install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} ${EXECUTABLE}
|
2017-07-03 16:36:25 +00:00
|
|
|
install_name_tool -id @executable_path/../Frameworks/${SONAME} Subsurface.app/Contents/Frameworks/${SONAME}
|
2017-08-21 03:45:36 +00:00
|
|
|
# also fix incorrect references inside of libgit2
|
2017-07-03 16:36:25 +00:00
|
|
|
if [[ "$i" = "libgit2" ]] ; then
|
|
|
|
CURLLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libcurl | cut -d\ -f1 | tr -d "\t")
|
|
|
|
install_name_tool -change ${CURLLIB} @executable_path/../Frameworks/$(basename ${CURLLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
|
2018-07-03 16:27:27 +00:00
|
|
|
# SSHLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libssh2 | cut -d\ -f1 | tr -d "\t")
|
|
|
|
# install_name_tool -change ${SSHLIB} @executable_path/../Frameworks/$(basename ${SSHLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
|
2016-06-05 17:55:13 +00:00
|
|
|
fi
|
2015-11-08 23:14:03 +00:00
|
|
|
fi
|
|
|
|
done
|
2017-07-03 16:34:23 +00:00
|
|
|
|
2019-02-21 16:54:29 +00:00
|
|
|
# ensure libpng and libjpeg inside the bundle are referenced in QtWebKit libraries
|
|
|
|
QTWEBKIT=Subsurface.app/Contents/Frameworks/QtWebKit.framework/QtWebKit
|
2022-04-11 04:46:53 +00:00
|
|
|
if [ -f $QTWEBKIT ] ; then
|
|
|
|
for i in libjpeg.8.dylib libpng16.16.dylib; do
|
2019-02-21 16:54:29 +00:00
|
|
|
OLD=$(otool -L ${QTWEBKIT} | grep $i | cut -d\ -f1 | tr -d "\t")
|
|
|
|
if [[ ! -z ${OLD} ]] ; then
|
|
|
|
# copy the library into the bundle and make sure its id and the reference to it are correct
|
|
|
|
if [[ ! -f Subsurface.app/Contents/Frameworks/$(basename ${OLD}) ]] ; then
|
|
|
|
cp ${OLD} Subsurface.app/Contents/Frameworks
|
|
|
|
fi
|
|
|
|
SONAME=$(basename $OLD)
|
|
|
|
install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} ${QTWEBKIT}
|
|
|
|
install_name_tool -id @executable_path/../Frameworks/${SONAME} Subsurface.app/Contents/Frameworks/${SONAME}
|
|
|
|
fi
|
2022-04-11 04:46:53 +00:00
|
|
|
done
|
|
|
|
fi
|
2019-02-21 16:54:29 +00:00
|
|
|
|
2017-08-21 03:45:36 +00:00
|
|
|
# next, copy libssh2.1
|
2018-07-03 16:27:27 +00:00
|
|
|
# cp ${DIR}/install-root/lib/libssh2.1.dylib Subsurface.app/Contents/Frameworks
|
2017-08-21 03:45:36 +00:00
|
|
|
|
2017-07-03 16:34:23 +00:00
|
|
|
# next, replace @rpath references with @executable_path references in Subsurface
|
2015-12-03 20:46:30 +00:00
|
|
|
RPATH=$(otool -L ${EXECUTABLE} | grep rpath | cut -d\ -f1 | tr -d "\t" | cut -b 8- )
|
|
|
|
for i in ${RPATH}; do
|
|
|
|
install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${EXECUTABLE}
|
|
|
|
done
|
2017-07-03 16:34:23 +00:00
|
|
|
|
2017-09-17 03:16:17 +00:00
|
|
|
if [ "$1" = "-nodmg" ] ; then
|
|
|
|
exit 0
|
2023-12-08 18:31:18 +00:00
|
|
|
elif [ "$1" = "-sign" ] ; then
|
|
|
|
SIGN=1
|
|
|
|
else
|
|
|
|
SIGN=0
|
2017-09-17 03:16:17 +00:00
|
|
|
fi
|
|
|
|
|
2013-12-15 19:19:01 +00:00
|
|
|
# copy things into staging so we can create a nice DMG
|
|
|
|
rm -rf ./staging
|
|
|
|
mkdir ./staging
|
|
|
|
cp -a ./Subsurface.app ./staging
|
2013-02-15 09:17:27 +00:00
|
|
|
|
2023-12-08 18:31:18 +00:00
|
|
|
if [ "$SIGN" = "1" ] ; then
|
|
|
|
sh ${DIR}/subsurface/packaging/macosx/sign
|
|
|
|
fi
|
2013-02-15 09:17:27 +00:00
|
|
|
|
2013-02-16 23:12:04 +00:00
|
|
|
if [ -f ./Subsurface-$VERSION.dmg ]; then
|
|
|
|
rm ./Subsurface-$VERSION.dmg.bak
|
|
|
|
mv ./Subsurface-$VERSION.dmg ./Subsurface-$VERSION.dmg.bak
|
2012-10-21 20:38:19 +00:00
|
|
|
fi
|
2013-02-15 09:17:27 +00:00
|
|
|
|
2015-09-04 19:13:52 +00:00
|
|
|
$DMGCREATE --background ${DIR}/subsurface/packaging/macosx/DMG-Background.png \
|
2013-02-16 23:12:04 +00:00
|
|
|
--window-size 500 300 --icon-size 96 --volname Subsurface-$VERSION \
|
2013-02-15 09:17:27 +00:00
|
|
|
--app-drop-link 380 205 \
|
2015-09-04 19:13:52 +00:00
|
|
|
--volicon ${DIR}/subsurface/packaging/macosx/Subsurface.icns \
|
2013-02-16 23:12:04 +00:00
|
|
|
--icon "Subsurface" 110 205 ./Subsurface-$VERSION.dmg ./staging
|