summaryrefslogtreecommitdiffstats
path: root/rbutil/rbutilqt/osx_deploy.sh
blob: bd9b0095c3b956f37001b81ce83e162c42ef74c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/sh
#             __________               __   ___.
#   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
#   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
#   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
#   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
#                     \/            \/     \/    \/            \/
# $Id: gentalkclips.sh 11426 2006-11-03 21:47:52Z rasher $
#
# Copyright (c) 2007 Barry Wardell
#
# All files in this archive are subject to the GNU General Public License.
# See the file COPYING in the source tree root for full license agreement.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
#
# Purpose of this script: Prepare Mac OS X version of rbutil for distribution.
#
# Inputs: None
#
# Action: Copy necessary Qt frameworks into the rbutilqt application bundle.
#         Update the linking of rbutilqt and the frameworks to refer to the new
#         new location of the framework files (inside the app bundle).
#         Create a compressed disk image from rbutilqt.app.
#
# Output: A compressed disk image called rbutilqt.dmg
#
# Requirement: This script assumes that you have rbutilqt.app in the current
#         directory and a framework build of Qt in your $PATH
#
# See http://doc.trolltech.com/4.3/deployment-mac.html for an explanation of
# what we're doing here.

# scan the $PATH for the given command
findtool(){
  file="$1"

  IFS=":"
  for path in $PATH
  do
    # echo "checks for $file in $path" >&2
    if test -f "$path/$file"; then
      echo "$path/$file"
      return
    fi
  done
}

# Try to find Qt
QTDIR=`findtool qmake`
if test -z "$QTDIR"; then
    # not in path
    echo "Error: Couldn't find Qt. Make sure it is in your \$PATH"
    exit
else
    QTDIR=`dirname \`dirname $QTDIR\``
    echo "Found Qt: $QTDIR"
fi

# Check Qt was built as frameworks
if test ! -d "$QTDIR/lib/QtCore.framework"; then
    echo "Error: Unable to find Qt frameworks in $QTDIR"
    echo "       Make sure you built Qt as frameworks and not statically."
    exit
fi

mkdir -p rbutilqt.app/Contents/Frameworks/{QtCore,QtGui,QtNetwork}.framework/Versions/4

echo "Copying frameworks"
cp $QTDIR/lib/QtCore.framework/Versions/4/QtCore  rbutilqt.app/Contents/Frameworks/QtCore.framework/Versions/4/
cp $QTDIR/lib/QtGui.framework/Versions/4/QtGui  rbutilqt.app/Contents/Frameworks/QtGui.framework/Versions/4/
cp $QTDIR/lib/QtNetwork.framework/Versions/4/QtNetwork  rbutilqt.app/Contents/Frameworks/QtNetwork.framework/Versions/4/

echo "Fixing framework linking"
install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore rbutilqt.app/Contents/Frameworks/QtCore.framework/Versions/4/QtCore
install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui rbutilqt.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui
install_name_tool -id @executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork rbutilqt.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork
install_name_tool -change $QTDIR/lib/QtCore.framework/Versions/4/QtCore  @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore rbutilqt.app/Contents/MacOS/rbutilqt 
install_name_tool -change $QTDIR/lib/QtGui.framework/Versions/4/QtGui  @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui rbutilqt.app/Contents/MacOS/rbutilqt 
install_name_tool -change $QTDIR/lib/QtNetwork.framework/Versions/4/QtNetwork  @executable_path/../Frameworks/QtNetwork.framework/Versions/4/QtNetwork rbutilqt.app/Contents/MacOS/rbutilqt 
install_name_tool -change $QTDIR/lib/QtCore.framework/Versions/4/QtCore  @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore rbutilqt.app/Contents/Frameworks/QtGui.framework/Versions/4/QtGui
install_name_tool -change $QTDIR/lib/QtCore.framework/Versions/4/QtCore  @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore rbutilqt.app/Contents/Frameworks/QtNetwork.framework/Versions/4/QtNetwork

echo "Creating disk image"
hdiutil create -srcfolder rbutilqt.app -ov rbutilqt.dmg