#!/bin/bash -i
#
# this script setups up env to work on flumotion uninstalled

# this script is run -i so that PS1 doesn't get cleared

self=$0
absolute=$self
if test -L $absolute
then
  # find what the symlink points to
  absolute=`stat $absolute -c %N -t | sed 's/^.* -> .//g' | sed 's/.$//g'`
fi
MISCDIR=`dirname $absolute`
BASEDIR=`cd $MISCDIR/.. && pwd`
ONEUPDIR=`cd $BASEDIR/.. && pwd`

# extract project and version from $0
# if this script is called "...-head" then version will be "head"
PROJECT=`basename $self | sed s/-.*//g`
VERSION=`basename $self | sed s/.*-//g`

export PATH=$BASEDIR/bin${PATH:+:$PATH}
export PYTHONPATH=$BASEDIR${PYTHONPATH:+:$PYTHONPATH}
export PKG_CONFIG_PATH=$BASEDIR/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}

# if we got a command, run it, else start a shell
if test ! -z "$1";
then
  $@
  exit $?
fi

# set up prompt to help us remember we're in a subshell, cd to
# the flumotion dir and start $SHELL
cd $BASEDIR
PS1="[flu-$VERSION] $PS1" $SHELL
