File: lein-pkg

package info (click to toggle)
leiningen-clojure 2.11.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,124 kB
  • sloc: xml: 925; sh: 776; lisp: 46; makefile: 45; java: 16
file content (266 lines) | stat: -rw-r--r-- 7,709 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
#!/usr/bin/env bash

# This variant of the lein script is meant for downstream packagers.
# It has all the cross-platform stuff stripped out as well as the
# logic for running from a source checkout and self-install/upgrading.

export LEIN_VERSION="2.11.2"

if [[ "$CLASSPATH" != "" ]]; then
    cat <<-'EOS' 1>&2
	WARNING: You have $CLASSPATH set, probably by accident.
	It is strongly recommended to unset this before proceeding.
	EOS
fi

if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "msys" ]]; then
    delimiter=";"
else
    delimiter=":"
fi

if [[ "$OSTYPE" == "cygwin" ]]; then
  cygwin=true
else
  cygwin=false
fi

function msg {
    echo "$@" 1>&2
}

function command_not_found {
    msg "Leiningen couldn't find $1 in your \$PATH ($PATH), which is required."
    exit 1
}

function make_native_path {
    # ensure we have native paths
    if $cygwin && [[ "$1"  == /* ]]; then
    echo -n "$(cygpath -wp "$1")"
    elif [[ "$OSTYPE" == "msys" && "$1"  == /?/* ]]; then
    echo -n "$(sh -c "(cd $1 2</dev/null && pwd -W) || echo $1 | sed 's/^\\/\([a-z]\)/\\1:/g'")"
    else
    echo -n "$1"
    fi
}

#  usage : add_path PATH_VAR [PATH]...
function add_path {
    local path_var="$1"
    shift
    while [ -n "$1" ];do
        # http://bashify.com/?Useful_Techniques:Indirect_Variables:Indirect_Assignment
        if [[ -z ${!path_var} ]]; then
          export ${path_var}="$(make_native_path "$1")"
        else
          export ${path_var}="${!path_var}${delimiter}$(make_native_path "$1")"
        fi
    shift
    done
}

function run_from_checkout() {
    add_path CLASSPATH "$LEIN_JAR"

    if [ "$LEIN_USE_BOOTCLASSPATH" != "no" ]; then
        LEIN_JVM_OPTS="-Xbootclasspath/a:$LEIN_JAR $LEIN_JVM_OPTS"
    fi
}

function cmd_run {
    if $cygwin; then
        # When running on Cygwin, use Windows-style paths for java
        ORIGINAL_PWD=$(cygpath -w "$ORIGINAL_PWD")
    fi

    if [ "$DEB_DH_CLJ_LEIN_BUILD" = true ]; then
        # override supports dh-clojure build tests
        add_path CLASSPATH "${DEB_DH_CLJ_LEIN_OVERRIDE_JAR:-/usr/share/maven-repo/org/debian/dh-clojure-lein/debian/dh-clojure-lein-debian.jar}"
    fi

    # apply context specific CLASSPATH entries
    if [ -f .lein-classpath ]; then
        add_path CLASSPATH "$(cat .lein-classpath)"
    fi

    if [ -n "$DEBUG" ]; then
        msg "Leiningen's classpath: $CLASSPATH"
    fi

    if [ -r .lein-fast-trampoline ]; then
        export LEIN_FAST_TRAMPOLINE='y'
    fi

    if [ "$LEIN_FAST_TRAMPOLINE" != "" ] && [ -r project.clj ]; then
        INPUTS="$* $(cat project.clj) $LEIN_VERSION $(test -f "$LEIN_HOME/profiles.clj" && cat "$LEIN_HOME/profiles.clj") $(test -f profiles.clj && cat profiles.clj)"

        INPUT_CHECKSUM=$(echo "$INPUTS" | $SHASUM_CMD | cut -f 1 -d " ")
        # Just don't change :target-path in project.clj, mkay?
        TRAMPOLINE_FILE="target/trampolines/$INPUT_CHECKSUM"
    else
        if hash mktemp 2>/dev/null; then
            # Check if mktemp is available before using it
            TRAMPOLINE_FILE="$(mktemp -t lein-trampoline-XXXXXXXXXXXXX)"
        else
            TRAMPOLINE_FILE="/tmp/lein-trampoline-$$"
        fi
        trap 'rm -f $TRAMPOLINE_FILE' EXIT
    fi

    if $cygwin; then
        TRAMPOLINE_FILE=$(cygpath -w "$TRAMPOLINE_FILE")
    fi

    if [ "$INPUT_CHECKSUM" != "" ] && [ -r "$TRAMPOLINE_FILE" ]; then
        if [ -n "$DEBUG" ]; then
            msg "Fast trampoline with $TRAMPOLINE_FILE."
        fi
        exec sh -c "exec $(cat "$TRAMPOLINE_FILE")"
    else
        export TRAMPOLINE_FILE
        "$LEIN_JAVA_CMD" \
            -Dfile.encoding=UTF-8 \
            -Dmaven.wagon.http.ssl.easy=false \
            -Dmaven.wagon.rto=10000 \
            $LEIN_JVM_OPTS \
            -Dleiningen.input-checksum="$INPUT_CHECKSUM" \
            -Dleiningen.original.pwd="$ORIGINAL_PWD" \
            -Dleiningen.script="$SCRIPT" \
            -classpath "$CLASSPATH" \
            clojure.main -m leiningen.core.main "$@"

        EXIT_CODE=$?

        if $cygterm ; then
          stty icanon echo > /dev/null 2>&1
        fi

        if [ -r "$TRAMPOLINE_FILE" ] && [ "$LEIN_TRAMPOLINE_WARMUP" = "" ]; then
            TRAMPOLINE="$(cat "$TRAMPOLINE_FILE")"
            if [ "$INPUT_CHECKSUM" = "" ]; then # not using fast trampoline
                rm "$TRAMPOLINE_FILE"
            fi
            if [ "$TRAMPOLINE" = "" ]; then
                exit $EXIT_CODE
            else
                exec sh -c "exec $TRAMPOLINE"
            fi
        else
            exit $EXIT_CODE
        fi
    fi
}

# cd to the project root, if applicable
NOT_FOUND=1
ORIGINAL_PWD="$PWD"
while [ ! -r "$PWD/project.clj" ] && [ "$PWD" != "/" ] && [ $NOT_FOUND -ne 0 ]
do
    cd ..
    if [ "$(dirname "$PWD")" = "/" ]; then
        NOT_FOUND=0
        cd "$ORIGINAL_PWD"
    fi
done

# User init
export LEIN_HOME="${LEIN_HOME:-"$HOME/.lein"}"

for f in "/etc/leinrc" "$LEIN_HOME/leinrc" ".leinrc"; do
  if [ -e "$f" ]; then
    source "$f"
  fi
done

if $cygwin; then
    export LEIN_HOME=$(cygpath -w "$LEIN_HOME")
fi

# normalize $0 on certain BSDs
if [ "$(dirname "$0")" = "." ]; then
    SCRIPT="$(which "$(basename "$0")")"
    if [ -z "$SCRIPT" ]; then
        SCRIPT="$0"
    fi
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")"

# If you're not using an uberjar you'll need to list each dependency
# and add them individually to the classpath/bootclasspath as well.

LEIN_JAR=/usr/share/java/leiningen-$LEIN_VERSION.jar

export LEIN_JVM_OPTS="${LEIN_JVM_OPTS-"-XX:+TieredCompilation -XX:TieredStopAtLevel=1"}"

# This needs to be defined before we call SHASUM_CMD below
if [ "$SHASUM_CMD" = "" ]; then
    if type -p sha256sum >/dev/null 2>&1; then
        export SHASUM_CMD="sha256sum"
    elif type -p shasum >/dev/null 2>&1; then
        export SHASUM_CMD="shasum --algorithm 256"
    elif type -p sha256 >/dev/null 2>&1; then
        export SHASUM_CMD="sha256 -q"
    else
        command_not_found sha256sum
    fi
fi

# When :eval-in :classloader we need more memory
grep -E -q '^\s*:eval-in\s+:classloader\s*$' project.clj 2> /dev/null && \
    export LEIN_JVM_OPTS="$LEIN_JVM_OPTS -Xms64m -Xmx512m"

run_from_checkout "$1"

if [ ! -x "$JAVA_CMD" ] && ! type -f java >/dev/null
then
    msg "Leiningen couldn't find 'java' executable, which is required."
    msg "Please either set JAVA_CMD or put java (>=1.6) in your \$PATH ($PATH)."
    exit 1
fi

export LEIN_JAVA_CMD="${LEIN_JAVA_CMD:-${JAVA_CMD:-java}}"

if [[ -z "${DRIP_INIT+x}" && "$(basename "$LEIN_JAVA_CMD")" == *drip* ]]; then
    export DRIP_INIT="$(printf -- '-e\n(require (quote leiningen.repl))')"
    export DRIP_INIT_CLASS="clojure.main"
fi

# Support $JAVA_OPTS for backwards-compatibility.
export JVM_OPTS="${JVM_OPTS:-"$JAVA_OPTS"}"

# Handle jline issue with cygwin not propagating OSTYPE through java subprocesses: https://github.com/jline/jline2/issues/62
cygterm=false
if $cygwin; then
  case "$TERM" in
    rxvt* | xterm* | vt*) cygterm=true ;;
  esac
fi

if $cygterm; then
  LEIN_JVM_OPTS="$LEIN_JVM_OPTS -Djline.terminal=jline.UnixTerminal"
  stty -icanon min 1 -echo > /dev/null 2>&1
fi

if [ "$1" = "upgrade" ]; then
    echo "This version of Leiningen was installed with a package manager, but"
    echo "the upgrade task is intended for manual installs. Please use your"
    echo "package manager's built-in upgrade facilities instead."
    exit 1
fi

cmd_run "$@"