curator/scripts/build-macos-app.sh

56 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
echo 'Generating macos app bundle...'
realpath() {
path="$(ls "$PWD/$1")"
echo "$path"
}
# Change our working directory to the parent directory of this script
real_path="$(realpath "$0")"
parent_dir="$(dirname "$real_path")"
cd "$parent_dir"
if [ ! -e ../build/install/curator ]; then
echo "You must run 'gradle installDist' before this script!" 1>&2
exit 1
fi
# Delete old app
rm -rf ../build/macos/Curator.app
# Copy empty application
mkdir -p ../build/macos/Curator.app/Contents/MacOS/ ../build/macos/Curator.app/Contents/Resources/
# Copy Info.plist and icon
cp macos/Info.plist ../build/macos/Curator.app/Contents/Info.plist
cp macos/icon.icns ../build/macos/Curator.app/Contents/Resources/icon.icns
# Copy compiled app
cp -r ../build/install/curator ../build/macos/Curator.app/Contents/MacOS/
rm ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.bat
echo "Compiling start script..."
# Compile start script (required to make JFileChooser work)
shc -r -f ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator -o ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x
rm ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x.c
mv ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator.x ../build/macos/Curator.app/Contents/MacOS/curator/bin/curator
# Build install image (if we are on a mac)
echo 'Building intsall image...'
if which hdiutil >/dev/null 2>/dev/null; then
# Set up temp dir
rm -rf ../build/tmp/macos
mkdir -p ../build/tmp/macos
cp -r ../build/macos/Curator.app ../build/tmp/macos/
ln -s /Applications ../build/tmp/macos/Applications
# Create image
hdiutil create -ov -volname "Curator" -srcfolder ../build/tmp/macos ../build/macos/Curator.dmg >/dev/null
else
echo "hdiutil(1) not found! Can't build DMG image."
fi
echo "App bundle generated in 'build/macos'!"