3
3
### Script to create the .app structure for osx
4
4
### 20080227 Stelios Bounanos M0GLD
7
echo "Syntax: $0 data-dir build-dir" >&2
5
### Updated 20080727: enable the .icns support
8
echo "Syntax: $0 data-dir build-dir bundle-dir static-bundle-dir" >&2
12
if [ -z "$PACKAGE_TARNAME" ]; then
13
echo "E: \$PACKAGE_TARNAME undefined"
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
20
28
if ! test -w "$build"; then
21
echo "%{build} is not writeable" >&2
29
echo "E: ${build} is not writeable" >&2
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
41
# aaaaaaaaaargh => Aaaaaaaaaargh
44
sed 'h; s/\(^.\).*/\1/; y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/; G; s/\n.//'
34
identifier="com.w1hkj.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`"
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
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"
63
$INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS"
64
if test "x$STRIP" != "x0"; then
65
strip -S "$appname/Contents/MacOS/$binary"
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
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"
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"
69
86
list="MacOS/$binary"
70
87
while test "x$list" != "x"; do