2010-03-16 22:34:07 +00:00
|
|
|
#!/usr/bin/env bash
|
2009-11-02 06:21:50 +00:00
|
|
|
|
2010-02-27 00:10:30 +00:00
|
|
|
VERSION="1.2.0-SNAPSHOT"
|
2009-12-03 04:47:30 +00:00
|
|
|
|
2010-04-20 05:23:12 +00:00
|
|
|
CLASSPATH="$(ls -1 lib/dev/*jar 2> /dev/null | tr \\n \:)":$CLASSPATH
|
2009-11-28 01:50:28 +00:00
|
|
|
LEIN_JAR="$HOME/.m2/repository/leiningen/leiningen/$VERSION/leiningen-$VERSION-standalone.jar"
|
2010-04-17 02:55:28 +00:00
|
|
|
CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.2.0-master-SNAPSHOT/clojure-1.2.0-master-SNAPSHOT.jar"
|
2009-11-06 04:36:27 +00:00
|
|
|
|
2009-11-22 06:18:51 +00:00
|
|
|
# normalize $0 on certain BSDs
|
2009-11-22 05:08:38 +00:00
|
|
|
if [ "$(dirname $0)" = "." ]; then
|
|
|
|
SCRIPT="$(which $(basename $0))"
|
|
|
|
else
|
|
|
|
SCRIPT="$0"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# resolve symlinks to the script itself portably
|
|
|
|
while [ -h "$SCRIPT" ] ; do
|
|
|
|
ls=`ls -ld "$SCRIPT"`
|
|
|
|
link=`expr "$ls" : '.*-> \(.*\)$'`
|
|
|
|
if expr "$link" : '/.*' > /dev/null; then
|
|
|
|
SCRIPT="$link"
|
|
|
|
else
|
|
|
|
SCRIPT="`dirname "$SCRIPT"`/$link"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
BIN_DIR="$(dirname "$SCRIPT")"
|
2009-11-22 00:45:10 +00:00
|
|
|
|
2009-11-22 22:09:11 +00:00
|
|
|
if [ -r "$BIN_DIR/../src/leiningen/core.clj" ]; then
|
2009-11-22 05:08:38 +00:00
|
|
|
# Running from source checkout
|
|
|
|
LEIN_DIR="$(dirname "$BIN_DIR")"
|
2009-12-02 04:04:26 +00:00
|
|
|
LEIN_LIBS="$(find -H $LEIN_DIR/lib -mindepth 2> /dev/null 1 -maxdepth 1 -print0 | tr \\0 \:)"
|
2009-12-03 04:47:30 +00:00
|
|
|
CLASSPATH="$LEIN_DIR/src:$LEIN_LIBS:$CLASSPATH"
|
2009-11-22 00:45:10 +00:00
|
|
|
|
2009-11-28 04:27:11 +00:00
|
|
|
if [ "$LEIN_LIBS" = "" -a "$1" != "self-install" ]; then
|
|
|
|
echo "Your Leiningen development checkout is missing its dependencies."
|
|
|
|
echo "Please download a stable version of Leiningen to fetch the deps."
|
|
|
|
echo "See the \"Hacking\" section of the readme for details."
|
|
|
|
exit 1
|
2009-11-22 00:45:10 +00:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Not running from a checkout
|
2009-12-03 04:47:30 +00:00
|
|
|
CLASSPATH="$LEIN_JAR:$CLASSPATH"
|
2009-11-22 00:45:10 +00:00
|
|
|
|
2009-11-14 21:44:59 +00:00
|
|
|
if [ ! -r "$LEIN_JAR" -a "$1" != "self-install" ]; then
|
2009-11-12 05:24:48 +00:00
|
|
|
echo "Leiningen is not installed. Please run \"lein self-install\"."
|
|
|
|
exit 1
|
2009-11-10 06:22:09 +00:00
|
|
|
fi
|
2009-11-02 06:21:50 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-10 06:22:09 +00:00
|
|
|
if [ $DEBUG ]; then
|
|
|
|
echo $CLASSPATH
|
|
|
|
fi
|
|
|
|
|
2010-02-12 08:41:12 +00:00
|
|
|
HTTP_CLIENT="wget -O"
|
|
|
|
if type -p curl >/dev/null 2>&1; then
|
2010-02-17 05:58:41 +00:00
|
|
|
HTTP_CLIENT="curl -L -o"
|
2010-02-12 08:41:12 +00:00
|
|
|
fi
|
|
|
|
|
2010-04-17 04:46:53 +00:00
|
|
|
if [ "$1" = "self-install" ]; then
|
2009-12-11 04:18:22 +00:00
|
|
|
if [[ $VERSION == *SNAPSHOT ]]; then
|
|
|
|
echo "The self-install task is only meant for stable releases."
|
|
|
|
echo "See the \"Hacking\" section of the README."
|
|
|
|
exit 1
|
|
|
|
fi
|
2009-11-10 06:22:09 +00:00
|
|
|
echo "Downloading Leiningen now..."
|
2010-03-07 05:51:13 +00:00
|
|
|
LEIN_DIR=`dirname "$LEIN_JAR"`
|
|
|
|
mkdir -p "$LEIN_DIR"
|
2010-02-17 05:58:41 +00:00
|
|
|
LEIN_URL="http://github.com/downloads/technomancy/leiningen/leiningen-$VERSION-standalone.jar"
|
2010-02-12 08:41:12 +00:00
|
|
|
exec $HTTP_CLIENT "$LEIN_JAR" "$LEIN_URL"
|
|
|
|
elif [ "$1" = "upgrade" ]; then
|
|
|
|
if [[ $VERSION == *SNAPSHOT ]]; then
|
|
|
|
echo "The upgrade task is only meant for stable releases."
|
|
|
|
echo "See the \"Hacking\" section of the README."
|
|
|
|
exit 1
|
2009-11-10 06:22:09 +00:00
|
|
|
fi
|
2010-02-12 22:04:47 +00:00
|
|
|
if [ ! -w "$SCRIPT" ]; then
|
|
|
|
echo "You do not have permission to upgrade the installation in $SCRIPT"
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "The script at $SCRIPT will be upgraded to the latest stable version."
|
|
|
|
echo -n "Do you want to continue [Y/n]? "
|
|
|
|
read RESP
|
|
|
|
case "$RESP" in
|
|
|
|
y|Y|"")
|
|
|
|
echo
|
|
|
|
echo "Upgrading..."
|
|
|
|
LEIN_SCRIPT_URL="http://github.com/technomancy/leiningen/raw/stable/bin/lein"
|
|
|
|
$HTTP_CLIENT "$SCRIPT" "$LEIN_SCRIPT_URL" \
|
|
|
|
&& chmod +x "$SCRIPT" \
|
|
|
|
&& echo && $SCRIPT self-install && echo && echo "Now running" `$SCRIPT version`
|
|
|
|
exit $?;;
|
|
|
|
*)
|
|
|
|
echo "Aborted."
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
fi
|
2009-11-02 06:38:59 +00:00
|
|
|
else
|
2010-03-07 05:51:13 +00:00
|
|
|
if type -p cygpath >/dev/null 2>&1; then
|
|
|
|
# When running on Cygwin, use Windows-style paths for java
|
|
|
|
CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"`
|
|
|
|
CLASSPATH=`cygpath -wp "$CLASSPATH"`
|
|
|
|
fi
|
|
|
|
|
2010-04-17 04:46:53 +00:00
|
|
|
# if [ "$1" = "repl" ]; then
|
|
|
|
# # Use rlwrap if it's available, otherwise fall back to JLine
|
|
|
|
# RLWRAP=`which rlwrap`
|
|
|
|
# JLINE=jline.ConsoleRunner
|
|
|
|
# if [ $RLWRAP != "" ]; then
|
|
|
|
# JLINE=
|
|
|
|
# fi
|
|
|
|
# fi
|
|
|
|
|
2010-03-07 05:36:19 +00:00
|
|
|
# The -Xbootclasspath argument is optional here: if the jar
|
|
|
|
# doesn't exist everything will still work, it will just have a
|
|
|
|
# slower JVM boot.
|
2010-04-17 05:34:45 +00:00
|
|
|
exec $RLWRAP java -Xbootclasspath/a:"$CLOJURE_JAR" -client $JAVA_OPTS \
|
|
|
|
-cp "$CLASSPATH" -Dleiningen.version="$VERSION" $JLINE \
|
|
|
|
clojure.main -e "(use 'leiningen.core)(-main)" /dev/null $@
|
2009-11-02 06:38:59 +00:00
|
|
|
fi
|