2008-02-29 09:18:07 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
|
|
### Script to create the .app structure for osx
|
|
|
|
|
### 20080227 Stelios Bounanos M0GLD
|
2008-08-03 01:09:12 +01:00
|
|
|
### Updated 20080727: enable the .icns support
|
2009-05-26 19:57:44 +01:00
|
|
|
### Updated 20090525: add flarq
|
2018-02-01 13:45:05 -06:00
|
|
|
### Updated 20180201: deleted dmg sans dylibs
|
2008-02-29 09:18:07 +00:00
|
|
|
|
2008-08-21 19:22:32 +01:00
|
|
|
upcase1()
|
|
|
|
|
{
|
2018-02-01 13:45:05 -06:00
|
|
|
sed 'h; s/\(^.\).*/\1/; y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/; G; s/\n.//'
|
2008-08-21 19:22:32 +01:00
|
|
|
}
|
2008-02-29 09:18:07 +00:00
|
|
|
|
2009-05-26 19:57:44 +01:00
|
|
|
function copy_libs()
|
|
|
|
|
{
|
2018-02-01 13:45:05 -06:00
|
|
|
list="$1"
|
|
|
|
|
while test "x$list" != "x"; do
|
2009-05-26 19:57:44 +01:00
|
|
|
change="$list"
|
|
|
|
|
list=""
|
2008-02-29 09:18:07 +00:00
|
|
|
|
2009-05-26 19:57:44 +01:00
|
|
|
for obj in $change; do
|
2018-02-01 13:45:05 -06:00
|
|
|
for lib in `otool -L $obj | \
|
|
|
|
|
sed -n 's!^.*[[:space:]]\([^[:space:]]*\.dylib\).*$!\1!p' | \
|
|
|
|
|
grep -Ev '^/(usr/lib|System)'`; do
|
2009-05-26 19:57:44 +01:00
|
|
|
libfn="`basename $lib`"
|
|
|
|
|
if ! test -f "Frameworks/$libfn"; then
|
2018-02-01 13:45:05 -06:00
|
|
|
cp "$lib" "Frameworks/$libfn"
|
|
|
|
|
install_name_tool -id "@executable_path/../Frameworks/$libfn" "Frameworks/$libfn"
|
|
|
|
|
list="$list Frameworks/$libfn"
|
2009-05-26 19:57:44 +01:00
|
|
|
fi
|
|
|
|
|
install_name_tool -change "$lib" "@executable_path/../Frameworks/$libfn" "$obj"
|
2018-02-01 13:45:05 -06:00
|
|
|
done
|
|
|
|
|
done
|
2009-05-26 19:57:44 +01:00
|
|
|
done
|
|
|
|
|
}
|
2008-02-29 09:18:07 +00:00
|
|
|
|
2009-05-26 19:57:44 +01:00
|
|
|
function bundle()
|
|
|
|
|
{
|
2018-02-01 13:45:05 -06:00
|
|
|
appname="${binary}-${appversion}.app"
|
|
|
|
|
cd "$build"
|
|
|
|
|
|
|
|
|
|
# bundle the binary
|
|
|
|
|
echo "creating ${build}/$bundle_dir/$appname"
|
|
|
|
|
$mkinstalldirs "$bundle_dir/$appname/Contents/MacOS" "$bundle_dir/$appname/Contents/Resources"
|
|
|
|
|
cd "$bundle_dir"
|
|
|
|
|
$INSTALL_PROGRAM "${build}/$binary" "$appname/Contents/MacOS"
|
|
|
|
|
test "x$NOSTRIP" = "x" && ${STRIP:-strip} -S "$appname/Contents/MacOS/$binary"
|
|
|
|
|
|
|
|
|
|
$INSTALL_DATA "$icon" "$appname/Contents/Resources"
|
|
|
|
|
echo "APPL${signature}" > "$appname/Contents/PkgInfo"
|
|
|
|
|
sed -e "s!%%IDENTIFIER%%!${identifier}!g; s!%%NAME%%!${name}!g;\
|
|
|
|
|
s!%%SIGNATURE%%!${signature}!g; s!%%BINARY%%!${binary}!g;\
|
2020-02-10 06:52:54 -06:00
|
|
|
s!%%VERSION%%!${version}!g;\
|
|
|
|
|
s!%%ICON%%!${icon##*/}!g;" < "$plist" > "$appname/Contents/Info.plist"
|
2018-02-01 13:45:05 -06:00
|
|
|
|
|
|
|
|
if grep '%%[A-Z]*%%' "$appname/Contents/Info.plist"; then
|
2009-05-26 19:57:44 +01:00
|
|
|
echo "E: unsubstituted variables in $appname/Contents/Info.plist" >&2
|
|
|
|
|
exit 1
|
2018-02-01 13:45:05 -06:00
|
|
|
fi
|
2009-05-26 19:57:44 +01:00
|
|
|
|
2018-02-01 13:45:05 -06:00
|
|
|
$mkinstalldirs "$appname/Contents/Frameworks"
|
|
|
|
|
cd "$appname/Contents"
|
|
|
|
|
copy_libs "MacOS/$binary"
|
2009-05-26 19:57:44 +01:00
|
|
|
}
|
|
|
|
|
|
2018-02-01 13:45:05 -06:00
|
|
|
if [ $# -ne 2 ]; then
|
|
|
|
|
echo "Syntax: $0 data-dir build-dir" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
if [ -z "$PACKAGE_TARNAME" ]; then
|
|
|
|
|
echo "E: \$PACKAGE_TARNAME undefined"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
PWD=`pwd`
|
|
|
|
|
data="${PWD}/$1"
|
|
|
|
|
build="${PWD}/$2"
|
|
|
|
|
bundle_dir="$APPBUNDLE"
|
|
|
|
|
|
|
|
|
|
for d in "$data" "$build"; do
|
|
|
|
|
test -d "$d" && continue
|
|
|
|
|
echo "E: ${d}: not a directory" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
done
|
|
|
|
|
if ! test -w "$build"; then
|
|
|
|
|
echo "E: ${build} is not writeable" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
plist="${data}/mac/Info.plist.in"
|
|
|
|
|
fldigi_icon="${data}/mac/fldigi.icns"
|
|
|
|
|
flarq_icon="${data}/mac/flarq.icns"
|
|
|
|
|
for f in "$plist" "$fldigi_icon" "$flarq_icon"; do
|
|
|
|
|
test -r "$f" && continue
|
|
|
|
|
echo "E: ${f}: not readable" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
done
|
|
|
|
|
|
2009-05-26 19:57:44 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
if test "x$WANT_FLDIGI" = "xyes"; then
|
2018-02-01 13:45:05 -06:00
|
|
|
identifier="com.w1hkj.$PACKAGE_TARNAME"
|
|
|
|
|
name=$(echo "$PACKAGE_TARNAME" | upcase1)
|
|
|
|
|
# we'll use the first four consonants as the signature
|
|
|
|
|
signature="$(echo $PACKAGE_TARNAME | sed 's/[aeiouAEIOU]//g; s/\(^....\).*/\1/')"
|
|
|
|
|
binary="$PACKAGE_TARNAME"
|
|
|
|
|
icon="$fldigi_icon"
|
2020-02-10 06:52:54 -06:00
|
|
|
version="${FLDIGI_VERSION_MAJOR}.${FLDIGI_VERSION_MINOR}.${FLDIGI_VERSION_PATCH}"
|
2018-02-01 13:45:05 -06:00
|
|
|
appversion="$FLDIGI_VERSION"
|
|
|
|
|
|
|
|
|
|
bundle
|
2008-02-29 09:18:07 +00:00
|
|
|
fi
|
|
|
|
|
|
2009-05-26 19:57:44 +01:00
|
|
|
if test "x$WANT_FLARQ" = "xyes"; then
|
2018-02-01 13:45:05 -06:00
|
|
|
identifier="com.w1hkj.flarq"
|
|
|
|
|
name="Flarq"
|
|
|
|
|
signature="flrq"
|
|
|
|
|
binary="flarq"
|
|
|
|
|
icon="$flarq_icon"
|
2020-02-10 06:52:54 -06:00
|
|
|
version="${FLARQ_VERSION_MAJOR}.${FLARQ_VERSION_MINOR}.${FLARQ_VERSION_PATCH}"
|
2018-02-01 13:45:05 -06:00
|
|
|
appversion="$FLARQ_VERSION"
|
|
|
|
|
|
|
|
|
|
bundle
|
2009-05-26 19:57:44 +01:00
|
|
|
fi
|
2008-08-21 19:22:32 +01:00
|
|
|
|
|
|
|
|
cd "$build"
|
2018-02-01 13:45:05 -06:00
|
|
|
|
|
|
|
|
echo "creating disk image"
|
|
|
|
|
hdiutil create -ov -srcfolder "$bundle_dir" -format UDZO -tgtimagekey zlib-level=9 "${APPBUNDLE}.dmg"
|