merge with master
[ardour.git] / tools / osx_packaging / osx_build
index 2d2328342c319147c7af6e4e91c892d37333b8bb..18d3b311eda3d25eeb1459df018eaf8bf5abedeb 100755 (executable)
@@ -8,6 +8,7 @@ BUILD_ROOT=../../build
 
 SAE=
 MIXBUS=
+WITH_HARVID=
 WITH_LADSPA=1
 STRIP=1
 PRINT_SYSDEPS=
@@ -55,6 +56,7 @@ while [ $# -gt 0 ] ; do
        # specific build flags
        #
 
+       --harvid) WITH_HARVID=1 ; shift ;;
        --noladspa) WITH_LADSPA= ; shift ;;
        --nostrip) STRIP= ; shift ;;
        --sysdeps) PRINT_SYSDEPS=1; shift ;;
@@ -62,11 +64,14 @@ while [ $# -gt 0 ] ; do
     esac
 done
 
-#release_version=`grep -m 1 '^VERSION' ../../wscript | cut -d' ' -f 3 | sed "s/'//g"`
-release_version=3.0
-svn_version=`grep -m 1 'svn_revision =' ../../libs/ardour/svn_revision.cc | cut -d' ' -f 8 | sed 's/[^0-9]//g'`
-echo "Version is $release_version / $svn_version"
-info_string="$release_version/$svn_version built on `hostname` by `whoami` on `date`"
+if test -z "$PRODUCT_PKG_DIR" -o -z "$APPNAME"; then
+       echo "application or product-name was not specified"
+       exit 1
+fi
+
+. ../define_versions.sh
+echo "Version is $release_version / $revision"
+info_string="$version built on `hostname` by `whoami` on `date`"
 echo "Info string is $info_string"
 
 # setup directory structure
@@ -126,7 +131,6 @@ mkdir -p $MidiMaps
 mkdir -p $ExportFormats
 mkdir -p $Templates
 mkdir -p $Frameworks/modules
-mkdir -p $Shared/templates
 mkdir -p $Etc
 mkdir -p $MackieControl
 
@@ -166,12 +170,12 @@ env="<key>LSEnvironment</key><dict>$env<key>ARDOUR_BUNDLED</key><string>true</st
 
 # edit plist
 sed -e "s?@ENV@?$env?g" \
-    -e "s?@VERSION@?$release_version/$svn_version?g" \
+    -e "s?@VERSION@?$release_version/$revision?g" \
     -e "s?@INFOSTRING@?$info_string?g" < Info.plist.in > Info.plist
 # and plist strings
 sed -e "s?@APPNAME@?$appname?" \
     -e "s?@ENV@?$env?g" \
-    -e "s?@VERSION@?$release_version/$svn_version?g" \
+    -e "s?@VERSION@?$release_version/$revision?g" \
     -e "s?@INFOSTRING@?$info_string?g" < InfoPlist.strings.in > Resources/InfoPlist.strings || exit 1
 
 # copy static files
@@ -265,12 +269,18 @@ rm pangorc
 gdk-pixbuf-query-loaders | sed "s?$GTKSTACK_ROOT/lib/gdk-pixbuf-2.0/2.10.0/loaders/?@executable_path/../lib/modules/?" > $Resources/gdk-pixbuf.loaders
 
 # We rely on clearlooks, so include a version from our own build tree
-# this one is special - we will set GTK_PATH to $Libraries/clearlooks
+# this one is special - we will set GTK_PATH to $Frameworks/gtkengines
 
-echo "Copying clearlooks ..."
+GTK_ENGINE_DIR=$Frameworks/gtkengines/engines
+mkdir -p $GTK_ENGINE_DIR
+
+echo "Copying GTK engines ..."
 cp $BUILD_ROOT/libs/clearlooks-newer/libclearlooks.dylib $Frameworks
-mkdir -p $Frameworks/clearlooks/engines
-(cd $Frameworks/clearlooks/engines && ln -s ../../libclearlooks.dylib libclearlooks.dylib && ln -s ../../libclearlooks.dylib libclearlooks.so)
+(cd $GTK_ENGINE_DIR && ln -s ../../libclearlooks.dylib . && ln -s ../../libclearlooks.dylib libclearlooks.so)
+
+cp $GTKSTACK_ROOT/lib/gtk-2.0/2.10.0/engines/libpixmap.so $Frameworks
+(cd $GTK_ENGINE_DIR && ln -s ../../libpixmap.so)
+
 
 if test x$WITH_LADSPA != x ; then
     if test x$SAE != x ; then
@@ -300,11 +310,11 @@ for f in $BUILD_ROOT/../export/*.preset $BUILD_ROOT/../export/*.format ; do
 done
 
 # Session and Route templates
-for f in $BUILD_ROOT/../templates/* ; do 
-    if [ -d "$f" ] ; then
-        cp -r "$f" $Templates ; 
-    fi
-done
+#for f in $BUILD_ROOT/../templates/* ; do 
+#    if [ -d "$f" ] ; then
+#        cp -r "$f" $Templates ; 
+#    fi
+#done
 
 # MidiMaps
 # got to be careful with names here
@@ -376,8 +386,7 @@ if test x$SAE != x ; then
     cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
     echo cp $BUILD_ROOT/instant.xml.sae $Resources/instant.xml
 else
-#    cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
-#    echo FOO cp $BUILD_ROOT/ardour_system.rc $Resources/ardour_system.rc
+    cp ../../ardour_system.rc $Resources/ardour_system.rc
     cp ../../instant.xml $Resources/instant.xml
     echo cp ../../instant.xml $Resources/instant.xml
 fi
@@ -389,8 +398,9 @@ cp $BUILD_ROOT/gtk2_ardour/ardour3_ui_dark.rc $Resources
 cp -r ../../gtk2_ardour/icons $Resources
 cp -r ../../gtk2_ardour/pixmaps $Resources
 
-# splash screen stuff
+# shared stuff
 cp -R ../../gtk2_ardour/splash.png $Shared
+cp -R ../../gtk2_ardour/ArdourMono.ttf $Shared
 
 # go through and recursively remove any .svn dirs in the bundle
 for svndir in `find $APPDIR -name .svn -type dir`; do
@@ -464,6 +474,9 @@ done
 rm -rf $PRODUCT_PKG_DIR
 mkdir $PRODUCT_PKG_DIR
 
+DMGWINBOTTOM=440
+DMGBACKGROUND=dmgbg.png
+
 if [ x$SAE != x ] ; then
        
     # SAE packaging
@@ -481,7 +494,9 @@ elif [ x$MIXBUS != x ] ; then
     echo "Creating Mixbus packaging directory"
     mv $APPDIR $PRODUCT_PKG_DIR/
     cp MixBus_Install_QuickStart.pdf "$PRODUCT_PKG_DIR/Mixbus Install & Quick Start Guide.pdf"
-
+               DMGWINBOTTOM=580
+               YPOS=$[ $DMGWINBOTTOM - 300 ]
+               MIXBUSPOS="set position of item \"MixBus_Install_QuickStart.pdf\" of container window to {90, ${YPOS}}"
 else 
 
     echo "Creating $APPNAME packaging directory"
@@ -489,20 +504,117 @@ else
 
 fi
 
-echo "Building DMG ..."
+if test x$WITH_HARVID != x ; then
+       echo "installing video tools.."
+       # TODO move files to http://ardour.org/files/ - symlink 'latest'
+       HARVID_VERSION=$(curl http://ardour.org/files/video-tools/harvid_version.txt)
+       XJADEO_VERSION=$(curl http://ardour.org/files/video-tools/xjadeo_version.txt)
+       echo "copying harvid and xjadeo ..."
+  curl -L -o "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg" "http://sourceforge.net/projects/xjadeo/files/xjadeo/${XJADEO_VERSION}/jadeo-${XJADEO_VERSION:1}.dmg/download"
+  curl -L "http://ardour.org/files/video-tools/harvid-osx-${HARVID_VERSION}.tgz"\
+               | tar -x -z -C $PRODUCT_PKG_DIR/$APPROOT
+
+       ls -l "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg"
+       JADEO=$(hdiutil attach "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg" | grep Apple_HFS | grep dev/ | cut -f 3)
+       cp -r "${JADEO}/Jadeo.app" "$PRODUCT_PKG_DIR/"
+       hdiutil detach "${JADEO}"
+       rm "$PRODUCT_PKG_DIR/xjadeo-${XJADEO_VERSION:1}.dmg"
+
+       DMGWINBOTTOM=580
+       YPOS=$[ $DMGWINBOTTOM - 300 ]
+       XJADEOPOS="set position of item \"Jadeo.app\" of container window to {310, ${YPOS}}"
+
+       DMGBACKGROUND=dmgbgxj.png
+fi
 
-# UC_DMG=$APPNAME-${release_version}-${svn_version}-UC.dmg
-# FINAL_DMG=$APPNAME-${release_version}-${svn_version}.dmg
-UC_DMG=$APPNAME-${release_version}-${svn_version}.dmg
+echo "Building DMG ..."
 
-rm -f $UC_DMG
-echo hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
-hdiutil create $UC_DMG -volname $APPNAME-$release_version -fs HFS+ -srcfolder $PRODUCT_PKG_DIR
+# UC_DMG=$APPNAME-${release_version}-${revision}-UC.dmg
+# FINAL_DMG=$APPNAME-${release_version}-${revision}.dmg
+UC_DMG=$APPNAME-$version.dmg
+VOLNAME=$APPNAME-$version
+
+# TODO use mktemp
+export TMPDIR=`pwd`
+MNTPATH=`mktemp -d -t /ardourimg`
+TMPDMG=`mktemp -t ardour`
+ICNSTMP=`mktemp -t ardouricon`
+EXTRA_SPACE_MB=30
+DMGMEGABYTES=$[ `du -sk "$PRODUCT_PKG_DIR" | cut -f 1` * 1024 / 1048576 + $EXTRA_SPACE_MB ]
+
+echo "DMG MB = " $DMGMEGABYTES
+
+rm -f $UC_DMG "$TMPDMG" "${TMPDMG}.dmg" "$ICNSTMP"
+rm -rf "$MNTPATH"
+mkdir -p "$MNTPATH"
+
+TMPDMG="${TMPDMG}.dmg"
+
+hdiutil create -megabytes $DMGMEGABYTES "$TMPDMG"
+DiskDevice=$(hdid -nomount "$TMPDMG" | grep Apple_HFS | cut -f 1 -d ' ')
+newfs_hfs -v "${VOLNAME}" "${DiskDevice}"
+mount -t hfs "${DiskDevice}" "${MNTPATH}"
+
+cp -r ${PRODUCT_PKG_DIR}/* "${MNTPATH}" || exit
+mkdir "${MNTPATH}/.background"
+cp -vi ${DMGBACKGROUND} "${MNTPATH}/.background/dmgbg.png"
+
+echo "setting DMG background ..."
+
+echo '
+   tell application "Finder"
+     tell disk "'${VOLNAME}'"
+           open
+           set current view of container window to icon view
+           set toolbar visible of container window to false
+           set statusbar visible of container window to false
+           set the bounds of container window to {400, 200, 800, '${DMGWINBOTTOM}'}
+           set theViewOptions to the icon view options of container window
+           set arrangement of theViewOptions to not arranged
+           set icon size of theViewOptions to 64
+           set background picture of theViewOptions to file ".background:dmgbg.png"
+           make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"}
+           set position of item "'${APPDIR}'" of container window to {90, 100}
+           set position of item "Applications" of container window to {310, 100}
+           '${MIXBUSPOS}'
+           '${HARVIDPOS}'
+           '${XJADEOPOS}'
+           close
+           open
+           update without registering applications
+           delay 5
+           eject
+     end tell
+   end tell
+' | osascript
+
+chmod -Rf go-w "${MNTPATH}"
+sync
+
+echo "compressing Image ..."
+
+# Umount the image
+umount "${DiskDevice}"
+hdiutil eject "${DiskDevice}"
+# Create a read-only version, use zlib compression
+hdiutil convert -format UDZO "${TMPDMG}" -imagekey zlib-level=9 -o "${UC_DMG}"
+# Delete the temporary files
+rm "$TMPDMG"
+rmdir "$MNTPATH"
+
+echo "setting file icon ..."
+
+cp ${PRODUCT_PKG_DIR}/$Resources/appIcon.icns ${ICNSTMP}.icns
+/usr/bin/sips -i ${ICNSTMP}.icns
+/Developer/Tools/DeRez -only icns ${ICNSTMP}.icns > ${ICNSTMP}.rsrc
+/Developer/Tools/Rez -append ${ICNSTMP}.rsrc -o "$UC_DMG"
+/Developer/Tools/SetFile -a C "$UC_DMG"
+
+rm ${ICNSTMP}.icns ${ICNSTMP}.rsrc
 
-# compress it
-# echo "Compressing DMG ..."
-# rm -f $FINAL_DMG
-# hdiutil convert $UC_DMG -format UDBZ -o $FINAL_DMG
+echo
+echo "packaging suceeded."
+ls -l "$UC_DMG"
 
 echo "Done."
-
+exit