2010-08-08 18:00:14 +00:00
|
|
|
#!/bin/sh
|
2009-11-02 06:21:50 +00:00
|
|
|
|
2011-07-16 21:50:16 +00:00
|
|
|
LEIN_VERSION="2.0.0-SNAPSHOT"
|
2011-01-22 18:06:24 +00:00
|
|
|
export LEIN_VERSION
|
2009-12-03 04:47:30 +00:00
|
|
|
|
2010-08-24 03:05:07 +00:00
|
|
|
case $LEIN_VERSION in
|
2010-08-08 18:00:14 +00:00
|
|
|
*SNAPSHOT) SNAPSHOT="YES" ;;
|
|
|
|
*) SNAPSHOT="NO" ;;
|
|
|
|
esac
|
|
|
|
|
2010-07-23 16:12:39 +00:00
|
|
|
# Make sure classpath is in unix format for manipulating, then put
|
|
|
|
# it back to windows format when we use it
|
2010-10-25 21:14:06 +00:00
|
|
|
if [ "$OSTYPE" = "cygwin" ] && [ "$CLASSPATH" != "" ]; then
|
2010-07-23 16:12:39 +00:00
|
|
|
CLASSPATH=`cygpath -up $CLASSPATH`
|
|
|
|
fi
|
|
|
|
|
2011-04-12 03:21:45 +00:00
|
|
|
if [ `whoami` = "root" ] && [ "$LEIN_ROOT" = "" ]; then
|
2010-07-30 20:28:45 +00:00
|
|
|
echo "WARNING: You're currently running as root; probably by accident."
|
|
|
|
echo "Press control-C to abort or Enter to continue as root."
|
|
|
|
echo "Set LEIN_ROOT to disable this warning."
|
2011-03-25 04:14:54 +00:00
|
|
|
read _
|
2010-07-30 20:28:45 +00:00
|
|
|
fi
|
|
|
|
|
2011-04-13 16:40:10 +00:00
|
|
|
NOT_FOUND=1
|
2010-08-27 02:50:04 +00:00
|
|
|
ORIGINAL_PWD="$PWD"
|
2011-05-25 04:35:40 +00:00
|
|
|
while [ ! -r "$PWD/project.clj" ] && [ "$PWD" != "/" ] && [ $NOT_FOUND -ne 0 ]
|
2010-08-12 01:22:25 +00:00
|
|
|
do
|
|
|
|
cd ..
|
2010-08-16 20:14:15 +00:00
|
|
|
if [ "$(dirname "$PWD")" = "/" ]; then
|
2010-08-12 01:22:25 +00:00
|
|
|
NOT_FOUND=0
|
|
|
|
cd "$ORIGINAL_PWD"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2010-08-08 20:33:04 +00:00
|
|
|
if [ "$LEIN_HOME" = "" ]; then
|
2011-11-11 22:55:17 +00:00
|
|
|
if [ -d "$PWD/.lein" ] && [ "$PWD" != "$HOME" ]; then
|
2011-11-08 23:48:54 +00:00
|
|
|
echo "Leiningen is running in bundled mode."
|
2011-11-11 22:55:17 +00:00
|
|
|
LEIN_HOME="$PWD/.lein"
|
2011-11-08 19:24:40 +00:00
|
|
|
else
|
2010-08-08 20:33:04 +00:00
|
|
|
LEIN_HOME="$HOME/.lein"
|
2011-11-08 19:24:40 +00:00
|
|
|
fi
|
2010-08-08 20:33:04 +00:00
|
|
|
fi
|
|
|
|
|
2011-08-18 23:05:18 +00:00
|
|
|
LEIN_JAR="$LEIN_HOME/self-installs/leiningen-$LEIN_VERSION-standalone.jar"
|
2011-11-20 05:07:34 +00:00
|
|
|
CLOJURE_JAR="$HOME/.m2/repository/org/clojure/clojure/1.3.0/clojure-1.3.0.jar"
|
2009-11-06 04:36:27 +00:00
|
|
|
|
2011-06-30 22:09:17 +00:00
|
|
|
# apply context specific CLASSPATH entries
|
2012-02-08 01:00:10 +00:00
|
|
|
if [ -f .lein-classpath ] && [ ! -f src/leiningen/version.clj ]; then
|
2011-07-21 17:38:52 +00:00
|
|
|
CLASSPATH="`cat .lein-classpath`:$CLASSPATH"
|
2011-06-30 22:09:17 +00:00
|
|
|
fi
|
|
|
|
|
2009-11-22 06:18:51 +00:00
|
|
|
# normalize $0 on certain BSDs
|
2010-07-26 08:37:32 +00:00
|
|
|
if [ "$(dirname "$0")" = "." ]; then
|
|
|
|
SCRIPT="$(which $(basename "$0"))"
|
2009-11-22 05:08:38 +00:00
|
|
|
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
|
2010-12-03 02:17:36 +00:00
|
|
|
SCRIPT="$(dirname "$SCRIPT"$)/$link"
|
2009-11-22 05:08:38 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
BIN_DIR="$(dirname "$SCRIPT")"
|
2009-11-22 00:45:10 +00:00
|
|
|
|
2012-01-17 22:57:24 +00:00
|
|
|
if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
|
2009-11-22 05:08:38 +00:00
|
|
|
# Running from source checkout
|
|
|
|
LEIN_DIR="$(dirname "$BIN_DIR")"
|
2009-11-22 00:45:10 +00:00
|
|
|
|
2012-01-17 23:11:20 +00:00
|
|
|
if [ "$(ls $LEIN_DIR/leiningen-core/lib/*)" = "" ]; then
|
|
|
|
echo "Leiningen is missing its dependencies."
|
|
|
|
echo "Please see \"Building\" in the README."
|
2009-11-28 04:27:11 +00:00
|
|
|
exit 1
|
2009-11-22 00:45:10 +00:00
|
|
|
fi
|
2012-01-24 03:17:14 +00:00
|
|
|
|
|
|
|
# Use bin/lein to calculate its own classpath
|
|
|
|
if [ ! -r "$LEIN_DIR/.lein-classpath" ]; then
|
|
|
|
ORIG_PWD="$PWD"
|
|
|
|
cd "$LEIN_DIR"
|
|
|
|
"$0" classpath > "$LEIN_DIR/.lein-classpath"
|
|
|
|
cd "$ORIG_PWD"
|
|
|
|
fi
|
|
|
|
|
|
|
|
CLASSPATH="$CLASSPATH:$LEIN_DIR/leiningen-core/src/"
|
2012-02-08 01:00:10 +00:00
|
|
|
CLASSPATH="$CLASSPATH:`cat $LEIN_DIR/.lein-classpath`"
|
2012-01-24 03:17:14 +00:00
|
|
|
CLASSPATH="$CLASSPATH::$LEIN_DIR/lib/*:$LEIN_DIR/leiningen-core/lib/*"
|
2012-02-08 01:00:10 +00:00
|
|
|
CLASSPATH="$CLASSPATH:$LEIN_DIR/test:$LEIN_DIR/src:$LEIN_DIR/resources:$LEIN_JAR"
|
2009-11-22 00:45:10 +00:00
|
|
|
else
|
|
|
|
# Not running from a checkout
|
2011-01-14 17:02:01 +00:00
|
|
|
CLASSPATH="$CLASSPATH:$LEIN_JAR"
|
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
|
2010-09-03 03:16:54 +00:00
|
|
|
"$0" self-install
|
2009-11-10 06:22:09 +00:00
|
|
|
fi
|
2009-11-02 06:21:50 +00:00
|
|
|
fi
|
|
|
|
|
2010-11-04 16:12:23 +00:00
|
|
|
HTTP_CLIENT="wget --no-check-certificate -O"
|
2010-02-12 08:41:12 +00:00
|
|
|
if type -p curl >/dev/null 2>&1; then
|
2011-04-13 14:37:30 +00:00
|
|
|
if [ "$https_proxy" != "" ]; then
|
2011-04-10 22:08:37 +00:00
|
|
|
CURL_PROXY="-x $https_proxy"
|
|
|
|
fi
|
|
|
|
HTTP_CLIENT="curl $CURL_PROXY --insecure -f -L -o"
|
2010-02-12 08:41:12 +00:00
|
|
|
fi
|
|
|
|
|
2011-06-20 02:28:16 +00:00
|
|
|
export JAVA_CMD=${JAVA_CMD:-"java"}
|
2010-05-23 00:28:39 +00:00
|
|
|
|
2010-12-25 04:14:25 +00:00
|
|
|
# Support $JAVA_OPTS for backwards-compatibility.
|
2011-06-28 16:51:19 +00:00
|
|
|
export JVM_OPTS=${JVM_OPTS:-"$JAVA_OPTS"}
|
2010-12-25 04:14:25 +00:00
|
|
|
|
2011-06-24 05:49:00 +00:00
|
|
|
# TODO: investigate http://skife.org/java/unix/2011/06/20/really_executable_jars.html
|
2010-07-21 04:49:34 +00:00
|
|
|
# If you're packaging this for a package manager (.deb, homebrew, etc)
|
|
|
|
# you need to remove the self-install and upgrade functionality.
|
2010-04-17 04:46:53 +00:00
|
|
|
if [ "$1" = "self-install" ]; then
|
2011-10-19 23:30:56 +00:00
|
|
|
if [ -r "$LEIN_JAR" ]; then
|
|
|
|
echo "The self-install jar already exists at $LEIN_JAR."
|
|
|
|
echo "If you wish to re-download, delete it and rerun \"$0 self-install\"."
|
|
|
|
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-12-03 02:16:16 +00:00
|
|
|
LEIN_URL="https://github.com/downloads/technomancy/leiningen/leiningen-$LEIN_VERSION-standalone.jar"
|
2010-07-29 04:30:16 +00:00
|
|
|
$HTTP_CLIENT "$LEIN_JAR" "$LEIN_URL"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "Failed to download $LEIN_URL"
|
2010-08-08 18:00:14 +00:00
|
|
|
if [ $SNAPSHOT = "YES" ]; then
|
2011-03-04 02:55:36 +00:00
|
|
|
echo "If you have Maven installed, you can do"
|
|
|
|
echo "mvn dependency:copy-dependencies; mv target/dependency lib"
|
|
|
|
echo "See README.md for further SNAPSHOT build instructions."
|
2010-07-29 04:30:16 +00:00
|
|
|
fi
|
2010-09-22 03:16:29 +00:00
|
|
|
rm $LEIN_JAR 2> /dev/null
|
2010-07-29 04:30:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2010-02-12 08:41:12 +00:00
|
|
|
elif [ "$1" = "upgrade" ]; then
|
2011-06-24 03:22:06 +00:00
|
|
|
if [ "$LEIN_DIR" != "" ]; then
|
|
|
|
echo "The upgrade task is not meant to be run from a checkout."
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-08-08 18:00:14 +00:00
|
|
|
if [ $SNAPSHOT = "YES" ]; then
|
2010-02-12 08:41:12 +00:00
|
|
|
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..."
|
2011-03-04 02:55:36 +00:00
|
|
|
TARGET="/tmp/lein-$$-upgrade"
|
2010-12-03 02:16:16 +00:00
|
|
|
LEIN_SCRIPT_URL="https://github.com/technomancy/leiningen/raw/stable/bin/lein"
|
2011-03-04 02:55:36 +00:00
|
|
|
$HTTP_CLIENT "$TARGET" "$LEIN_SCRIPT_URL" \
|
|
|
|
&& mv "$TARGET" "$SCRIPT" \
|
2010-02-12 22:04:47 +00:00
|
|
|
&& chmod +x "$SCRIPT" \
|
2011-11-01 21:52:23 +00:00
|
|
|
&& echo && "$SCRIPT" self-install && echo && echo "Now running" `$SCRIPT version`
|
2010-02-12 22:04:47 +00:00
|
|
|
exit $?;;
|
|
|
|
*)
|
|
|
|
echo "Aborted."
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
fi
|
2009-11-02 06:38:59 +00:00
|
|
|
else
|
2010-07-26 08:37:32 +00:00
|
|
|
if [ "$OSTYPE" = "cygwin" ]; then
|
2010-03-07 05:51:13 +00:00
|
|
|
# When running on Cygwin, use Windows-style paths for java
|
|
|
|
CLOJURE_JAR=`cygpath -w "$CLOJURE_JAR"`
|
2010-11-19 17:48:02 +00:00
|
|
|
ORIGINAL_PWD=`cygpath -w "$ORIGINAL_PWD"`
|
2010-03-07 05:51:13 +00:00
|
|
|
CLASSPATH=`cygpath -wp "$CLASSPATH"`
|
2010-07-23 16:12:39 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ $DEBUG ]; then
|
|
|
|
echo $CLASSPATH
|
|
|
|
echo $CLOJURE_JAR
|
2010-03-07 05:51:13 +00:00
|
|
|
fi
|
|
|
|
|
2010-11-10 22:06:30 +00:00
|
|
|
JLINE=""
|
2010-07-31 04:23:50 +00:00
|
|
|
if ([ "$1" = "repl" ] || [ "$1" = "interactive" ] || [ "$1" = "int" ]) &&
|
2010-08-20 03:54:50 +00:00
|
|
|
[ -z $INSIDE_EMACS ] && [ "$TERM" != "dumb" ]; then
|
2010-06-22 02:21:22 +00:00
|
|
|
# Use rlwrap if it's available, otherwise fall back to JLine
|
|
|
|
RLWRAP=`which rlwrap`
|
2010-11-26 22:41:11 +00:00
|
|
|
if [ ! -x "$RLWRAP" ] || [ "$RLWRAP" = "" ]; then
|
2011-02-24 05:17:25 +00:00
|
|
|
if [ ! -r "$LEIN_HOME/.jline-warn" ]; then
|
|
|
|
echo "Using JLine for console I/O; install rlwrap for optimum experience."
|
|
|
|
touch "$LEIN_HOME/.jline-warn"
|
|
|
|
fi
|
2010-11-19 04:32:22 +00:00
|
|
|
RLWRAP=""
|
2010-06-22 02:21:22 +00:00
|
|
|
JLINE=jline.ConsoleRunner
|
2010-08-06 23:53:02 +00:00
|
|
|
if [ "$OSTYPE" = "cygwin" ]; then
|
2010-11-19 17:49:55 +00:00
|
|
|
JLINE="-Djline.terminal=jline.UnixTerminal jline.ConsoleRunner"
|
|
|
|
CYGWIN_JLINE=y
|
2010-08-06 23:53:02 +00:00
|
|
|
fi
|
2011-04-12 20:32:46 +00:00
|
|
|
else
|
2011-04-14 01:15:22 +00:00
|
|
|
# Test to see if rlwrap supports custom quote chars
|
|
|
|
rlwrap -m -q '"' echo "hi" > /dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
2011-10-24 16:43:25 +00:00
|
|
|
RLWRAP="$RLWRAP -r -m -q '\"'"
|
2011-04-14 01:15:22 +00:00
|
|
|
fi
|
2010-06-22 02:21:22 +00:00
|
|
|
fi
|
|
|
|
fi
|
2010-04-17 04:46:53 +00:00
|
|
|
|
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-08-06 23:53:02 +00:00
|
|
|
test $CYGWIN_JLINE && stty -icanon min 1 -echo
|
2011-06-20 02:28:16 +00:00
|
|
|
if [ "$1" = "trampoline" ]; then
|
2011-06-23 03:42:44 +00:00
|
|
|
TRAMPOLINE_FILE="/tmp/lein-trampoline-$$"
|
2011-07-10 07:17:54 +00:00
|
|
|
if [ "$OSTYPE" = "cygwin" ]; then
|
|
|
|
TRAMPOLINE_FILE=`cygpath -w $TRAMPOLINE_FILE`
|
|
|
|
fi
|
2011-07-22 03:04:09 +00:00
|
|
|
$JAVA_CMD -Xbootclasspath/a:"$CLOJURE_JAR" -client \
|
|
|
|
$LEIN_JVM_OPTS -Dleiningen.original.pwd="$ORIGINAL_PWD" \
|
2011-06-23 03:42:44 +00:00
|
|
|
-Dleiningen.trampoline-file=$TRAMPOLINE_FILE -cp "$CLASSPATH" \
|
2012-01-16 04:20:02 +00:00
|
|
|
$JLINE clojure.main -m leiningen.core.main "$@"
|
2011-06-23 03:42:44 +00:00
|
|
|
if [ -r $TRAMPOLINE_FILE ]; then
|
2011-06-28 02:02:50 +00:00
|
|
|
TRAMPOLINE="$(cat $TRAMPOLINE_FILE)"
|
|
|
|
rm $TRAMPOLINE_FILE
|
2011-07-10 07:17:54 +00:00
|
|
|
exec sh -c "exec $TRAMPOLINE"
|
2011-06-20 02:28:16 +00:00
|
|
|
fi
|
|
|
|
else
|
2011-12-03 04:53:04 +00:00
|
|
|
# Until the fix comes in for classlojure.
|
|
|
|
# -Xbootclasspath/a:"$CLOJURE_JAR"
|
2012-01-17 22:55:24 +00:00
|
|
|
exec $RLWRAP $JAVA_CMD -client -XX:+TieredCompilation \
|
2011-11-20 05:07:34 +00:00
|
|
|
$LEIN_JVM_OPTS -Dleiningen.original.pwd="$ORIGINAL_PWD" \
|
2012-01-16 04:20:02 +00:00
|
|
|
-cp "$CLASSPATH" $JLINE clojure.main -m leiningen.core.main "$@"
|
2011-06-20 02:28:16 +00:00
|
|
|
fi
|
2011-07-10 07:17:54 +00:00
|
|
|
test $CYGWIN_JLINE && stty icanon echo
|
2009-11-02 06:38:59 +00:00
|
|
|
fi
|