Created
September 22, 2020 19:40
-
-
Save staticfloat/d2330d035271ffc99afb861aa2bd407d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| OS=$(uname) | |
| ARCH="$(uname -m)" | |
| get_julia_url() { | |
| local VERSION=${1} | |
| local MAJMIN="${VERSION%.*}" | |
| if [[ "$OS" == "Linux" ]]; then | |
| if [[ "$ARCH" == "x86_64" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/linux/x64/julia-latest-linux64.tar.gz" | |
| else | |
| echo "https://julialang-s3.julialang.org/bin/linux/x64/${MAJMIN}/julia-${VERSION}-linux-x86_64.tar.gz" | |
| fi | |
| elif [[ "$ARCH" == "i686" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/linux/x86/julia-latest-linux32.tar.gz" | |
| else | |
| echo "https://julialang-s3.julialang.org/bin/linux/x86/${MAJMIN}julia-${VERSION}-linux-i686.tar.gz" | |
| fi | |
| elif [[ "$ARCH" == "armhf" ]] || [[ "$ARCH" == "armv7l" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/linux/armv7l/julia-latest-linuxarmv7l.tar.gz" | |
| else | |
| echo "https://julialang.julialang.org/bin/linux/armv7l/${MAJMIN}/julia-${VERSION}-linux-armv7l.tar.gz" | |
| fi | |
| elif [[ "$ARCH" == "aarch64" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/linux/x86/julia-latest-linuxaarch64.tar.gz" | |
| else | |
| echo "https://julialang-s3.julialang.org/bin/linux/aarch64/${MAJMIN}/julia-${VERSION}-linux-aarch64.tar.gz" | |
| fi | |
| else | |
| echo "Architecture $ARCH unsupported on $OS" >&2 | |
| exit 1 | |
| fi | |
| elif [[ "$OS" == "Darwin" ]]; then | |
| if [[ "$ARCH" == "x86_64" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/mac/x64/julia-latest-mac64.dmg" | |
| else | |
| echo "https://julialang-s3.julialang.org/bin/mac/x64/${MAJMIN}/julia-${VERSION}-mac64.dmg" | |
| fi | |
| else | |
| echo "Architecture $ARCH unsupported on $OS" >&2 | |
| exit 1 | |
| fi | |
| elif [[ "$OS" == "FreeBSD" ]]; then | |
| if [[ "$ARCH" == "amd64" ]]; then | |
| if [[ "${VERSION}" == "master" ]]; then | |
| echo "https://julialangnightlies-s3.julialang.org/bin/freebsd/x64/julia-latest-freebsd64.tar.gz" | |
| else | |
| echo "https://julialang-s3.julialang.org/bin/freebsd/x64/${MAJMIN}/julia-${VERSION}-freebsd-x86_64.tar.gz" | |
| fi | |
| else | |
| echo "Architecture $ARCH unsupported on $OS" >&2 | |
| exit 1 | |
| fi | |
| else | |
| echo "Platform $OS unsupported" | |
| exit 1 | |
| fi | |
| } | |
| VERSION=${1:-1.5.1} | |
| JULIA_URL=$(get_julia_url ${VERSION}) | |
| DESTDIR=~/dist/julia-${VERSION} | |
| if [[ -d ${DESTDIR} ]]; then | |
| if [[ $@ == *--force* ]]; then | |
| rm -rf ${DESTDIR} | |
| else | |
| echo "${DESTDIR} already exists" >&2 | |
| exit 0 | |
| fi | |
| fi | |
| mkdir ${DESTDIR} | |
| echo "Downloading ${JULIA_URL}" | |
| if [[ "$OS" == "Linux" ]] || [[ "$OS" == "FreeBSD" ]]; then | |
| # Download, unpack Julia version into the destination directory | |
| curl -# -L "$JULIA_URL" | tar -C $DESTDIR --strip-components=1 -f- -zxv | |
| elif [[ "$OS" == "Darwin" ]]; then | |
| # Download, unpack Julia version into the destination directory | |
| curl -L "$JULIA_URL" -o ${DESTDIR}/julia-installer.dmg | |
| hdiutil mount ${DESTDIR}/julia-installer.dmg | |
| cp -Ra /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia/* ${DESTDIR} | |
| for j in /Volumes/Julia-*; do | |
| hdiutil detach "$j" | |
| done | |
| rm -f ${DESTDIR}/julia-installer.dmg | |
| else | |
| echo "Platform $OS unsupported" | |
| exit 1 | |
| fi | |
| # Link julia into our local bin directory | |
| mkdir -p ~/local/bin | |
| if [[ "${VERSION}" != "master" ]]; then | |
| ln -sf ${DESTDIR}/bin/julia ~/local/bin/ | |
| else | |
| ln -sf ${DESTDIR}/bin/julia ~/local/bin/julia-master | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment