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