Remove notarization from make_dmg.sh.
[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
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_lib_root libleqm_nrt "$dest"
128     copy $ROOT src/dcpomatic/build/src/lib/libdcpomatic2.dylib "$dest"
129     copy $ROOT src/dcpomatic/build/src/wx/libdcpomatic2-wx.dylib "$dest"
130     copy_lib_env libboost_system "$dest"
131     copy_lib_env libboost_filesystem "$dest"
132     copy_lib_env libboost_thread "$dest"
133     copy_lib_env libboost_date_time "$dest"
134     copy_lib_env libboost_locale "$dest"
135     copy_lib_env libboost_regex "$dest"
136     copy_lib_env libxml++ "$dest"
137     copy_lib_env libxslt "$dest"
138     copy_lib_env libxml2 "$dest"
139     copy_lib_env libglibmm-2.4 "$dest"
140     copy_lib_env libgobject "$dest"
141     copy_lib_env libgthread "$dest"
142     copy_lib_env libgmodule "$dest"
143     copy_lib_env libsigc "$dest"
144     copy_lib_env libglib-2 "$dest"
145     copy_lib_env libintl "$dest"
146     copy_lib_env libsndfile "$dest"
147     copy_lib_env libssh "$dest"
148     copy_lib_env libwx "$dest"
149     copy_lib_env libfontconfig "$dest"
150     copy_lib_env libfreetype "$dest"
151     copy_lib_env libexpat "$dest"
152     copy_lib_env libltdl "$dest"
153     copy_lib_env libxmlsec1 "$dest"
154     copy_lib_env libcurl "$dest"
155     copy_lib_env libffi "$dest"
156     copy_lib_env libpango "$dest"
157     copy_lib_env libcairo "$dest"
158     copy_lib_env libpixman "$dest"
159     copy_lib_env libharfbuzz "$dest"
160     copy_lib_env libsamplerate "$dest"
161     copy_lib_env libicui18n "$dest"
162     copy_lib_env libicudata "$dest"
163     copy_lib_env libicuio "$dest"
164     copy_lib_env libicule "$dest"
165     copy_lib_env libiculx "$dest"
166     copy_lib_env libicutest "$dest"
167     copy_lib_env libicutu "$dest"
168     copy_lib_env libicuuc "$dest"
169     copy_lib_env libFLAC "$dest"
170     copy_lib_env libvorbis "$dest"
171     copy_lib_env libogg "$dest"
172     copy_lib_env libxerces-c "$dest"
173 }
174
175 # @param #1 directory to copy to
176 function copy_resources {
177     local dest="$1"
178     case $TYPE in
179         universal)
180             local prefix=$ROOT/32
181             ;;
182         thin)
183             local prefix=$ROOT
184             ;;
185     esac
186     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic_small.png "$dest"
187     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2.icns "$dest"
188     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_kdm.icns "$dest"
189     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_server.icns "$dest"
190     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_player.icns "$dest"
191     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_batch.icns "$dest"
192     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_playlist.icns "$dest"
193     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_disk.icns "$dest"
194     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_combiner.icns "$dest"
195     cp $prefix/src/dcpomatic/graphics/osx/preferences/defaults.png "$dest"
196     cp $prefix/src/dcpomatic/graphics/osx/preferences/defaults@2x.png "$dest"
197     cp $prefix/src/dcpomatic/graphics/osx/preferences/kdm_email.png "$dest"
198     cp $prefix/src/dcpomatic/graphics/osx/preferences/kdm_email@2x.png "$dest"
199     cp $prefix/src/dcpomatic/graphics/osx/preferences/email.png "$dest"
200     cp $prefix/src/dcpomatic/graphics/osx/preferences/email@2x.png "$dest"
201     cp $prefix/src/dcpomatic/graphics/osx/preferences/servers.png "$dest"
202     cp $prefix/src/dcpomatic/graphics/osx/preferences/servers@2x.png "$dest"
203     cp $prefix/src/dcpomatic/graphics/osx/preferences/tms.png "$dest"
204     cp $prefix/src/dcpomatic/graphics/osx/preferences/tms@2x.png "$dest"
205     cp $prefix/src/dcpomatic/graphics/osx/preferences/keys.png "$dest"
206     cp $prefix/src/dcpomatic/graphics/osx/preferences/keys@2x.png "$dest"
207     cp $prefix/src/dcpomatic/graphics/osx/preferences/cover_sheet.png "$dest"
208     cp $prefix/src/dcpomatic/graphics/osx/preferences/cover_sheet@2x.png "$dest"
209     cp $prefix/src/dcpomatic/graphics/osx/preferences/notifications.png "$dest"
210     cp $prefix/src/dcpomatic/graphics/osx/preferences/notifications@2x.png "$dest"
211     cp $prefix/src/dcpomatic/graphics/osx/preferences/sound.png "$dest"
212     cp $prefix/src/dcpomatic/graphics/osx/preferences/sound@2x.png "$dest"
213     cp $prefix/src/dcpomatic/graphics/osx/preferences/identifiers.png "$dest"
214     cp $prefix/src/dcpomatic/graphics/osx/preferences/identifiers@2x.png "$dest"
215     cp $prefix/src/dcpomatic/graphics/osx/preferences/general.png "$dest"
216     cp $prefix/src/dcpomatic/graphics/osx/preferences/general@2x.png "$dest"
217     cp $prefix/src/dcpomatic/graphics/osx/preferences/advanced.png "$dest"
218     cp $prefix/src/dcpomatic/graphics/osx/preferences/advanced@2x.png "$dest"
219     cp $prefix/src/dcpomatic/graphics/osx/preferences/locations.png "$dest"
220     cp $prefix/src/dcpomatic/graphics/osx/preferences/locations@2x.png "$dest"
221     cp $prefix/src/dcpomatic/fonts/LiberationSans-Regular.ttf "$dest"
222     cp $prefix/src/dcpomatic/fonts/LiberationSans-Italic.ttf "$dest"
223     cp $prefix/src/dcpomatic/fonts/LiberationSans-Bold.ttf "$dest"
224     cp $prefix/src/dcpomatic/fonts/fonts.conf.osx "$dest"/fonts.conf
225     cp $prefix/src/dcpomatic/graphics/splash.png "$dest"
226     cp $prefix/src/dcpomatic/graphics/zoom.png "$dest"
227     cp $prefix/src/dcpomatic/graphics/zoom_all.png "$dest"
228     cp $prefix/src/dcpomatic/graphics/select.png "$dest"
229     cp $prefix/src/dcpomatic/graphics/snap.png "$dest"
230     cp $prefix/src/dcpomatic/graphics/sequence.png "$dest"
231     cp $prefix/src/dcpomatic/graphics/me.jpg "$dest"
232     cp $prefix/src/dcpomatic/graphics/link.png "$dest"
233     cp -r $prefix/share/libdcp/xsd "$dest"
234     cp -r $prefix/share/libdcp/tags "$dest"
235
236     # i18n: DCP-o-matic .mo files
237     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
238         mkdir -p "$dest/$lang/LC_MESSAGES"
239         cp $prefix/src/dcpomatic/build/src/lib/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
240         cp $prefix/src/dcpomatic/build/src/wx/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
241         cp $prefix/src/dcpomatic/build/src/tools/mo/$lang/*.mo "$dest/$lang/LC_MESSAGES"
242     done
243
244     # i18n: wxWidgets .mo files
245     for lang in de es fr it sv nl ru pl da cs; do
246         mkdir "$dest/$lang"
247         cp $ENV/64/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
248     done
249 }
250
251 # param $1 list of things that link to other things
252 function relink_relative {
253     to_relink=`echo $to_relink | sed -e "s/\+//g"`
254     local linkers=("$@")
255
256     for obj in "${linkers[@]}"; do
257         deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
258         changes=""
259         for dep in $deps; do
260             base=`basename $dep`
261             if [ "$TYPE" == "universal" ]; then
262                 # $dep will be a path within 64/; make a 32/ path too
263                 dep32=`echo $dep | sed -e "s/\/64\//\/32\//g"`
264                 changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep32 @executable_path/../Frameworks/$base"
265             else
266                 changes="$changes -change $dep @executable_path/../Frameworks/$base"
267             fi
268         done
269         if test "x$changes" != "x"; then
270             install_name_tool $changes -id `basename "$obj"` "$obj"
271         fi
272     done
273 }
274
275 # param $1 directory things should be relinked into
276 #       $2 list of things that link to other things
277 function relink_absolute {
278     to_relink=`echo $to_relink | sed -e "s/\+//g"`
279     target=$1
280     shift
281     local linkers=("$@")
282
283     for obj in "${linkers[@]}"; do
284         deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
285         for dep in $deps; do
286             base=`basename $dep`
287             install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
288         done
289     done
290 }
291
292 function sign {
293     codesign --deep --force --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$1"
294     if [ "$?" != "0" ]; then
295         echo "Failed to sign $1"
296         exit 1
297     fi
298 }
299
300
301 # @param #1 .app directory
302 # @param #2 .pkg or ""
303 # @param #3 full name e.g. DCP-o-matic Batch Converter
304 # @param #4 bundle id e.g. com.dcpomatic.batch
305 function make_dmg {
306     local appdir="$1"
307     local pkg="$2"
308     local full_name="$3"
309     local bundle_id="$4"
310     tmp_dmg=dcpomatic_tmp.dmg
311     dmg="$full_name $version.dmg"
312     vol_name=DCP-o-matic-$version
313
314     sign "$appdir"
315
316     if [ "$pkg" != "" ]; then
317         productsign --sign "Developer ID Installer: Carl Hetherington (R82DXSR997)" "$pkg" "signed_temp.pkg"
318         if [ "$?" != "0" ]; then
319             echo "Failed to sign .pkg"
320             exit 1
321         fi
322         mv signed_temp.pkg "$pkg"
323     fi
324
325     mkdir -p $vol_name
326     cp -a "$appdir" $vol_name
327     if [ "$pkg" != "" ]; then
328         cp -a "$pkg" $vol_name
329     fi
330     ln -s /Applications "$vol_name/Applications"
331     cat<<EOF > "$vol_name/READ ME.txt"
332 Welcome to DCP-o-matic!  The first time you run the program there may be
333 a long (several-minute) delay while OS X checks the code for viruses and
334 other malware.  Please be patient!
335 EOF
336     cat<<EOF > "$vol_name/READ ME.de_DE.txt"
337 Beim erstmaligen Start der DCP-o-matic Anwendungen kann ein längerer
338 Verifikationsvorgang auftreten.  Dies ist von der OS X Sicherheitsumgebung
339 'Gatekeeper' verursacht.  Dieser je nach Rechner teils minutenlange
340 Verifikationsvorgang ist gegenwärtig normal und nicht zu umgehen,
341 es ist kein Programmfehler.  Warten sie die Verifikation für jede der
342 DCP-o-matic Anwendungen ab, bei weiteren Programmstarts wird sie nicht
343 mehr auftreten.
344 EOF
345
346     if [ "$pkg" != "" ]; then
347         cat<<EOF > "$vol_name/READ ME.txt"
348
349 To run this software successfully you must install $pkg before running
350 the .app
351 EOF
352     fi
353
354     if [ "$pkg" != "" ]; then
355         cat<<EOF > "$vol_name/READ ME.de_DE.txt"
356
357 To run this software successfully you must install $pkg before running
358 the .app
359 EOF
360
361     fi
362     rm -f $tmp_dmg "$dmg"
363     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
364     attach=$(hdiutil attach -readwrite -noverify -noautoopen $tmp_dmg)
365     device=`echo $attach | egrep '^/dev/' | sed 1q | awk '{print $5}'`
366     sleep 5
367
368     echo '
369   tell application "Finder"
370     tell disk "'$vol_name'"
371            open
372            set current view of container window to icon view
373            set toolbar visible of container window to false
374            set statusbar visible of container window to false
375            set the bounds of container window to {400, 200, 1160, 600}
376            set the bounds of container window to {400, 200, 1160, 600}
377            set the bounds of container window to {400, 200, 1160, 600}
378            set theViewOptions to the icon view options of container window
379            set arrangement of theViewOptions to not arranged
380            set icon size of theViewOptions to 64
381            set position of item "'$appdir'" of container window to {90, 80}
382            set position of item "Applications" of container window to {265, 80}
383            set position of item "READ ME.txt" of container window to {430, 80}
384            set position of item "READ ME.de_DE.txt" of container window to {595, 80}
385            set position of item "DCP-o-matic Disk Writer.pkg" of container window to {90, 255}
386            close
387            open
388            update without registering applications
389            delay 5
390      end tell
391    end tell
392 ' | osascript
393
394     chmod -Rf go-w /Volumes/"$vol_name"/"$appdir"
395     sync
396
397     hdiutil eject $device
398     hdiutil convert -format UDZO $tmp_dmg -imagekey zlib-level=9 -o "$dmg"
399     sips -i "$appdir/Contents/Resources/dcpomatic2.icns"
400     DeRez -only icns "$appdir/Contents/Resources/dcpomatic2.icns" > "$appdir/Contents/Resources/DCP-o-matic.rsrc"
401     Rez -append "$appdir/Contents/Resources/DCP-o-matic.rsrc" -o "$dmg"
402     SetFile -a C "$dmg"
403     xattr -c "$dmg"
404
405     set -e
406     codesign --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$dmg"
407     set +e
408
409     rm $tmp_dmg
410     rm -rf $vol_name
411 }
412
413 # @param #1 appdir
414 function setup {
415     appdir="$1"
416     approot="$appdir/Contents"
417     rm -rf "$appdir"
418     mkdir -p "$approot/MacOS"
419     mkdir -p "$approot/Frameworks"
420     mkdir -p "$approot/Resources"
421
422     to_relink="dcpomatic"
423     copy_libs "$approot/Frameworks"
424     copy_resources "$approot/Resources"
425 }
426
427 case $TYPE in
428     universal)
429         prefix=$ROOT/32
430         ;;
431     thin)
432         prefix=$ROOT
433         ;;
434 esac
435
436 # DCP-o-matic main
437 setup "DCP-o-matic 2.app"
438 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2 "$approot/MacOS"
439 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_cli "$approot/MacOS"
440 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_create "$approot/MacOS"
441 copy $ROOT bin/ffprobe "$approot/MacOS"
442 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
443 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2.Info.plist "$approot/Info.plist"
444 rl=("$approot/MacOS/dcpomatic2" "$approot/MacOS/dcpomatic2_cli" "$approot/MacOS/dcpomatic2_create" "$approot/MacOS/ffprobe" "$approot/Frameworks/"*.dylib)
445 relink_relative "${rl[@]}"
446 make_dmg "$appdir" "" "DCP-o-matic" com.dcpomatic
447
448 # DCP-o-matic KDM Creator
449 setup "DCP-o-matic 2 KDM Creator.app"
450 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_kdm "$approot/MacOS"
451 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_kdm_cli "$approot/MacOS"
452 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
453 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_kdm.Info.plist "$approot/Info.plist"
454 rl=("$approot/MacOS/dcpomatic2_kdm" "$approot/MacOS/dcpomatic2_kdm_cli" "$approot/Frameworks/"*.dylib)
455 relink_relative "${rl[@]}"
456 make_dmg "$appdir" "" "DCP-o-matic KDM Creator" com.dcpomatic.kdm
457
458 # DCP-o-matic Encode Server
459 setup "DCP-o-matic 2 Encode Server.app"
460 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_server "$approot/MacOS"
461 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_server_cli "$approot/MacOS"
462 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
463 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_server.Info.plist "$approot/Info.plist"
464 rl=("$approot/MacOS/dcpomatic2_server" "$approot/MacOS/dcpomatic2_server_cli" "$approot/Frameworks/"*.dylib)
465 relink_relative "${rl[@]}"
466 make_dmg "$appdir" "" "DCP-o-matic Encode Server" com.dcpomatic.server
467
468 # DCP-o-matic Batch Converter
469 setup "DCP-o-matic 2 Batch converter.app"
470 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_batch "$approot/MacOS"
471 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
472 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_batch.Info.plist "$approot/Info.plist"
473 rl=("$approot/MacOS/dcpomatic2_batch" "$approot/Frameworks/"*.dylib)
474 relink_relative "${rl[@]}"
475 make_dmg "$appdir" "" "DCP-o-matic Batch Converter" com.dcpomatic.batch
476
477 # DCP-o-matic Player
478 setup "DCP-o-matic 2 Player.app"
479 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_player "$approot/MacOS"
480 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
481 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_player.Info.plist "$approot/Info.plist"
482 rl=("$approot/MacOS/dcpomatic2_player" "$approot/Frameworks/"*.dylib)
483 relink_relative "${rl[@]}"
484 make_dmg "$appdir" "" "DCP-o-matic Player" com.dcpomatic.player
485
486 # DCP-o-matic Playlist Editor
487 setup "DCP-o-matic 2 Playlist Editor.app"
488 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_playlist "$approot/MacOS"
489 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
490 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_playlist.Info.plist "$approot/Info.plist"
491 rl=("$approot/MacOS/dcpomatic2_playlist" "$approot/Frameworks/"*.dylib)
492 relink_relative "${rl[@]}"
493 make_dmg "$appdir" "" "DCP-o-matic Playlist Editor" com.dcpomatic.playlist
494
495 # DCP-o-matic Combiner
496 setup "DCP-o-matic 2 Combiner.app"
497 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_combiner "$approot/MacOS"
498 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
499 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_combiner.Info.plist "$approot/Info.plist"
500 rl=("$approot/MacOS/dcpomatic2_combiner" "$approot/Frameworks/"*.dylib)
501 relink_relative "${rl[@]}"
502 make_dmg "$appdir" "" "DCP-o-matic Combiner" com.dcpomatic.combiner
503
504 # DCP-o-matic Disk Writer .app
505 setup "DCP-o-matic 2 Disk Writer.app"
506 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk "$approot/MacOS"
507 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
508 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_disk.Info.plist "$approot/Info.plist"
509 rl=("$approot/MacOS/dcpomatic2_disk" "$approot/Frameworks/"*.dylib)
510 relink_relative "${rl[@]}"
511
512 # DCP-o-matic Disk Writer daemon .pkg
513
514 pkgbase=tmp-disk-writer
515 rm -rf $pkgbase
516 mkdir $pkgbase
517 pkgbin=$pkgbase/bin
518 pkgroot=$pkgbase/root
519
520 mkdir -p $pkgroot/Library/LaunchDaemons
521 cat > $pkgroot/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist <<EOF
522 <?xml version="1.0" encoding="UTF-8"?>
523 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
524 <plist version="1.0">
525 <dict>
526     <key>Label</key>
527     <string>com.dcpomatic.disk.writer</string>
528     <key>ProgramArguments</key>
529     <array>
530         <string>/Library/Application Support/com.dcpomatic/dcpomatic2_disk_writer</string>
531     </array>
532     <key>EnvironmentVariables</key>
533     <dict>
534         <key>DYLD_LIBRARY_PATH</key>
535         <string><![CDATA[/Library/Application Support/com.dcpomatic]]></string>
536     </dict>
537     <key>StandardOutPath</key>
538     <string>/var/log/dcpomatic_disk_writer_out.log</string>
539     <key>StandardErrorPath</key>
540     <string>/var/log/dcpomatic_disk_writer_err.log</string>
541     <key>LaunchEvents</key>
542     <dict>
543         <key>com.apple.notifyd.matching</key>
544         <dict>
545             <key>com.dcpomatic.disk.writer.start</key>
546             <dict>
547                 <key>Notification</key>
548                 <string>com.dcpomatic.disk.writer.start</string>
549             </dict>
550         </dict>
551     </dict>
552 </dict>
553 </plist>
554 EOF
555
556 # Get the binaries together in $pkgbin then move them to the
557 # place with spaces in the filename to avoid some of the pain of escaping
558
559 mkdir $pkgbin
560 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk_writer "$pkgbin"
561 copy_libs "$pkgbin"
562
563 rl=("$pkgbin/dcpomatic2_disk_writer" "$pkgbin/"*.dylib)
564 relink_absolute "/Library/Application Support/com.dcpomatic" "${rl[@]}"
565
566 mkdir $pkgbase/scripts
567 cat > $pkgbase/scripts/postinstall <<EOF
568 #!/bin/sh
569 /bin/launchctl unload "/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist"
570 /bin/launchctl load "/Library/LaunchDaemons/com.dcpomatic.disk.writer.plist"
571 exit 0
572 EOF
573 chmod gou+x $pkgbase/scripts/postinstall
574
575 find "$pkgbin" -iname "*.dylib" -print0 | while IFS= read -r -d '' f; do
576     sign "$f"
577 done
578 sign "$pkgbin/dcpomatic2_disk_writer"
579
580 mkdir -p "$pkgroot/Library/Application Support/com.dcpomatic"
581 mv $pkgbin/* "$pkgroot/Library/Application Support/com.dcpomatic/"
582 pkgbuild --root $pkgroot --identifier com.dcpomatic.disk.writer --scripts $pkgbase/scripts "DCP-o-matic Disk Writer.pkg"
583
584 make_dmg "$appdir" "DCP-o-matic Disk Writer.pkg" "DCP-o-matic Disk Writer" com.dcpomatic.disk
585