File: make-bundle

package info (click to toggle)
poedit 1.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,688 kB
  • ctags: 1,229
  • sloc: cpp: 9,686; sh: 3,951; makefile: 269; ansic: 10
file content (120 lines) | stat: -rwxr-xr-x 3,553 bytes parent folder | download | duplicates (2)
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh

#
# Creates Mac OS X bundle file. Must be run from $(builddir)/src
#
# Usage: make-bundle <bundleName.app> <rez> <top_builddir> <top_srcdir>
# 
# $Id: make-bundle 1267 2007-12-27 12:08:17Z vaclavslavik $
#

bundle="$1"
rez="$2"
top_builddir="$3"
top_srcdir="$4"


# this function returns *non-system* shared libs a binary depends on
get_private_shared_deps()
{
    # ignore any shared libs in /usr/lib* or /System
    otool -X -L $1 | cut -d" " -f1 | cut -c2- | grep -v '^\(/usr/lib\|/System\)'
}

prepend_path()
{
    path=$1
    shift
    for f in $* ; do echo $path/$f; done
}


rm -rf $bundle
mkdir -p $bundle/Contents/MacOS
mkdir -p $bundle/Contents/Resources

bindir="$bundle/Contents/MacOS"

# executables:
cp poedit $bindir/Poedit
$rez $bindir/Poedit

if [ -n "$GETTEXT_PREFIX" ] ; then
    gettext_apps="msgfmt msgmerge msgunfmt msgcat xgettext"

    all_dylibs=""

    # copy gettext binaries over:
    for f in $gettext_apps ; do
        cp -pPf $GETTEXT_PREFIX/bin/$f $bindir

        # now copy any gettext shared libs they need and update their install paths
        # so that they are usable from the bundle:
        for dylib_full in `get_private_shared_deps $bindir/$f` ; do
            all_dylibs="$all_dylibs $dylib_full"
            dylib=`basename $dylib_full`
            if [ ! -f $bindir/$dylib -a -f $GETTEXT_PREFIX/lib/$dylib ] ; then
                cp -pPf $GETTEXT_PREFIX/lib/$dylib $bindir
                install_name_tool -id $dylib $bindir/$dylib
            fi
        done
    done
    
    # now update shared libs references to point to bundle's location so that they
    # are correctly resolved at runtime:
    for dylib in $all_dylibs ; do
        for f in `prepend_path $bindir $gettext_apps` $bindir/*.dylib ; do
            install_name_tool -change $dylib "@executable_path/`basename $dylib`" $f
        done
    done
else
    echo "WARNING: not copying gettext binaries, point GETTEXT_PREFIX" >&2
    echo "         environment variable to a directory that contains them" >&2
fi

# extract (DWARF) debug information into separate dSYM files and pack them into
# an archive:
if [ -f /usr/bin/dsymutil ] ; then
    dsymutil $bindir/Poedit
    tar -cjf $bundle.dSYM.tar.bz2 $bundle/Contents/MacOS/Poedit.dSYM
    rm -rf $bundle/Contents/MacOS/Poedit.dSYM
    strip -u -r $bindir/Poedit
else
    echo "WARNING: Xcode 2.4+ is needed to extract debug information" >&2
fi

# metadata:
cp $top_builddir/macosx/Info.plist $bundle/Contents
cp $top_srcdir/macosx/*.icns $bundle/Contents/Resources

# gettext catalogs:
for i in $top_srcdir/locales/*.mo ; do
    lang=`basename $i .mo`
    mkdir -p $bundle/Contents/Resources/locale/$lang/LC_MESSAGES
    cp $i $bundle/Contents/Resources/locale/$lang/LC_MESSAGES/poedit.mo
done

if [ -n "$WX_ROOT" ] ; then
    (cd $WX_ROOT/share ; tar -c locale) | \
        (cd $bundle/Contents/Resources ; tar -x)
else
    echo "WARNING: not copying wxWidgets message catalogs, point WX_ROOT" >&2
    echo "         environment variable to a directory with installed wx" >&2
fi

# 3rd party frameworks:
if [ -n "$SPARKLE_FRAMEWORK" ] ; then
    mkdir -p $bundle/Contents/Frameworks
    cp -R $SPARKLE_FRAMEWORK $bundle/Contents/Frameworks
else
    echo "WARNING: not copying Sparkle framework, point SPARKLE_FRAMEWORK" >&2
    echo "         environment variable to it" >&2
fi

echo "Installed message catalogs:"
find $bundle/Contents/Resources/locale -type f

# icons:
iconsdir="$bundle/Contents/Resources/icons"
mkdir -p $iconsdir
cp $top_srcdir/src/icons/*.png $iconsdir