source: subsurface/packaging/macosx/make-package.sh

Last change on this file was 2d2bb95, checked in by Dirk Hohndel <dirk@…>, 3 months ago

Mac packaging: add option to make bundle without creating DMG

Signed-off-by: Dirk Hohndel <dirk@…>

  • Property mode set to 100755
File size: 4.1 KB
Line 
1#!/bin/sh
2#
3# this simply automates the steps to create a DMG we can ship
4#
5# run this from the top subsurface directory
6
7# find the directory above the sources - typically ~/src
8DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../.. && pwd )
9
10# install location of yourway-create-dmg
11# by default we assume it's next to subsurface in ~/src/yoursway-create-dmg
12DMGCREATE=${DIR}/yoursway-create-dmg/create-dmg
13
14# same git version magic as in the Makefile
15# for the naming of volume and dmg we want the 3 digits of the full version number
16VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version linux)
17
18# first build and install Subsurface and then clean up the staging area
19# make sure we didn't lose the minimum OS version
20rm -rf ./Subsurface.app
21cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.10.sdk/ .
22LIBRARY_PATH=${DIR}/install-root/lib make -j8
23LIBRARY_PATH=${DIR}/install-root/lib make install
24
25# now adjust a few references that macdeployqt appears to miss
26EXECUTABLE=Subsurface.app/Contents/MacOS/Subsurface
27for i in libgit2 libGrantlee_TextDocument.dylib libGrantlee_Templates.dylib; do
28        OLD=$(otool -L ${EXECUTABLE} | grep $i | cut -d\  -f1 | tr -d "\t")
29        if [ ! -z ${OLD} ] ; then
30                # copy the library into the bundle and make sure its id and the reference to it are correct
31                cp ${DIR}/install-root/lib/$(basename ${OLD}) Subsurface.app/Contents/Frameworks
32                SONAME=$(basename $OLD)
33                install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} ${EXECUTABLE}
34                install_name_tool -id @executable_path/../Frameworks/${SONAME} Subsurface.app/Contents/Frameworks/${SONAME}
35                # also fix incorrect references inside of libgit2
36                if [[ "$i" = "libgit2" ]] ; then
37                        CURLLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libcurl | cut -d\  -f1 | tr -d "\t")
38                        install_name_tool -change ${CURLLIB} @executable_path/../Frameworks/$(basename ${CURLLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
39                        SSHLIB=$(otool -L Subsurface.app/Contents/Frameworks/${SONAME} | grep libssh2 | cut -d\  -f1 | tr -d "\t")
40                        install_name_tool -change ${SSHLIB} @executable_path/../Frameworks/$(basename ${SSHLIB}) Subsurface.app/Contents/Frameworks/${SONAME}
41                fi
42        fi
43done
44
45# next, copy libssh2.1
46cp ${DIR}/install-root/lib/libssh2.1.dylib Subsurface.app/Contents/Frameworks
47
48# next, replace @rpath references with @executable_path references in Subsurface
49RPATH=$(otool -L ${EXECUTABLE} | grep rpath  | cut -d\  -f1 | tr -d "\t" | cut -b 8- )
50for i in ${RPATH}; do
51        install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${EXECUTABLE}
52done
53
54# next deal with libGrantlee
55LIBG=$(ls Subsurface.app/Contents/Frameworks/libGrantlee_Templates*dylib)
56for i in QtScript.framework/Versions/5/QtScript QtCore.framework/Versions/5/QtCore ; do
57        install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${LIBG}
58done
59
60# clean up shared library dependency in the Grantlee plugins
61for i in Subsurface.app/Contents/PlugIns/grantlee/5.0/*.so; do
62        OLD=$(otool -L $i | grep libGrantlee_Templates | cut -d\  -f1 | tr -d "\t")
63        SONAME=$(basename $OLD )
64        install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} $i;
65        OLD=$(otool -L $i | grep QtCore | cut -d\  -f1 | tr -d "\t")
66        install_name_tool -change ${OLD} @executable_path/../Frameworks/QtCore.framework/QtCore $i;
67        mv $i Subsurface.app/Contents/PlugIns/grantlee
68done
69rmdir Subsurface.app/Contents/PlugIns/grantlee/5.0
70pushd Subsurface.app/Contents/PlugIns/grantlee
71ln -s . 5.0
72popd
73
74if [ "$1" = "-nodmg" ] ; then
75        exit 0
76fi
77
78# copy things into staging so we can create a nice DMG
79rm -rf ./staging
80mkdir ./staging
81cp -a ./Subsurface.app ./staging
82
83sh ${DIR}/subsurface/packaging/macosx/sign
84
85if [ -f ./Subsurface-$VERSION.dmg ]; then
86        rm ./Subsurface-$VERSION.dmg.bak
87        mv ./Subsurface-$VERSION.dmg ./Subsurface-$VERSION.dmg.bak
88fi
89
90$DMGCREATE --background ${DIR}/subsurface/packaging/macosx/DMG-Background.png \
91        --window-size 500 300 --icon-size 96 --volname Subsurface-$VERSION \
92        --app-drop-link 380 205 \
93        --volicon ${DIR}/subsurface/packaging/macosx/Subsurface.icns \
94        --icon "Subsurface" 110 205 ./Subsurface-$VERSION.dmg ./staging
Note: See TracBrowser for help on using the repository browser.