Seems over-complicated to use SDK-specific subdirectories.
[dcpomatic.git] / platform / osx / make_dmg.sh
index 949999ceeb0ea6d409905cca75e2d7c7e83a7e92..9ba05ac96485846a00ecb7e303f6264a12f7edf3 100644 (file)
@@ -1,9 +1,8 @@
 #!/bin/bash
 #
-SYNTAX="make_dmg.sh <environment> <builddir> <type> <apple-id> <apple-password>"
-# where <type> is universal or thin
+SYNTAX="make_dmg.sh <environment> <builddir> <apple-id> <apple-password>"
 #
-# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist universal foo@bar.net opensesame
+# e.g. make_dmg.sh /Users/carl/osx-environment /Users/carl/cdist foo@bar.net opensesame
 
 # Don't set -e here as egrep (used a few times) returns 1 if no matches
 # were found.
@@ -14,94 +13,61 @@ version=`git describe --tags --abbrev=0 | sed -e "s/v//"`
 DMG_SIZE=256
 ENV=$1
 ROOT=$2
-TYPE=$3
-APPLE_ID=$4
-APPLE_PASSWORD=$5
-
-if [ "$TYPE" != "universal" -a "$TYPE" != "thin" ]; then
-    echo $SYNTAX
-    echo "where <type> is universal or thin"
-    exit 1
-fi
+APPLE_ID=$3
+APPLE_PASSWORD=$4
 
 # This is our work area for making up the .dmgs
 mkdir -p build/platform/osx
 cd build/platform/osx
 
+cat <<EOF > entitlements.plist
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+  <key>com.apple.security.cs.disable-library-validation</key>
+  <true/>
+  <key>com.apple.security.cs.allow-dyld-environment-variables</key>
+  <true/>
+</dict>
+</plist>
+EOF
+
 function copy {
-    case $TYPE in
-       universal)
-           for f in $1/32/$2; do
+       for f in $1/arm64/$2; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$3/`basename $f`"
+                       ln -s $(readlink $f) "$3/`basename $f`"
                else
-                   g=`echo $f | sed -e "s/\/32\//\/64\//g"`
-                   mkdir -p "$3"
-                   lipo -create $f $g -output "$3/`basename $f`"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$3"
+                       lipo -create $f $g -output "$3/`basename $f`"
                fi
-           done
-           ;;
-       thin)
-           if [ -h $1/$2 ]; then
-               ln -s $(readlink $1/$2) "$3/`basename $f`"
-            else
-               cp $1/$2 "$3"
-           fi
-           ;;
-    esac
+       done
 }
 
 function copy_lib_root {
-    case $TYPE in
-       universal)
-           for f in $ROOT/32/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/32\//\/64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
-               fi
-           done
-           ;;
-       thin)
-           for f in $ROOT/lib/$1*.dylib; do
+       for f in $ROOT/arm64/lib/$1*.dylib; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
+                       ln -s $(readlink $f) "$2/`basename $f`"
                else
-                   mkdir -p "$2"
-                   cp $f "$2"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$2"
+                       lipo -create $f $g -output "$2/`basename $f`"
                fi
-           done
-           ;;
-    esac
+       done
     to_relink="$to_relink|$1"
 }
 
 function copy_lib_env {
-    case $TYPE in
-       universal)
-           for f in $ENV/32/lib/$1*.dylib; do
-               if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
-               else
-                   g=`echo $f | sed -e "s/\/32\//\/64\//g"`
-                   mkdir -p "$2"
-                   lipo -create $f $g -output "$2/`basename $f`"
-               fi
-           done
-           ;;
-       thin)
-           for f in $ENV/64/lib/$1*.dylib; do
+       for f in $ENV/arm64/lib/$1*.dylib; do
                if [ -h $f ]; then
-                   ln -s $(readlink $f) "$2/`basename $f`"
+                       ln -s $(readlink $f) "$2/`basename $f`"
                else
-                   mkdir -p "$2"
-                   cp $f "$2"
+                       g=`echo $f | sed -e "s/\/arm64\//\/x86_64\//g"`
+                       mkdir -p "$2"
+                       lipo -create $f $g -output "$2/`basename $f`"
                fi
-           done
-           ;;
-    esac
+       done
     to_relink="$to_relink|$1"
 }
 
@@ -170,19 +136,17 @@ function copy_libs {
     copy_lib_env libvorbis "$dest"
     copy_lib_env libogg "$dest"
     copy_lib_env libxerces-c "$dest"
+    copy_lib_env libcrypto "$dest"
+    copy_lib_env libssl "$dest"
+    copy_lib_env libfribidi "$dest"
+    copy_lib_env libgio "$dest"
+    copy_lib_env libz "$dest"
 }
 
 # @param #1 directory to copy to
 function copy_resources {
     local dest="$1"
-    case $TYPE in
-       universal)
-           local prefix=$ROOT/32
-           ;;
-       thin)
-           local prefix=$ROOT
-           ;;
-    esac
+       local prefix=$ROOT/x86_64
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic_small.png "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2.icns "$dest"
     cp $prefix/src/dcpomatic/graphics/osx/dcpomatic2_kdm.icns "$dest"
