6
# Will loop through all dynamic links for $file, and update each to be relative.
9
#echo "checkLink called with $1 $2"
12
otool -L $FILE | grep -v "${APP}" | grep -v '/usr/lib' | grep -v '/System/' | grep -v "@executable_path" | cut -f 1 -d ' ' | while read X
14
local NAME=${LIB}/`basename "$X"`
19
#Recursively update the linkage of libraries
27
CONTENTS=${APP}/Contents
28
RESOURCES=${CONTENTS}/Resources
29
MACOS=${CONTENTS}/MacOS
35
DMG=${RELEASE}/${PROGN}.dmg
36
EXECUTABLE=bin/digikam
37
BUILD_FOLDER=./project/macosx
38
DTVER=`git describe --tags $branch | sed 's,^release-,,;s,-,+,;s,-,~,;'`
40
#Find where MacPorts is installed. We take a known binary (port), which is in <MacPorts>/bin, and
41
# go up a level to get the main install folder.
42
MACPORTS_PREFIX=`which port`
43
MACPORTS_PREFIX=`dirname $MACPORTS_PREFIX`
44
MACPORTS_PREFIX=`dirname $MACPORTS_PREFIX`
46
if [ ! -d ${RELEASE} ]; then
47
echo "Please run this from the root of the project; i.e. ${BUILD_FOLDER}/`basename $0`."
51
if [ -d "${APP}" ]; then
52
echo "Removing old application..."
56
if [ -f ${DMG} ]; then
57
echo "Removing old disk image..."
61
echo "Making application directory structure..."
62
mkdir -p "${RESOURCES}"
65
mkdir -p "${SHARE}/mime"
67
#Copy over non-explicitly linked libraries
68
echo "Copying libraries from ${MACPORTS_PREFIX}..."
69
cp -R ${MACPORTS_PREFIX}/lib/pango ${LIB}
70
cp -R ${MACPORTS_PREFIX}/lib/gtk-2.0 ${LIB}
71
cp -R ${MACPORTS_PREFIX}/lib/gdk-pixbuf-2.0 ${LIB}
73
#Copy over mimes (if a mime is copied, and nobody hears, is it really copied?)
74
echo "Copying shared files from ${MACPORTS_PREFIX}..."
75
cp -R ${MACPORTS_PREFIX}/share/mime/* ${SHARE}/mime
77
#Copy over etc files, and modify as needed
78
echo "Copying configuration files from ${MACPORTS_PREFIX} and modifying for standalone app bundle..."
79
cp -R $MACPORTS_PREFIX/etc/gtk-2.0 ${ETC}
80
cp -R $MACPORTS_PREFIX/etc/pango ${ETC}
81
ESCAPED_MACPORTS_PREFIX=`echo ${MACPORTS_PREFIX} | sed -e 's/\\//\\\\\\//g'`
82
sed -i .bak -e "s/${ESCAPED_MACPORTS_PREFIX}/@executable_path\/../g" ${ETC}/gtk-2.0/gdk-pixbuf.loaders ${ETC}/pango/pango.modules
83
echo -e "[Pango]\nModuleFiles = /tmp/`basename ${EXECUTABLE}`_pango.modules" > ${ETC}/pango/pangorc
85
#Copy over the release files
86
echo "Copying release files..."
87
cp -R ${RELEASE}/* ${MACOS}
89
#Copy application-specific stuff like icons and startup script
90
echo "Creating required application bundle files..."
91
cp ${BUILD_FOLDER}/Info.plist ${CONTENTS}
92
sed -i -e 's/VERSION/'${DTVER}'/g' ${CONTENTS}/Info.plist
93
cp cmake/macosx/darktable.icns ${RESOURCES}
94
cp ${BUILD_FOLDER}/start ${MACOS}
96
#Copy and relink the explicitly defined libraries
97
echo "Recursively copying libraries referenced by executable..."
98
checkLink "${MACOS}/${EXECUTABLE}"
100
#Make a .dmg for distribution and delete the .app
101
echo "Creating distribution .dmg ..."
103
# Creating temporary rw image
104
SIZE=$(( $(du -sm "${APP}"| awk '{print $1}') + 3 ))
105
hdiutil create -srcfolder "${APP}" -volname "${PROGN}" -fs HFS+ \
106
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M pack.temp.dmg
108
# mounting image without auto-open to create window style params
109
device=$(hdiutil attach -readwrite -noverify -noautoopen "pack.temp.dmg" | \
110
egrep '^/dev/' | sed 1q | awk '{print $1}')
112
tell application "Finder"
113
tell disk "'${PROGN}'"
115
set current view of container window to icon view
116
set toolbar visible of container window to false
117
set statusbar visible of container window to false
118
set the bounds of container window to {400, 100, 885, 330}
119
set theViewOptions to the icon view options of container window
120
set arrangement of theViewOptions to not arranged
121
set icon size of theViewOptions to 72
122
# set background picture of theViewOptions to file ".backgroundimage:digikam.svg"
123
make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
124
set position of item "'${PROGN}'" of container window to {100, 100}
125
set position of item "Applications" of container window to {375, 100}
126
update without registering applications
134
# Finalizing creation
135
chmod -Rf go-w /Volumes/"${PROGN}"
138
hdiutil detach ${device}
140
if [ -f build/"${PROGN}".dmg ]
141
then echo "removing old .dmg file" && rm -if build/"${PROGN}".dmg
144
hdiutil convert "pack.temp.dmg" -format UDZO -imagekey zlib-level=9 -o build/"${PROGN}"
147
echo "Cleaning up..."
149
du -sh build/"${PROGN}".dmg