~ubuntu-branches/ubuntu/trusty/fldigi/trusty

« back to all changes in this revision

Viewing changes to scripts/mkappbundle.sh

  • Committer: Bazaar Package Importer
  • Author(s): Joop Stakenborg
  • Date: 2008-11-17 19:40:43 UTC
  • mfrom: (1.1.6 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081117194043-sfe108e41ppsyhxr
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
### Script to create the .app structure for osx
4
4
### 20080227  Stelios Bounanos M0GLD
5
 
 
6
 
if [ $# -ne 2 ]; then
7
 
    echo "Syntax: $0 data-dir build-dir" >&2
 
5
### Updated 20080727: enable the .icns support
 
6
 
 
7
if [ $# -ne 4 ]; then
 
8
    echo "Syntax: $0 data-dir build-dir bundle-dir static-bundle-dir" >&2
 
9
    exit 1
 
10
fi
 
11
 
 
12
if [ -z "$PACKAGE_TARNAME" ]; then
 
13
    echo "E: \$PACKAGE_TARNAME undefined"
8
14
    exit 1
9
15
fi
10
16
 
11
17
PWD=`pwd`
12
18
data="${PWD}/$1"
13
19
build="${PWD}/$2"
 
20
bundle_dir="$3"
 
21
static_bundle_dir="$4"
14
22
# more sanity checks
15
23
for d in "$data" "$build"; do
16
24
    test -d "$d" && continue
17
 
    echo "%{d}: not a directory" >&2
 
25
    echo "E: ${d}: not a directory" >&2
18
26
    exit 1
19
27
done
20
28
if ! test -w "$build"; then
21
 
    echo "%{build} is not writeable" >&2
 
29
    echo "E: ${build} is not writeable" >&2
22
30
    exit 1
23
31
fi
24
32
 
25
33
plist="${data}/mac/Info.plist.in"
26
 
icons="${data}/mac/fldigi.icns"
27
 
for f in "$plist" "$icons"; do
 
34
icon="${data}/mac/fldigi.icns"
 
35
for f in "$plist" "$icon"; do
28
36
    test -r "$f" && continue
29
 
    echo "%{f}: not readable" >&2
 
37
    echo "E: ${f}: not readable" >&2
30
38
    exit 1
31
39
done
32
40
 
 
41
# aaaaaaaaaargh => Aaaaaaaaaargh
 
42
upcase1()
 
43
{
 
44
    sed 'h; s/\(^.\).*/\1/; y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/; G; s/\n.//'
 
45
}
33
46
 
34
 
identifier="com.w1hkj.fldigi"
35
 
name="Fldigi"
36
 
signature="fldg"
37
 
binary="fldigi"
 
47
identifier="com.w1hkj.$PACKAGE_TARNAME"
 
48
name=$(echo "$PACKAGE_TARNAME" | upcase1)
 
49
# we'll use the first four consonants as the signature
 
50
signature="$(echo $PACKAGE_TARNAME | sed 's/[aeiouAEIOU]//g; s/\(^....\).*/\1/')"
 
51
binary="$PACKAGE_TARNAME"
38
52
version="${FLDIGI_VERSION_MAJOR}.${FLDIGI_VERSION_MINOR}"
39
 
icon="`basename $icons`"
40
53
 
41
54
set -e
42
55
 
43
56
cd "$build"
44
57
 
45
58
# bundle the binary
46
 
echo "Creating ${build}/mac-bundle/"$PACKAGE".app"
47
 
$mkinstalldirs mac-bundle/"$PACKAGE".app/Contents/MacOS mac-bundle/"$PACKAGE".app/Contents/Resources
48
 
cd mac-bundle
49
 
$INSTALL_STRIP_PROGRAM "${build}/$binary" "$PACKAGE".app/Contents/MacOS
50
 
# $INSTALL_DATA "$icons" "$PACKAGE".app/Contents/Resources
51
 
echo "APPL${signature}" > "$PACKAGE".app/Contents/PkgInfo
 
59
appname="${PACKAGE_TARNAME}-${PACKAGE_VERSION}.app"
 
60
echo "creating ${build}/$bundle_dir/$appname"
 
61
$mkinstalldirs "$bundle_dir/$appname/Contents/MacOS" "$bundle_dir/$appname/Contents/Resources"
 
62
cd "$bundle_dir"
 
63
$INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS"
 
64
if test "x$STRIP" != "x0"; then
 
65
    strip -S "$appname/Contents/MacOS/$binary"
 
66
fi
 
67
$INSTALL_DATA "$icon" "$appname/Contents/Resources"
 
68
echo "APPL${signature}" > "$appname/Contents/PkgInfo"
52
69
sed -e "s!%%IDENTIFIER%%!${identifier}!g; s!%%NAME%%!${name}!g;\
53
70
        s!%%SIGNATURE%%!${signature}!g; s!%%BINARY%%!${binary}!g;\
54
 
        s!%%VERSION%%!${version}!g; s!%%ICON%%!${icon}!g;" < "$plist" > "$PACKAGE".app/Contents/Info.plist
55
 
if grep '%%[A-Z]*%%' "$PACKAGE".app/Contents/Info.plist; then
56
 
    echo "Unsubstituted variables in Info.plist!" >&2
 
71
        s!%%VERSION%%!${version}!g; s!%%ICON%%!${icon##*/}!g;" < "$plist" > "$appname/Contents/Info.plist"
 
72
if grep '%%[A-Z]*%%' "$appname/Contents/Info.plist"; then
 
73
    echo "E: unsubstituted variables in $appname/Contents/Info.plist" >&2
57
74
    exit 1
58
75
fi
59
76
 
60
77
 
61
78
# bundle the binary and its non-standard dependencies
62
 
echo "Creating ${build}/mac-libs-bundle/"$PACKAGE".app"
 
79
echo "creating ${build}/$static_bundle_dir/$appname"
63
80
cd ..
64
 
$mkinstalldirs mac-libs-bundle
65
 
cp -pR mac-bundle/"$PACKAGE".app mac-libs-bundle
66
 
$mkinstalldirs mac-libs-bundle/"$PACKAGE".app/Contents/Frameworks
67
 
cd mac-libs-bundle/"$PACKAGE".app/Contents
 
81
$mkinstalldirs "$static_bundle_dir"
 
82
cp -pR "$bundle_dir/$appname" "$static_bundle_dir"
 
83
$mkinstalldirs "$static_bundle_dir/$appname/Contents/Frameworks"
 
84
cd "$static_bundle_dir/$appname/Contents"
68
85
 
69
86
list="MacOS/$binary"
70
87
while test "x$list" != "x"; do
85
102
        done
86
103
    done
87
104
done
 
105
 
 
106
cd "$build"
 
107
echo $ECHO_N "creating disk image"
 
108
hdiutil create -ov -srcfolder "$bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION-nolibs.dmg"
 
109
echo $ECHO_N "creating disk image"
 
110
hdiutil create -ov -srcfolder "$static_bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "$PACKAGE_TARNAME-$PACKAGE_VERSION.dmg"