@@ -230,6 +194,8 @@ function copy_resources {
     cp $prefix/src/dcpomatic/graphics/sequence.png "$dest"
     cp $prefix/src/dcpomatic/graphics/me.jpg "$dest"
     cp $prefix/src/dcpomatic/graphics/link.png "$dest"
+    cp $prefix/src/dcpomatic/graphics/tick.png "$dest"
+    cp $prefix/src/dcpomatic/graphics/no_tick.png "$dest"
     cp -r $prefix/share/libdcp/xsd "$dest"
     cp -r $prefix/share/libdcp/tags "$dest"
 
@@ -244,7 +210,7 @@ function copy_resources {
     # i18n: wxWidgets .mo files
     for lang in de es fr it sv nl ru pl da cs; do
        mkdir "$dest/$lang"
-       cp $ENV/64/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
+       cp $ENV/x86_64/share/locale/$lang/LC_MESSAGES/wxstd.mo "$dest/$lang"
     done
 }
 
@@ -254,17 +220,13 @@ function relink_relative {
     local linkers=("$@")
 
     for obj in "${linkers[@]}"; do
-       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
+       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
        changes=""
        for dep in $deps; do
            base=`basename $dep`
-           if [ "$TYPE" == "universal" ]; then
-               # $dep will be a path within 64/; make a 32/ path too
-               dep32=`echo $dep | sed -e "s/\/64\//\/32\//g"`
-               changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep32 @executable_path/../Frameworks/$base"
-           else
-               changes="$changes -change $dep @executable_path/../Frameworks/$base"
-           fi
+               # $dep will be a path within x86_64; make arm64 path too
+               dep_arm64=`echo $dep | sed -e "s/\/x86_64\//\/arm64\//g"`
+               changes="$changes -change $dep @executable_path/../Frameworks/$base -change $dep_arm64 @executable_path/../Frameworks/$base"
        done
        if test "x$changes" != "x"; then
            install_name_tool $changes -id `basename "$obj"` "$obj"
@@ -281,16 +243,16 @@ function relink_absolute {
     local linkers=("$@")
 
     for obj in "${linkers[@]}"; do
-       deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu)"`
-       for dep in $deps; do
-           base=`basename $dep`
-            install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
-       done
+               deps=`otool -L "$obj" | awk '{print $1}' | egrep "($to_relink)" | egrep "($ENV|$ROOT|boost|libicu|libssh)"`
+               for dep in $deps; do
+                       base=`basename $dep`
+                       install_name_tool -change "$dep" "$target"/$base -id `basename "$obj"` "$obj"
+               done
     done
 }
 
 function sign {
-    codesign --deep --force --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$1"
+    codesign --deep --force --verify --verbose --options runtime --entitlements entitlements.plist --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$1"
     if [ "$?" != "0" ]; then
        echo "Failed to sign $1"
        exit 1
@@ -401,7 +363,7 @@ EOF
     xattr -c "$dmg"
 
     set -e
-    codesign --verify --verbose --options runtime --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$dmg"
+    codesign --verify --verbose --options runtime --entitlements entitlements.plist --sign "Developer ID Application: Carl Hetherington (R82DXSR997)" "$dmg"
     set +e
 
     rm $tmp_dmg
@@ -422,14 +384,7 @@ function setup {
     copy_resources "$approot/Resources"
 }
 
-case $TYPE in
-    universal)
-       prefix=$ROOT/32
-       ;;
-    thin)
-       prefix=$ROOT
-       ;;
-esac
+prefix=$ROOT/arm64
 
 # DCP-o-matic main
 setup "DCP-o-matic 2.app"
@@ -503,6 +458,7 @@ make_dmg "$appdir" "" "DCP-o-matic Combiner"
 setup "DCP-o-matic 2 Disk Writer.app"
 copy $ROOT src/dcpomatic/build/src/tools/dcpomatic2_disk "$approot/MacOS"
 copy $ROOT src/openssl/apps/openssl "$approot/MacOS"
+cp $prefix/src/dcpomatic/platform/osx/uninstall_disk.applescript "$approot/Resources"
 cp $prefix/src/dcpomatic/build/platform/osx/dcpomatic2_disk.Info.plist "$approot/Info.plist"
 rl=("$approot/MacOS/dcpomatic2_disk" "$approot/Frameworks/"*.dylib)
 relink_relative "${rl[@]}"