diff --git a/images/linux/scripts/installers/julia.sh b/images/linux/scripts/installers/julia.sh new file mode 100644 index 00000000..1ca45032 --- /dev/null +++ b/images/linux/scripts/installers/julia.sh @@ -0,0 +1,62 @@ +#!/bin/bash +################################################################################ +## File: julia.sh +## Desc: Installs Julia, and adds Julia to the path +################################################################################ + +# Source the helpers for use with the script +source $HELPER_SCRIPTS/document.sh + +# This function fetches the latest Julia release from the GitHub API +# Based on https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c +function GetLatestJuliaRelease () { + curl --silent "https://api.github.com/repos/julialang/julia/releases/latest" | + grep '"tag_name":' | + sed -E 's/.*"([^"]+)".*/\1/' | + sed 's/v//' # remove v prefix +} + + +# This function installs Julia using the specified arguments: +# $1=MajorAndMinorVersion (1.3.1) +# $2=IsDefaultVersion (true or false) + +function InstallJulia () { + # Extract Major and Minor version from full version string + juliaMajorAndMinorVersion="$(sed 's/\.[^.]*$//' <<< $1)" + + curl -sL "https://julialang-s3.julialang.org/bin/linux/x64/$juliaMajorAndMinorVersion/julia-$1-linux-x86_64.tar.gz" -o "julia-$1-linux-x86_64.tar.gz" + mkdir -p "/usr/local/julia$juliaMajorAndMinorVersion" + tar -C "/usr/local/julia$juliaMajorAndMinorVersion" -xzf "julia-$1-linux-x86_64.tar.gz" --strip-components=1 julia + rm "julia-$1-linux-x86_64.tar.gz" + + # If this version of Julia is to be the default version, + # symlink it into the path + if [ "$2" = true ]; then + ln -s "/usr/local/julia$juliaMajorAndMinorVersion/bin/julia" /usr/bin/julia + fi + + # Run tests to determine that the software installed as expected + echo "Testing to make sure that script performed as expected, and basic scenarios work" + + # If this version of Julia is to be the default version, + # check that it has been added to PATH + if [ "$2" = true ]; then + if ! command -v julia; then + echo "Julia was not installed or found on PATH" + exit 1 + fi + fi + + # Verify output of julia --version + if [ ! "$(/usr/local/julia"$juliaMajorAndMinorVersion"/bin/julia --version)" = "julia version $1" ]; then + echo "Julia was not installed correctly" + exit 1 + fi + + # Document what was added to the image + echo "Lastly, documenting what we added to the metadata file" + DocumentInstalledItem "Julia ($(julia --version))" +} + +InstallJulia "$(GetLatestJuliaRelease)" true diff --git a/images/win/scripts/Installers/Install-Julia.ps1 b/images/win/scripts/Installers/Install-Julia.ps1 new file mode 100644 index 00000000..90547472 --- /dev/null +++ b/images/win/scripts/Installers/Install-Julia.ps1 @@ -0,0 +1,6 @@ +################################################################################ +## File: Install-Julia.ps1 +## Desc: Install Julia +################################################################################ + +choco install julia -y --ia "/D=C:\Julia" diff --git a/images/win/scripts/Installers/Validate-Julia.ps1 b/images/win/scripts/Installers/Validate-Julia.ps1 new file mode 100644 index 00000000..e31bd39f --- /dev/null +++ b/images/win/scripts/Installers/Validate-Julia.ps1 @@ -0,0 +1,25 @@ +################################################################################ +## File: Validate-Julia.ps1 +## Desc: Validate Julia +################################################################################ + +# Verify that julia.exe is on the path +if(Get-Command -Name 'julia') +{ + Write-Host "$(julia --version) is on the path." +} +else +{ + Write-Host "Julia is not on the path." + exit 1 +} + +# Add description of the software to Markdown +$SoftwareName = "Julia (x64)" +$juliaVersion = $(julia --version).split() -match "\d+\.\d+\.\d+" + +$Description = @" +_Version:_ $juliaVersion
+"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description