19588f0351c72ed7d8294299f911fe6dd6d96234
[dcpomatic.git] / platform / osx / make_dmg.sh
1 #!/bin/bash
2 #
3 # Syntax: make_dmg.sh <environment> <builddir> <type> <apple-id> <apple-password>
4 # where <type> is universal or thin
5 #
6 # e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist universal foo@bar.net opensesame
7
8 # Don't set -e here as egrep (used a few times) returns 1 if no matches
9 # were found.
10
11 version=`git describe --tags --abbrev=0 | sed -e "s/v//"`
12
13 # DMG size in megabytes
14 DMG_SIZE=256
15 ENV=$1
16 ROOT=$2
17 TYPE=$3
18 APPLE_ID=$4
19 APPLE_PASSWORD=$5
20
21 if [ "$TYPE" != "universal" -a "$TYPE" != "thin" ]; then
22     echo "Syntax: $0 <builddir> <type>"
23     echo "where <type> is universal or thin"
24     exit 1
25 fi
26
27 # This is our work area for making up the .dmgs
28 mkdir -p build/platform/osx
29 cd build/platform/osx
30
31 function copy {
32     case $TYPE in
33         universal)
34             for f in $1/32/$2; do
35                 if [ -h $f ]; then
36                     ln -s $(readlink $f) "$3/`basename $f`"
37                 else
38                     g=`echo $f | sed -e "s/\/32\//\/64\//g"`
39                     mkdir -p "$3"
40                     lipo -create $f $g -output "$3/`basename $f`"
41                 fi
42             done
43             ;;
44         thin)
45             if [ -h $1/$2 ]; then
46                 ln -s $(readlink $1/$2) "$3/`basename $f`"
47             else
48                 cp $1/$2 "$3"
49             fi
50             ;;
51     esac
52 }
53
54 function copy_lib_root {
55     case $TYPE in
56         universal)
57             for f in $ROOT/32/lib/$1*.dylib; do
58                 if [ -h $f ]; then
59                     ln -s $(readlink $f) "$2/`basename $f`"
60                 else
61                     g=`echo $f | sed -e "s/\/32\//\/64\//g"`
62                     mkdir -p "$2"
63                     lipo -create $f $g -output "$2/`basename $f`"
64                 fi
65             done
66             ;;
67         thin)
68             for f in $ROOT/lib/$1*.dylib; do
69                 if [ -h $f ]; then
70                     ln -s $(readlink $f) "$2/`basename $f`"
71                 else
72                     mkdir -p "$2"
73                     cp $f "$2"
74                 fi
75             done
76             ;;
77     esac
78     to_relink="$to_relink|$1"
79 }
80
81 function copy_lib_env {
82     case $TYPE in
83         universal)
84             for f in $ENV/32/lib/$1*.dylib; do
85                 if [ -h $f ]; then
86                     ln -s $(readlink $f) "$2/`basename $f`"
87                 else
88                     g=`echo $f | sed -e "s/\/32\//\/64\//g"`
89                     mkdir -p "$2"
90                     lipo -create $f $g -output "$2/`basename $f`"
91                 fi
92             done
93             ;;
94         thin)
95             for f in $ENV/64/lib/$1*.dylib; do
96                 if [ -h $f ]; then
97                     ln -s $(readlink $f) "$2/`basename $f`"
98                 else
99                     mkdir -p "$2"
100                     cp $f "$2"
101                 fi
102             done
103             ;;
104     esac
105     to_relink="$to_relink|$1"
106 }
107
108 # @param #1 directory to copy to
109 function copy_libs {
110     local dest="$1"
111     copy_lib_root libcxml "$dest"
112     copy_lib_root libdcp-1.0 "$dest"
113     copy_lib_root libasdcp-carl "$dest"
114     copy_lib_root libkumu-carl "$dest"
115     copy_lib_root libsub "$dest"
116     copy_lib_root libopenjp2 "$dest"
117     copy_lib_root libavdevice "$dest"
118     copy_lib_root libavformat "$dest"
119     copy_lib_root libavfilter "$dest"
120     copy_lib_root libavutil "$dest"
121     copy_lib_root libavcodec "$dest"
122     copy_lib_root libswscale "$dest"
123     copy_lib_root libpostproc "$dest"
124     copy_lib_root libswresample "$dest"
125     copy_lib_root liblwext4 "$dest"
126     copy_lib_root libblockdev "$dest"
127     copy $ROOT src/dcpomatic/build/src/lib/libdcpomatic2.dylib "$dest"
128     copy $ROOT src/dcpomatic/build/src/wx/libdcpomatic2-wx.dylib "$dest"
129     copy_lib_env libboost_system "$dest"
130     copy_lib_env libboost_filesystem "$dest"
131     copy_lib_env libboost_thread "$dest"
132     copy_lib_env libboost_date_time "$dest"
133     copy_lib_env libboost_locale "$dest"
134     copy_lib_env libboost_regex "$dest"
135     copy_lib_env libxml++ "$dest"
136     copy_lib_env libxslt "$dest"
137     copy_lib_env libxml2 "$dest"
138     copy_lib_env libglibmm-2.4 "$dest"
139     copy_lib_env libgobject "$dest"
140     copy_lib_env libgthread "$dest"
141     copy_lib_env libgmodule "$dest"
142     copy_lib_env libsigc "$dest"
143     copy_lib_env libglib-2 "$dest"
144     copy_lib_env libintl "$dest"
145     copy_lib_env libsndfile "$dest"
146     copy_lib_env libssh "$dest"
147     copy_lib_env libwx "$dest"
148     copy_lib_env libfontconfig "$dest"
149     copy_lib_env libfreetype "$dest"
150     copy_lib_env libexpat "$dest"
151     copy_lib_env libltdl "$dest"
152     copy_lib_env libxmlsec1 "$dest"
153     copy_lib_env libcurl "$dest"
154     copy_lib_env libffi "$dest"
155     copy_lib_env libpango "$dest"
156     copy_lib_env libcairo "$dest"
157     copy_lib_env libpixman "$dest"
158     copy_lib_env libharfbuzz "$dest"
159     copy_lib_env libsamplerate "$dest"
160     copy_lib_env libicui18n "$dest"
161     copy_lib_env libicudata "$dest"
162     copy_lib_env libicuio "$dest"
163     copy_lib_env libicule "$dest"
164     copy_lib_env libiculx "$dest"
165     copy_lib_env libicutest "$dest"
166     copy_lib_env libicutu "$dest"
167     copy_lib_env libicuuc "$dest"
168     copy_lib_env libFLAC "$dest"
169     copy_lib_env libvorbis "$dest"
170     copy_lib_env libogg "$dest"
171     copy_lib_env libxerces-c "$dest"
172 }
173
174 # @param #1 directory to copy to
175 function copy_resources {
176     local dest="$1"
177     case $TYPE in
178         universal)
179             local prefix=$ROOT/32
180             ;;
181         thin)
182             local prefix=$ROOT
183             ;;
184     esac
185     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic_small.png "$dest"
186     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2.icns "$dest"
187     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_kdm.icns "$dest"
188     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_server.icns "$dest"
189     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_player.icns "$dest"
190     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_batch.icns "$dest"
191     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_playlist.icns "$dest"
192     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_disk.icns "$dest"
193     cp $prefix/src/dcpomatic/graphics/osx/preferences/colour_conversions.png "$dest"
194     cp $prefix/src/dcpomatic/graphics/osx/preferences/defaults.png "$dest"
195     cp $prefix/src/dcpomatic/graphics/osx/preferences/kdm_email.png "$dest"
196     cp $prefix/src/dcpomatic/graphics/osx/preferences/email.png "$dest"
197     cp $prefix/src/dcpomatic/graphics/osx/preferences/servers.png "$dest"
198     cp $prefix/src/dcpomatic/graphics/osx/preferences/tms.png "$dest"
199     cp $prefix/src/dcpomatic/graphics/osx/preferences/keys.png "$dest"
200     cp $prefix/src/dcpomatic/graphics/osx/preferences/cover_sheet.png "$dest"
201     cp $prefix/src/dcpomatic/graphics/osx/preferences/notifications.png "$dest"
202     cp $prefix/src/dcpomatic/graphics/osx/preferences/locations.png "$dest"
203     cp $prefix/src/dcpomatic/graphics/osx/preferences/sound.png "$dest"
204     cp $prefix/src/dcpomatic/fonts/LiberationSans-Regular.ttf "$dest"
205     cp $prefix/src/dcpomatic/fonts/LiberationSans-Italic.ttf "$dest"
206     cp $prefix/src/dcpomatic/fonts/LiberationSans-Bold.ttf "$dest"
207     cp $prefix/src/dcpomatic/fonts/fonts.conf.osx "$dest"/fonts.conf
208     cp $prefix/src/dcpomatic/graphics/splash.png "$dest"
209     cp $prefix/src/dcpomatic/graphics/zoom.png "$dest"
210     cp $prefix/src/dcpomatic/graphics/zoom_all.png "$dest"
211     cp $prefix/src/dcpomatic/graphics/select.png "$dest"
212     cp $prefix/src/dcpomatic/graphics/snap.png "$dest"
213     cp $prefix/src/dcpomatic/graphics/sequence.png "$dest"
214     cp $prefix/src/dcpomatic/graphics/me.jpg "$dest"
215     cp -r $prefix/share/libdcp/xsd "$dest"
216
217     # i18n: DCP-o-matic .mo files
218     for lang in de_DE es_ES fr_FR it_IT sv_SE nl_NL ru_RU pl_PL da_DK pt_PT pt_BR sk_SK cs_CZ uk_UA zh_CN tr_TR; do
219         mkdir -p "$dest/$lang/LC_MESSAGES"
220         cp $prefix/src/dcpomatic/build/src/lib/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
221         cp $prefix/src/dcpomatic/build/src/wx/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
222         cp $prefix/src/dcpomatic/build/src/tools/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
223     done
224
225     # i18n: wxWidgets .mo files
226     for lang in de es fr it sv nl ru pl da cs; do
227         mkdir "$dest/$lang"
228         cp $ENV/64/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
229     done
230 }
231
232 # param $1 list of things that link to other things
233 function relink_relative {
234     to_relink=`echo $to_relink | sed -e "s/\+//g"`
235     local linkers=("$@")
236
237     for obj in "${linkers[@]}"; do
238         deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
239         changes=""
240         for dep in $deps; do
241             base=`basename $dep`
242             if [ "$TYPE" == "universal" ]; then
243                 # $dep will be a path within 64/; make a 32/ path too
244                 dep32=`echo $dep | sed -e "s/\/64\//\/32\//g"`
245                 changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep32 @executable_path/../Frameworks/$base"
246             else
247                 changes="$changes -change $dep @executable_path/../Frameworks/$base"
248             fi
249         done
250         if test "x$changes" != "x"; then
251             install_name_tool $changes -id `basename "$obj"` "$obj"
252         fi
253     done
254 }
255
256 # param $1 directory containg things
257 #       $2 list of things that link to other things
258 function relink_absolute {
259     to_relink=`echo $to_relink | sed -e "s/\+//g"`
260     target=$1
261     shift
262     local linkers=("$@")
263
264     for obj in "${linkers[@]}"; do
265         deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
266         changes=""
267         for dep in $deps; do
268             base=`basename $dep`
269             changes="$changes -change "$dep" \"$target/$base\""
270         done
271         if test "x$changes" != "x"; then
272             install_name_tool $changes -id "`basename "$obj"`" "$obj"
273         fi
274     done
275 }
276
277 function sign {
278     codesign --deep --force --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$1"
279     if [ "$?" != "0" ]; then
280         echo "Failed to sign $1"
281         exit 1
282     fi
283 }
284
285
286 # @param #1 .app directory
287 # @param #2 .pkg or ""
288 # @param #3 full name e.g. DCP-o-matic Batch Converter
289 # @param #4 bundle id e.g. com.dcpomatic.batch
290 function make_dmg {
291     local appdir="$1"
292     local pkg="$2"
293     local full_name="$3"
294     local bundle_id="$4"
295     tmp_dmg=dcpomatic_tmp.dmg
296     dmg="$full_name $version.dmg"
297     vol_name=DCP-o-matic-$version
298
299     sign "$appdir"
300
301     if [ "$pkg" != "" ]; then
302         productsign --sign "Developer ID Installer: Carl Hetherington (R82DXSR997)" "$pkg" "signed_temp.pkg"
303         if [ "$?" != "0" ]; then
304             echo "Failed to sign .pkg"
305             exit 1
306         fi
307         mv signed_temp.pkg "$pkg"
308     fi
309
310     mkdir -p $vol_name
311     cp -a "$appdir" $vol_name
312     if [ "$pkg" != "" ]; then
313         cp -a "$pkg" $vol_name
314     fi
315     ln -s /Applications "$vol_name/Applications"
316     cat<<EOF > "$vol_name/READ ME.txt"
317 Welcome to DCP-o-matic!  The first time you run the program there may be
318 a long (several-minute) delay while OS X checks the code for viruses and
319 other malware.  Please be patient!
320 EOF
321     cat<<EOF > "$vol_name/READ ME.de_DE.txt"
322 Beim erstmaligen Start der DCP-o-matic Anwendungen kann ein längerer
323 Verifikationsvorgang auftreten.  Dies ist von der OS X Sicherheitsumgebung
324 'Gatekeeper' verursacht.  Dieser je nach Rechner teils minutenlange
325 Verifikationsvorgang ist gegenwärtig normal und nicht zu umgehen,
326 es ist kein Programmfehler.  Warten sie die Verifikation für jede der
327 DCP-o-matic Anwendungen ab, bei weiteren Programmstarts wird sie nicht
328 mehr auftreten.
329 EOF
330
331     if [ "$pkg" != "" ]; then
332         cat<<EOF > "$vol_name/READ ME.txt"
333
334 To run this software successfully you must install $pkg before running
335 the .app
336 EOF
337     fi
338
339     if [ "$pkg" != "" ]; then
340         cat<<EOF > "$vol_name/READ ME.de_DE.txt"
341
342 To run this software successfully you must install $pkg before running
343 the .app
344 EOF
345
346     fi
347     rm -f $tmp_dmg "$dmg"
348     hdiutil create -srcfolder $vol_name -volname $vol_name -fs HFS+ -fsargs "-c c=64,a=16,e=16" -format UDRW -size $DMG_SIZE $tmp_dmg
349     attach=$(hdiutil attach -readwrite -noverify -noautoopen $tmp_dmg)
350     device=`echo $attach | egrep '^/dev/' | sed 1q | awk '{print $5}'`
351     sleep 5
352
353     echo '
354   tell application "Finder"
355     tell disk "'$vol_name'"
356            open
357            set current view of container window to icon view
358            set toolbar visible of container window to false
359            set statusbar visible of container window to false
360            set the bounds of container window to {400, 200, 940, 600}
361            set theViewOptions to the icon view options of container window
362            set arrangement of theViewOptions to not arranged
363            set icon size of theViewOptions to 64
364            set position of item "'$appdir'" of container window to {90, 80}
365            set position of item "Applications" of container window to {265, 80}
366            set position of item "READ ME.txt" of container window to {430, 80}
367            set position of item "READ ME.de_DE.txt" of container window to {595, 80}
368            set position of item "DCP-o-matic Disk Writer.pkg" of container window to {90, 255}
369            close
370            open
371            update without registering applications
372            delay 5
373      end tell
374    end tell
375 ' | osascript
376
377     chmod -Rf go-w /Volumes/"$vol_name"/"$appdir"
378     sync
379
380     hdiutil eject $device
381     hdiutil convert -format UDZO $tmp_dmg -imagekey zlib-level=9 -o "$dmg"
382     sips -i "$appdir/Contents/Resources/dcpomatic2.icns"
383     DeRez -only icns "$appdir/Contents/Resources/dcpomatic2.icns" > "$appdir/Contents/Resources/DCP-o-matic.rsrc"
384     Rez -append "$appdir/Contents/Resources/DCP-o-matic.rsrc" -o "$dmg"
385     SetFile -a C "$dmg"
386     xattr -c "$dmg"
387
388     set -e
389     codesign --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$dmg"
390
391     # We only notarize thin builds, as if we're building universal binaries we must be on an OS
392     # sufficiently old that it can't notarize anyway
393     if [ "$TYPE" == "thin" ]; then
394
395         id=$(xcrun altool --notarize-app -t osx -f "$dmg" --primary-bundle-id $bundle_id -u $APPLE_ID -p $APPLE_PASSWORD --output-format xml | grep -C1 RequestUUID | tail -n 1 | sed -e "s/<string>//g" | sed -e "s/<\/string>//g")
396         N=0
397         while [ 1 ]; do
398             echo "Checking up on $id"
399             status=$(xcrun altool --notarization-info $id -u $APPLE_ID -p $APPLE_PASSWORD --output-format xml)
400             summary=$(echo "$status" | grep -C1 "<key>Status</key>" | tail -n 1 | sed -e "s/    .//g")
401             echo "Got $summary"
402             if [ "$summary" == "<string>invalid</string>" ]; then
403                 echo "Notarization failed."
404                 echo $status
405                 exit 1
406             fi
407             if [ "$summary" == "<string>success</string>" ]; then
408                 break
409             fi
410             sleep 30
411             N=$((N+1))
412             if [ "$N" == "30" ]; then
413                 echo "Timed out waiting for notarization"
414                 exit 1
415             fi
416         done
417
418         xcrun stapler staple "$dmg"
419     fi
420     set +e
421
422     rm $tmp_dmg
423     rm -rf $vol_name
424 }
425
426 # @param #1 appdir
427 function setup {
428     appdir="$1"
429     approot="$appdir/Contents"
430     rm -rf "$appdir"
431     mkdir -p "$approot/MacOS"
432     mkdir -p "$approot/Frameworks"
433     mkdir -p "$approot/Resources"
434
435     to_relink="dcpomatic"
436     copy_libs "$approot/Frameworks"
437     copy_resources "$approot/Resources"
438 }
439
440 case $TYPE in
441     universal)
442         prefix=$ROOT/32
443         ;;
444     thin)
445         prefix=$ROOT
446         ;;
447 esac
448
449 # DCP-o-matic main
450 ##setup "DCP-o-matic 2.app"
451 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2 "$approot/MacOS"
452 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_cli "$approot/MacOS"
453 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_create "$approot/MacOS"
454 ##copy $ROOT bin/ffprobe "$approot/MacOS"
455 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
456 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2.Info.plist "$approot/Info.plist"
457 ##rl=("$approot/MacOS/dcpomatic2" "$approot/MacOS/dcpomatic2_cli" "$approot/MacOS/dcpomatic2_create" "$approot/MacOS/ffprobe" "$approot/Frameworks/"*.dylib)
458 ##relink_relative "${rl[@]}"
459 ##make_dmg "$appdir" "" "DCP-o-matic" com.dcpomatic
460
461 # DCP-o-matic KDM Creator
462 ##setup "DCP-o-matic 2 KDM Creator.app"
463 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_kdm "$approot/MacOS"
464 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_kdm_cli "$approot/MacOS"
465 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
466 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_kdm.Info.plist "$approot/Info.plist"
467 ##rl=("$approot/MacOS/dcpomatic2_kdm" "$approot/MacOS/dcpomatic2_kdm_cli" "$approot/Frameworks/"*.dylib)
468 ##relink_relative "${rl[@]}"
469 ##make_dmg "$appdir" "" "DCP-o-matic KDM Creator" com.dcpomatic.kdm
470
471 # DCP-o-matic Encode Server
472 ##setup "DCP-o-matic 2 Encode Server.app"
473 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_server "$approot/MacOS"
474 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_server_cli "$approot/MacOS"
475 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
476 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_server.Info.plist "$approot/Info.plist"
477 ##rl=("$approot/MacOS/dcpomatic2_server" "$approot/MacOS/dcpomatic2_server_cli" "$approot/Frameworks/"*.dylib)
478 ##relink_relative "${rl[@]}"
479 ##make_dmg "$appdir" "" "DCP-o-matic Encode Server" com.dcpomatic.server
480
481 # DCP-o-matic Batch Converter
482 ##setup "DCP-o-matic 2 Batch converter.app"
483 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_batch "$approot/MacOS"
484 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
485 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_batch.Info.plist "$approot/Info.plist"
486 ##rl=("$approot/MacOS/dcpomatic2_batch" "$approot/Frameworks/"*.dylib)
487 ##relink_relative "${rl[@]}"
488 ##make_dmg "$appdir" "" "DCP-o-matic Batch Converter" com.dcpomatic.batch
489
490 # DCP-o-matic Player
491 ##setup "DCP-o-matic 2 Player.app"
492 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_player "$approot/MacOS"
493 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
494 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_player.Info.plist "$approot/Info.plist"
495 ##rl=("$approot/MacOS/dcpomatic2_player" "$approot/Frameworks/"*.dylib)
496 ##relink_relative "${rl[@]}"
497 ##make_dmg "$appdir" "" "DCP-o-matic Player" com.dcpomatic.player
498
499 # DCP-o-matic Playlist Editor
500 ##setup "DCP-o-matic 2 Playlist Editor.app"
501 ##copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_playlist "$approot/MacOS"
502 ##copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
503 ##cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_playlist.Info.plist "$approot/Info.plist"
504 ##rl=("$approot/MacOS/dcpomatic2_playlist" "$approot/Frameworks/"*.dylib)
505 ##relink_relative "${rl[@]}"
506 ##make_dmg "$appdir" "" "DCP-o-matic Playlist Editor" com.dcpomatic.playlist
507
508 # DCP-o-matic Disk Writer .app
509 setup "DCP-o-matic 2 Disk Writer.app"
510 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk "$approot/MacOS"
511 # XXX: this shouldn't really be necessary
512 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
513 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_disk.Info.plist "$approot/Info.plist"
514 rl=("$approot/MacOS/dcpomatic2_disk" "$approot/Frameworks/"*.dylib)
515 relink_relative "${rl[@]}"
516
517 # DCP-o-matic Disk Writer daemon .pkg
518 pkgbase=tmp-disk-writer
519 rm -rf $pkgbase
520 mkdir $pkgbase
521 pkgroot=$pkgbase/root
522 mkdir -p $pkgroot/Library/LaunchDaemons
523 cat > $pkgroot/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist <<EOF
524 <?xml version="1.0" encoding="UTF-8"?>
525 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
526 <plist version="1.0">
527 <dict>
528     <key>Label</key>
529     <string>com.dcpomatic.disk.writer</string>
530     <key>ProgramArguments</key>
531     <array>
532         <string>/Library/Application Support/com.dcpomatic/dcpomatic2_disk_writer</string>
533     </array>
534     <key>EnvironmentVariables</key>
535     <dict>
536         <key>DYLD_LIBRARY_PATH</key>
537         <string><![CDATA[/Library/Application Support/com.dcpomatic]]></string>
538     </dict>
539     <key>KeepAlive</key>
540     <true/>
541     <key>RunAtLoad</key>
542     <true/>
543     <key>Debug</key>
544     <true/>
545     <key>StandardOutPath</key>
546     <string>/Users/carl/damon.out.log</string>
547     <key>StandardErrorPath</key>
548     <string>/Users/carl/damon.err.log</string>
549 </dict>
550 </plist>
551 EOF
552
553 mkdir -p "$pkgroot/Library/Application Support/com.dcpomatic"
554 target="$pkgroot/Library/Application Support/com.dcpomatic"
555 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk_writer "$target"
556 copy_lib_root libcxml "$target"
557 copy_lib_env libboost_system "$target"
558 copy_lib_env libboost_filesystem "$target"
559 copy_lib_env libboost_thread "$target"
560 copy_lib_env libboost_date_time "$target"
561 copy_lib_env libboost_locale "$target"
562 copy_lib_env libboost_regex "$target"
563 copy_lib_env libicui18n "$target"
564 copy_lib_env libicudata "$target"
565 copy_lib_env libicuio "$target"
566 copy_lib_env libicule "$target"
567 copy_lib_env libiculx "$target"
568 copy_lib_env libicutest "$target"
569 copy_lib_env libicutu "$target"
570 copy_lib_env libicuuc "$target"
571
572 rl=("$target/dcpomatic2_disk_writer" "$target/"*.dylib)
573 relink_absolute "${rl[@]}"
574
575 mkdir $pkgbase/scripts
576 cat > $pkgbase/scripts/postinstall <<EOF
577 #!/bin/sh
578 /bin/launchctl load "/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist"
579 exit 0
580 EOF
581 chmod gou+x $pkgbase/scripts/postinstall
582
583 find "$target" -iname "*.dylib" -print0 | while IFS= read -r -d '' f; do
584     sign "$f"
585 done
586 sign "$target/dcpomatic2_disk_writer"
587
588 pkgbuild --root $pkgroot --identifier com.dcpomatic.disk.writer --scripts $pkgbase/scripts "DCP-o-matic Disk Writer.pkg"
589
590 make_dmg "$appdir" "DCP-o-matic Disk Writer.pkg" "DCP-o-matic Disk Writer" com.dcpomatic.disk