~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to scripts/mkappbundle.sh

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-06-07 11:28:52 UTC
  • Revision ID: package-import@ubuntu.com-20140607112852-v4d5tb1m3h3vi0dl
Tags: upstream-1.3.15
ImportĀ upstreamĀ versionĀ 1.3.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
### Script to create the .app structure for osx
 
4
### 20090730  Stelios Bounanos M0GLD
 
5
 
 
6
if [ $# -ne 2 ]; then
 
7
    echo "Syntax: $0 data-dir build-dir" >&2
 
8
    exit 1
 
9
fi
 
10
 
 
11
if [ -z "$PACKAGE_TARNAME" ]; then
 
12
    echo "E: \$PACKAGE_TARNAME undefined"
 
13
    exit 1
 
14
fi
 
15
 
 
16
PWD=`pwd`
 
17
data="${PWD}/$1"
 
18
build="${PWD}/$2"
 
19
bundle_dir="$APPBUNDLE_NOLIBS"
 
20
static_bundle_dir="$APPBUNDLE"
 
21
# more sanity checks
 
22
for d in "$data" "$build"; do
 
23
    test -d "$d" && continue
 
24
    echo "E: ${d}: not a directory" >&2
 
25
    exit 1
 
26
done
 
27
if ! test -w "$build"; then
 
28
    echo "E: ${build} is not writeable" >&2
 
29
    exit 1
 
30
fi
 
31
 
 
32
plist="${data}/mac/Info.plist.in"
 
33
flrig_icon="${data}/mac/flrig.icns"
 
34
for f in "$plist" "$flrig_icon"; do
 
35
    test -r "$f" && continue
 
36
    echo "E: ${f}: not readable" >&2
 
37
    exit 1
 
38
done
 
39
 
 
40
# aaaaaaaaaargh => Aaaaaaaaaargh
 
41
upcase1()
 
42
{
 
43
    sed 'h; s/\(^.\).*/\1/; y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/; G; s/\n.//'
 
44
}
 
45
 
 
46
function copy_libs()
 
47
{
 
48
    list="$1"
 
49
    while test "x$list" != "x"; do
 
50
        change="$list"
 
51
        list=""
 
52
 
 
53
        for obj in $change; do
 
54
            for lib in `otool -L $obj | \
 
55
                sed -n 's!^.*[[:space:]]\([^[:space:]]*\.dylib\).*$!\1!p' | \
 
56
                grep -Ev '^/(usr/lib|System)'`; do
 
57
                libfn="`basename $lib`"
 
58
                if ! test -f "Frameworks/$libfn"; then
 
59
                    cp "$lib" "Frameworks/$libfn"
 
60
                    install_name_tool -id "@executable_path/../Frameworks/$libfn" "Frameworks/$libfn"
 
61
                    list="$list Frameworks/$libfn"
 
62
                fi
 
63
                install_name_tool -change "$lib" "@executable_path/../Frameworks/$libfn" "$obj"
 
64
            done
 
65
        done
 
66
    done
 
67
}
 
68
 
 
69
function bundle()
 
70
{
 
71
    appname="${binary}-${appversion}.app"
 
72
    cd "$build"
 
73
 
 
74
    # bundle the binary
 
75
    echo "creating ${build}/$bundle_dir/$appname"
 
76
    $mkinstalldirs "$bundle_dir/$appname/Contents/MacOS" "$bundle_dir/$appname/Contents/Resources"
 
77
    cd "$bundle_dir"
 
78
    $INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS"
 
79
    test "x$NOSTRIP" = "x" && ${STRIP:-strip} -S "$appname/Contents/MacOS/$binary"
 
80
 
 
81
    $INSTALL_DATA "$icon" "$appname/Contents/Resources"
 
82
    echo "APPL${signature}" > "$appname/Contents/PkgInfo"
 
83
    sed -e "s!%%IDENTIFIER%%!${identifier}!g; s!%%NAME%%!${name}!g;\
 
84
        s!%%SIGNATURE%%!${signature}!g; s!%%BINARY%%!${binary}!g;\
 
85
        s!%%VERSION%%!${version}!g; s!%%ICON%%!${icon##*/}!g;" < "$plist" > "$appname/Contents/Info.plist"
 
86
    if grep '%%[A-Z]*%%' "$appname/Contents/Info.plist"; then
 
87
        echo "E: unsubstituted variables in $appname/Contents/Info.plist" >&2
 
88
        exit 1
 
89
    fi
 
90
 
 
91
 
 
92
    # bundle the binary and its non-standard dependencies
 
93
    echo "creating ${build}/$static_bundle_dir/$appname"
 
94
    cd ..
 
95
    $mkinstalldirs "$static_bundle_dir"
 
96
    cp -pR "$bundle_dir/$appname" "$static_bundle_dir"
 
97
    $mkinstalldirs "$static_bundle_dir/$appname/Contents/Frameworks"
 
98
    cd "$static_bundle_dir/$appname/Contents"
 
99
    copy_libs "MacOS/$binary"
 
100
}
 
101
 
 
102
set -e
 
103
 
 
104
identifier="com.w1hkj.$PACKAGE_TARNAME"
 
105
name=$(echo "$PACKAGE_TARNAME" | upcase1)
 
106
# we'll use the first four consonants as the signature
 
107
signature="$(echo $PACKAGE_TARNAME | sed 's/[aeiouAEIOU]//g; s/\(^....\).*/\1/')"
 
108
binary="$PACKAGE_TARNAME"
 
109
icon="$flrig_icon"
 
110
version="${FLRIG_VERSION_MAJOR}.${FLRIG_VERSION_MINOR}"
 
111
appversion="$FLRIG_VERSION"
 
112
 
 
113
bundle
 
114
 
 
115
cd "$build"
 
116
echo $ECHO_N "creating disk image"
 
117
hdiutil create -ov -srcfolder "$bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "${APPBUNDLE}-nolibs.dmg"
 
118
echo $ECHO_N "creating disk image"
 
119
hdiutil create -ov -srcfolder "$static_bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "${APPBUNDLE}.dmg"