#!/bin/sh # Copyright (c) Sean Seefried 2005 - http://www.cse.unsw.edu.au/~sseefried/ # # Installs Panic on Mac OS X # # The way I check for whether it has been built or not completely violates # the DRY (Don't Repeat Yourself) principle but at this early stage it's # all I can think off. # # # Assumes (and checks that) macosx-app and install-sh are in the same # directory # this_path="`pwd`/$0" this_dir=`dirname $this_path` panic_dir=$this_dir/.. source $this_dir/../configure.lib # # These constants you may wish to change later (if Cabal changes) # PANIC=Panic PANIC_CABAL=$panic_dir/Panic.cabal MACOSX_APP=$this_dir/macosx-app INSTALL_SH=$this_dir/install-sh SETUP_CONFIG=$panic_dir/dist/setup-config ICON=$this_dir/Panic.icns if test ! \( -x $MACOSX_APP -a -x $INSTALL_SH \); then echo "ERROR: macosx-app and install-sh must be present in directory" echo " \``pwd`'" echo " for `basename $0` to run" exit 1 fi if test $# -ne 1; then echo "Usage: `basename $0` " exit 1 fi if test ! -f $SETUP_CONFIG; then echo "dist/setup-config not found. Run \`runhaskell Setup.hs configure' first" exit 1 fi build_dir=`get_config_value buildDir $SETUP_CONFIG` # # The directory the binary is contained in # PROJECT=`get_cabal_value executable $PANIC_CABAL` bin_dir=$panic_dir/$build_dir/$PROJECT/ PANIC_BIN=$bin_dir/$PANIC # # Next we must check that the binary has been built # echo "$PANIC_BIN" if test ! -f "$PANIC_BIN"; then echo "$PANIC has not been built yet. Run \`runhaskell Setup.hs build' first" exit 1 fi if test -e "$1/$PANIC_BIN"; then echo "File $1/$PANIC_BIN already exists" exit 1 fi echo Installing $PANIC.app in $1/$PANIC.app $INSTALL_SH -d $1 $INSTALL_SH -c $PANIC_BIN $1 (cd $1 && $MACOSX_APP --icon=$ICON $PANIC ) # Create the .app rm $1/$PANIC # Remove the original file