Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- APP_ROOT="$(dirname "$0")"
- for ((i=0; i<2; i++)); do APP_ROOT="$(dirname "$APP_ROOT")"; done
- APP_ROOT="${APP_ROOT/\/\/}"
- # Bundle directories
- CONTENTS_DIR="$APP_ROOT/Contents"
- RES_DIR="$CONTENTS_DIR/Resources"
- ETC_DIR="$RES_DIR/etc"
- LIB_DIR="$RES_DIR/lib"
- BIN_DIR="$RES_DIR/bin"
- DATA_DIR="$RES_DIR/share"
- # Shell environment
- export PATH="/bin:/usr/bin:$BIN_DIR"
- export BUNDLE_BIN_DIR="$BIN_DIR"
- export BUNDLE_LIB_DIR="$LIB_DIR"
- # XDG environment
- export XDG_CONFIG_DIRS="$ETC_DIR/xdg"
- export XDG_DATA_DIRS="$DATA_DIR"
- export XDG_CONFIG_HOME="$HOME/.config"
- # GTK environment
- export GTK_PATH="$RES_DIR"
- export GTK_EXE_PREFIX="$RES_DIR"
- export GTK_DATA_PREFIX="$RES_DIR"
- export GTK2_RC_FILES="$ETC_DIR/gtk-2.0/gtkrc"
- export GTK_IM_MODULE_FILE="$ETC_DIR/gtk-2.0/gtk.immodules"
- export GDK_PIXBUF_MODULE_FILE="$ETC_DIR/gtk-2.0/gdk-pixbuf.loaders"
- export PANGO_RC_FILE="$ETC_DIR/pango/pangorc"
- # Banshee/Mono/GStreamer environment
- export MONO_FRAMEWORK_PATH="$LIB_DIR"
- export DYLD_FALLBACK_LIBRARY_PATH="/usr/lib:/usr/local/lib:$LIB_DIR:$LIB_DIR/banshee:$LIB_DIR/banshee/Extensions"
- export GST_PLUGIN_SYSTEM_PATH="$LIB_DIR/gstreamer-0.10"
- export BANSHEE_CONFIG_DIR="$XDG_CONFIG_HOME/banshee-1"
- BANSHEE_OPTIONS=""
- BANSHEE_EXEC_NAME=Banshee
- MONO_BIN="$BIN_DIR/mono"
- MONO_EXE="$LIB_DIR/banshee/Nereid.exe"
- MONO_OPTIONS=""
- # We are testing the SGen compacting GC
- export MONO_ENV_OPTIONS="--gc=sgen"
- for arg in $*; do
- if [ "$arg" = --debug ]; then
- MONO_OPTIONS="$MONO_OPTIONS --debug"
- BANSHEE_OPTIONS="$BANSHEE_OPTIONS --debug"
- fi
- done
- # FIXME
- # pango.modules sucks - it doesn't like paths with spaces,
- # so even though everything else works fine, we still
- # will explode, so instead I'm just showing this lame dialog.
- if [[ "$APP_ROOT" =~ [[:space:]] ]]; then
- osascript &>/dev/null <<EOF
- tell application "System Events"
- activate
- display dialog "A space was detected in the path to Banshee. Currently this is unsupported.\n\nRename or move Banshee.app to a path without spaces.\n\nPath: $APP_ROOT" with title "Error" with icon caution buttons { "OK" } default button 1
- end tell
- EOF
- exit 1
- fi
- mkdir -p "$BANSHEE_CONFIG_DIR"
- if [ -f "$RES_DIR/first-run" ]; then
- echo "Appears to be first run of this application bundle."
- rm -f -- "$RES_DIR/first-run"
- PREVIOUS_APP_ROOT=""
- else
- PREVIOUS_APP_ROOT="$(cat "$BANSHEE_CONFIG_DIR/app-bundle-location" 2>/dev/null)"
- fi
- if [ ! "$APP_ROOT" = "$PREVIOUS_APP_ROOT" ]; then
- echo "Application bundle has moved. Adjusting bundle..."
- # Mono Addins doesn't like being relocated - its cache contains
- # references to the previous location of this bundle
- find "$BANSHEE_CONFIG_DIR" -name addin-db-\* \
- -exec rm -rf -- {} \; &>/dev/null
- # Adjust config files that need absolute paths to things
- # in the bundle (e.g. pango, GDK pixbuf loaders...)
- # TODO This only supports moving the bundle once;
- # after that, there will be no ${APP_RESOURCES} to change to the value of ${RES_DIR}
- IFS=$'\n'
- for file in $(find "$ETC_DIR" | grep -E '.in$|.loaders$|.modules$|.immodules$'); do
- echo "adjusting paths in $file";
- sed -i -E "s|\${APP_RESOURCES}|${RES_DIR}|g" ${file};
- sed -i -E "s|\${RES_DIR}|${RES_DIR}|g" ${file};
- done
- unset IFS
- # Store the new location of the bundle
- echo "$APP_ROOT" > "$BANSHEE_CONFIG_DIR/app-bundle-location"
- fi
- # set and handle debug parameters
- [ -n "$BANSHEE_DEBUG" -o -f "${BANSHEE_CONFIG_DIR}/always-debug" ] && BANSHEE_DEBUG="--debug"
- [ -n "$BANSHEE_TRACE" ] && BANSHEE_TRACE="--trace=$BANSHEE_TRACE"
- [ -n "$BANSHEE_PROFILE" ] && BANSHEE_PROFILE="--profile=$BANSHEE_PROFILE"
- for arg in $*; do
- case "x--debug" in ("x$arg")
- BANSHEE_DEBUG=$arg
- esac
- case "x--trace=" in ("x${arg:0:8}")
- BANSHEE_TRACE=$arg
- esac
- case "x--profile=" in ("x${arg:0:10}")
- BANSHEE_PROFILE=$arg
- esac
- case "x--redirect-log" in ("x$arg")
- # OS X has no "pidof" so get its execution name
- BANSHEE_PID=`ps wwax | egrep -i "[B]anshee" | awk '{ print $1 }'`;
- [ -z "$BANSHEE_PID" ] && BANSHEE_REDIRECT_LOG="${BANSHEE_CONFIG_DIR}/log"
- esac
- case "x--client=" in ("x${arg:0:9}")
- BANSHEE_CLIENT="${arg:9}"
- esac
- done
- if [ ! -z "$BANSHEE_CLIENT" ]; then
- BANSHEE_CLIENT="--client=${BANSHEE_CLIENT}"
- fi
- if [ -n "$BANSHEE_DEBUG" -o -n "$BANSHEE_TRACE" -o -n "$BANSHEE_PROFILE" ]; then
- MONO_OPTIONS="$BANSHEE_DEBUG $BANSHEE_TRACE $BANSHEE_PROFILE"
- echo "** Running Mono with $MONO_OPTIONS **"
- fi
- # Finally - environment is set up, time to run our beloved
- exec_args="-a $BANSHEE_EXEC_NAME $MONO_BIN $MONO_OPTIONS $MONO_EXE $BANSHEE_DEBUG $BANSHEE_CLIENT $BANSHEE_OPTIONS"
- if [ -z "$BANSHEE_REDIRECT_LOG" ]; then
- exec $exec_args "$@"
- else
- mkdir -p `dirname "$BANSHEE_REDIRECT_LOG"`
- (echo "exec $exec_args " "$@"; echo; exec $exec_args "$@") &> $BANSHEE_REDIRECT_LOG
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement