| 
									
										
										
										
											2013-02-16 23:46:17 +01:00
										 |  |  | #!/bin/sh
 | 
					
						
							| 
									
										
										
										
											2012-10-21 13:38:19 -07:00
										 |  |  | # | 
					
						
							|  |  |  | # this simply automates the steps to create a DMG we can ship | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | # | 
					
						
							|  |  |  | # run this from the top subsurface directory | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | # find the directory above the sources - typically ~/src | 
					
						
							|  |  |  | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && cd ../../.. && pwd ) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | # install location of yourway-create-dmg | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | # by default we assume it's next to subsurface in ~/src/yoursway-create-dmg | 
					
						
							|  |  |  | DMGCREATE=${DIR}/yoursway-create-dmg/create-dmg | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-15 22:28:31 -08:00
										 |  |  | # same git version magic as in the Makefile | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | # for the naming of volume and dmg we want the 3 digits of the full version number | 
					
						
							|  |  |  | VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version linux) | 
					
						
							| 
									
										
										
										
											2013-02-15 22:28:31 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # first build and install Subsurface and then clean up the staging area | 
					
						
							| 
									
										
										
										
											2017-07-04 03:56:51 +09:00
										 |  |  | # make sure we didn't lose the minimum OS version | 
					
						
							| 
									
										
										
										
											2015-01-02 15:49:08 -08:00
										 |  |  | rm -rf ./Subsurface.app | 
					
						
							| 
									
										
										
										
											2017-07-04 03:56:51 +09:00
										 |  |  | cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.10.sdk/ . | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | LIBRARY_PATH=${DIR}/install-root/lib make -j8 | 
					
						
							|  |  |  | LIBRARY_PATH=${DIR}/install-root/lib make install | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # now adjust a few references that macdeployqt appears to miss | 
					
						
							|  |  |  | EXECUTABLE=Subsurface.app/Contents/MacOS/Subsurface | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07:00
										 |  |  | for i in libssh libssrfmarblewidget libgit2 libGrantlee_TextDocument.dylib libGrantlee_Templates.dylib; do | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | 	OLD=$(otool -L ${EXECUTABLE} | grep $i | cut -d\  -f1 | tr -d "\t") | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07:00
										 |  |  | 	if [ ! -z ${OLD} ] ; then | 
					
						
							| 
									
										
										
										
											2017-07-04 01:36:25 +09:00
										 |  |  | 		# copy the library into the bundle and make sure its id and the reference to it are correct | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07: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-04 01:36:25 +09:00
										 |  |  | 		install_name_tool -id @executable_path/../Frameworks/${SONAME} Subsurface.app/Contents/Frameworks/${SONAME} | 
					
						
							|  |  |  | 		# also fix one incorrect reference inside of libgit2 | 
					
						
							|  |  |  | 		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} | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07:00
										 |  |  | 		fi | 
					
						
							| 
									
										
										
										
											2015-11-08 15:14:03 -08:00
										 |  |  | 	fi | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2017-07-04 01:34:23 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | # next, replace @rpath references with @executable_path references in Subsurface | 
					
						
							| 
									
										
										
										
											2015-12-03 12:46:30 -08: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-04 01:34:23 +09:00
										 |  |  | 
 | 
					
						
							|  |  |  | # and now replace @rpath references in libssrfmarblewidget | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07:00
										 |  |  | MARBLELIB=$(ls Subsurface.app/Contents/Frameworks/libssrfmarblewidget*dylib) | 
					
						
							|  |  |  | RPATH=$(otool -L ${MARBLELIB} | 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 ${MARBLELIB} | 
					
						
							|  |  |  | done | 
					
						
							| 
									
										
										
										
											2015-11-08 15:14:03 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | # next deal with libGrantlee | 
					
						
							| 
									
										
										
										
											2016-06-05 10:55:13 -07:00
										 |  |  | LIBG=$(ls Subsurface.app/Contents/Frameworks/libGrantlee_Templates*dylib) | 
					
						
							| 
									
										
										
										
											2015-11-08 15:14:03 -08:00
										 |  |  | for i in QtScript.framework/Versions/5/QtScript QtCore.framework/Versions/5/QtCore ; do | 
					
						
							|  |  |  | 	install_name_tool -change @rpath/$i @executable_path/../Frameworks/$i ${LIBG} | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # clean up shared library dependency in the Grantlee plugins | 
					
						
							|  |  |  | for i in Subsurface.app/Contents/PlugIns/grantlee/5.0/*.so; do | 
					
						
							|  |  |  | 	OLD=$(otool -L $i | grep libGrantlee_Templates | cut -d\  -f1 | tr -d "\t") | 
					
						
							|  |  |  | 	SONAME=$(basename $OLD ) | 
					
						
							|  |  |  | 	install_name_tool -change ${OLD} @executable_path/../Frameworks/${SONAME} $i; | 
					
						
							| 
									
										
										
										
											2017-07-03 13:30:10 -07:00
										 |  |  | 	OLD=$(otool -L $i | grep QtCore | cut -d\  -f1 | tr -d "\t") | 
					
						
							|  |  |  | 	install_name_tool -change ${OLD} @executable_path/../Frameworks/QtCore.framework/QtCore $i; | 
					
						
							| 
									
										
										
										
											2017-07-03 22:36:39 -07:00
										 |  |  | 	mv $i Subsurface.app/Contents/PlugIns/grantlee | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | done | 
					
						
							| 
									
										
										
										
											2017-07-03 22:36:39 -07:00
										 |  |  | rmdir Subsurface.app/Contents/PlugIns/grantlee/5.0 | 
					
						
							|  |  |  | pushd Subsurface.app/Contents/PlugIns/grantlee | 
					
						
							|  |  |  | ln -s . 5.0 | 
					
						
							|  |  |  | popd | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-15 11:19:01 -08: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 01:17:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | sh ${DIR}/subsurface/packaging/macosx/sign | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-17 00:12:04 +01:00
										 |  |  | if [ -f ./Subsurface-$VERSION.dmg ]; then | 
					
						
							|  |  |  | 	rm ./Subsurface-$VERSION.dmg.bak | 
					
						
							|  |  |  | 	mv ./Subsurface-$VERSION.dmg ./Subsurface-$VERSION.dmg.bak | 
					
						
							| 
									
										
										
										
											2012-10-21 13:38:19 -07:00
										 |  |  | fi | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | $DMGCREATE --background ${DIR}/subsurface/packaging/macosx/DMG-Background.png \
 | 
					
						
							| 
									
										
										
										
											2013-02-17 00:12:04 +01:00
										 |  |  | 	--window-size 500 300 --icon-size 96 --volname Subsurface-$VERSION \
 | 
					
						
							| 
									
										
										
										
											2013-02-15 01:17:27 -08:00
										 |  |  | 	--app-drop-link 380 205 \
 | 
					
						
							| 
									
										
										
										
											2015-09-04 12:13:52 -07:00
										 |  |  | 	--volicon ${DIR}/subsurface/packaging/macosx/Subsurface.icns \
 | 
					
						
							| 
									
										
										
										
											2013-02-17 00:12:04 +01:00
										 |  |  | 	--icon "Subsurface" 110 205 ./Subsurface-$VERSION.dmg ./staging |