|
| 1 | +#!/bin/bash |
| 2 | +# install julia vX.Y.Z: ./install-julia.sh X.Y.Z |
| 3 | +# install julia nightly: ./install-julia.sh nightly |
| 4 | + |
| 5 | +# LICENSE |
| 6 | +# |
| 7 | +# Copyright © 2013 by Steven G. Johnson, Fernando Perez, Jeff |
| 8 | +# Bezanson, Stefan Karpinski, Keno Fischer, Jake Bolewski, Takafumi |
| 9 | +# Arakaki, and other contributors. |
| 10 | +# |
| 11 | +# Permission is hereby granted, free of charge, to any person obtaining |
| 12 | +# a copy of this software and associated documentation files (the |
| 13 | +# "Software"), to deal in the Software without restriction, including |
| 14 | +# without limitation the rights to use, copy, modify, merge, publish, |
| 15 | +# distribute, sublicense, and/or sell copies of the Software, and to |
| 16 | +# permit persons to whom the Software is furnished to do so, subject to |
| 17 | +# the following conditions: |
| 18 | +# |
| 19 | +# The above copyright notice and this permission notice shall be |
| 20 | +# included in all copies or substantial portions of the Software. |
| 21 | +# |
| 22 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 23 | +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 24 | +# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 25 | +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 26 | +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 27 | +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 28 | +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 29 | + |
| 30 | +# stop on error |
| 31 | +set -e |
| 32 | +VERSION="$1" |
| 33 | + |
| 34 | +case "$VERSION" in |
| 35 | + nightly) |
| 36 | + BASEURL="https://julialangnightlies-s3.julialang.org/bin" |
| 37 | + JULIANAME="julia-latest" |
| 38 | + ;; |
| 39 | + [0-9]*.[0-9]*.[0-9]*) |
| 40 | + BASEURL="https://julialang-s3.julialang.org/bin" |
| 41 | + SHORTVERSION="$(echo "$VERSION" | grep -Eo '^[0-9]+\.[0-9]+')" |
| 42 | + JULIANAME="$SHORTVERSION/julia-$VERSION" |
| 43 | + ;; |
| 44 | + [0-9]*.[0-9]) |
| 45 | + BASEURL="https://julialang-s3.julialang.org/bin" |
| 46 | + SHORTVERSION="$(echo "$VERSION" | grep -Eo '^[0-9]+\.[0-9]+')" |
| 47 | + JULIANAME="$SHORTVERSION/julia-$VERSION-latest" |
| 48 | + ;; |
| 49 | + *) |
| 50 | + echo "Unrecognized VERSION=$VERSION, exiting" |
| 51 | + exit 1 |
| 52 | + ;; |
| 53 | +esac |
| 54 | + |
| 55 | +case $(uname) in |
| 56 | + Linux) |
| 57 | + case $(uname -m) in |
| 58 | + x86_64) |
| 59 | + ARCH="x64" |
| 60 | + case "$JULIANAME" in |
| 61 | + julia-latest) |
| 62 | + SUFFIX="linux64" |
| 63 | + ;; |
| 64 | + *) |
| 65 | + SUFFIX="linux-x86_64" |
| 66 | + ;; |
| 67 | + esac |
| 68 | + ;; |
| 69 | + i386 | i486 | i586 | i686) |
| 70 | + ARCH="x86" |
| 71 | + case "$JULIANAME" in |
| 72 | + julia-latest) |
| 73 | + SUFFIX="linux32" |
| 74 | + ;; |
| 75 | + *) |
| 76 | + SUFFIX="linux-i686" |
| 77 | + ;; |
| 78 | + esac |
| 79 | + ;; |
| 80 | + *) |
| 81 | + echo "Do not have Julia binaries for this architecture, exiting" |
| 82 | + exit 1 |
| 83 | + ;; |
| 84 | + esac |
| 85 | + echo "$BASEURL/linux/$ARCH/$JULIANAME-$SUFFIX.tar.gz" |
| 86 | + curl -L "$BASEURL/linux/$ARCH/$JULIANAME-$SUFFIX.tar.gz" | tar -xz |
| 87 | + sudo ln -s $PWD/julia-*/bin/julia /usr/local/bin/julia |
| 88 | + julia -e 'import Pkg; Pkg.add("PyCall");' |
| 89 | + julia -e 'import Pkg; Pkg.Registry.update(); Pkg.add("PandaModels"); Pkg.build(); Pkg.resolve();' |
| 90 | + ;; |
| 91 | + Darwin) |
| 92 | + if [ -e /usr/local/bin/julia ]; then |
| 93 | + echo "/usr/local/bin/julia already exists, exiting" |
| 94 | + exit 1 |
| 95 | + elif [ -e julia.dmg ]; then |
| 96 | + echo "julia.dmg already exists, exiting" |
| 97 | + exit 1 |
| 98 | + elif [ -e ~/julia ]; then |
| 99 | + echo "~/julia already exists, exiting" |
| 100 | + exit 1 |
| 101 | + fi |
| 102 | + curl -Lo julia.dmg "$BASEURL/mac/x64/$JULIANAME-mac64.dmg" |
| 103 | + hdiutil mount -mountpoint /Volumes/Julia julia.dmg |
| 104 | + cp -Ra /Volumes/Julia/*.app/Contents/Resources/julia ~ |
| 105 | + ln -s ~/julia/bin/julia /usr/local/bin/julia |
| 106 | + # TODO: clean up after self? |
| 107 | + ;; |
| 108 | + *) |
| 109 | + echo "Do not have Julia binaries for this platform, exiting" |
| 110 | + exit 1 |
| 111 | + ;; |
| 112 | +esac |
| 113 | + |
0 commit comments