3
### Script to create the .app structure for osx
4
### 20090730 Stelios Bounanos M0GLD
7
echo "Syntax: $0 data-dir build-dir" >&2
11
if [ -z "$PACKAGE_TARNAME" ]; then
12
echo "E: \$PACKAGE_TARNAME undefined"
19
bundle_dir="$APPBUNDLE_NOLIBS"
20
static_bundle_dir="$APPBUNDLE"
22
for d in "$data" "$build"; do
23
test -d "$d" && continue
24
echo "E: ${d}: not a directory" >&2
27
if ! test -w "$build"; then
28
echo "E: ${build} is not writeable" >&2
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
40
# aaaaaaaaaargh => Aaaaaaaaaargh
43
sed 'h; s/\(^.\).*/\1/; y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/; G; s/\n.//'
49
while test "x$list" != "x"; do
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"
63
install_name_tool -change "$lib" "@executable_path/../Frameworks/$libfn" "$obj"
71
appname="${binary}-${appversion}.app"
75
echo "creating ${build}/$bundle_dir/$appname"
76
$mkinstalldirs "$bundle_dir/$appname/Contents/MacOS" "$bundle_dir/$appname/Contents/Resources"
78
$INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS"
79
test "x$NOSTRIP" = "x" && ${STRIP:-strip} -S "$appname/Contents/MacOS/$binary"
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
92
# bundle the binary and its non-standard dependencies
93
echo "creating ${build}/$static_bundle_dir/$appname"
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"
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"
110
version="${FLRIG_VERSION_MAJOR}.${FLRIG_VERSION_MINOR}"
111
appversion="$FLRIG_VERSION"
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"