#!/bin/bash

# This script creates a MacOSX launcher for birch. 
#
# Apple fights tooth and nail to make all paths fully-qualified, which of course
# makes .app files totally non-portable to other systems. What do they teach
# students in Comp Sci, anyway?
#
# These files must be in the PWD
# Input:
ICONFILE=birchIcon.icns 
SCRIPT=birch
# We need the -G -l option to force platypus to tell the app to read the user's environment
# variables eg. $BIRCH etc. Otherwise BIRCH can't find its files.

platypus -a birch -o 'Text Window' -i $ICONFILE -p /bin/bash -G -l --symlink $SCRIPT birch.app

# Output:
# This script will create a directory called birch.app. 
# birch.app/Contents/Resources/script will be a symbolic link to $BIRCH/script/birch. 
# platypus will create this as a fully qualified path, so we need to delete the link and
# create a new link with a relative path:

cd birch.app/Contents/Resources
rm script
ln -s ../../../../../script/birch script

# During installation or update, install-scripts/createlauncher.py and linklauncher.py
# will make a symbolic link in the user's Desktop directory
# called birch, that points to birch.app.
