-
Notifications
You must be signed in to change notification settings - Fork 0
/
script
executable file
·47 lines (40 loc) · 1.75 KB
/
script
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
set -e # Failfast (broken)
loc=$1 # Create varaibles
pkg=$(basename $loc .jl)
if [ $loc = $pkg ]
then
loc=\"$loc\"
else
loc=url=\"$loc\"
fi
install=$(echo 'import Pkg; Pkg.activate("$p", shared=true); Pkg.add($l); using $p: main' | awk '{gsub(/\$p/, p); gsub(/\$l/, l)} 1' p=$pkg l=$loc)
if julia -v
then
# Julia is installed
echo "This might take a while." # Ecosystem-wide TTFX issues...
julia -e "${install}"
else
# Julia is missing; install it with juliaup (https://github.com/JuliaLang/juliaup)
# Use manual install b.c. script install is broken (https://github.com/JuliaLang/juliaup/issues/464)
# expect -c 'spawn bash -c "curl -fsSL https://install.julialang.org | sh"; expect "Proceed"; send -- "\r"; expect eof' || exit 1
echo "The \`julia\` command is not availible on this system—installing it now. Feel free to use the default settings."
curl -fsSL https://install.julialang.org | sh
echo "Now that Julia is installed, we can install $pkg. This might take a while." # Ecosystem-wide TTFX issues...
# Julia may not yet be on the path of this shell so we launch with an absolute path
~/.julia/juliaup/bin/julialauncher -e "${install}"
fi
# Move from ~ to ~/Desktop so that the script will be more easily located (if possible)
dir=$(pwd)
set +e
if [ $(pwd) = ~ ]
then
cd Desktop
fi
set -e
# Create script
echo '#!/bin/sh\njulia -e '\''import Pkg; Pkg.activate("$p", shared=true); try Pkg.update() catch; println("Warning: update failed") end; using $p: main; main()'\'' $0 $@' | awk '{gsub(/\$p/, p)} 1' p=$pkg>$pkg
chmod +x $pkg
echo "Installation succeeded!"
echo "Double click on the $pkg file to run the program"
echo "$pkg is currently located at $(pwd), but feel free to move it somewhere more convenient"
cd $dir