Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit f7da8f3

Browse files
committed
feature: adding unix 32 bits architecture option
1 parent 593a62b commit f7da8f3

File tree

2 files changed

+98
-43
lines changed

2 files changed

+98
-43
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@ Run the script for install:
2121

2222
- `juliavm ls-remote` - list all remote versions
2323
- `juliavm ls` - list all locale versions
24-
- `juliavm install x.y.z` - install x.y.x version
25-
- `juliavm use x.y.z` - use x.y.x version
24+
- `juliavm install x.y.z [-ARCHITECTURE]` - install x.y.x version, ARCHITECTURE is an optional param
25+
- `juliavm use x.y.z [-ARCHITECTURE]` - use x.y.x version, ARCHITECTURE is an optional param
2626
- `juliavm update` - update **juliavm** with latest resources
2727
- `juliavm uninstall` - uninstall juliavm and all julia versions downloaded inside juliavm
2828
- `juliavm help` - list all available commands
2929

3030
## Architectures
31-
32-
Only unix 64 bits version is supported right now, in some nearby moment in the future it will be update for 32 bits and OSx versions.
31+
- `-x64` - unix 64 bits
32+
- `-x86` - unix 32 bits
33+
- If you don't pass the architecture unix 64 bits will be assumed
34+
35+
Only Unix (32 and 64 bits) version is supported right now, in some nearby moment in the future it will be update for be compatible with OSX.

juliavm.sh

Lines changed: 91 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if [ -z "$JULIAVM_JULIA_REPO" ]; then
55
export JULIAVM_JULIA_REPO="https://github.com/JuliaLang/julia"
66
fi
77
if [ -z "$JULIAVM_JULIA_AWS" ]; then
8-
export JULIAVM_JULIA_AWS="https://julialang.s3.amazonaws.com/bin/linux/x64/"
8+
export JULIAVM_JULIA_AWS="https://julialang.s3.amazonaws.com/bin/linux/"
99
fi
1010
if [ -z "$JULIAVM_WORK_DIR" ]; then
1111
export JULIAVM_WORK_DIR=$( cd "$( dirname "$0" )" && pwd )
@@ -18,26 +18,32 @@ juliavm_ls_remote() {
1818
}
1919

2020
juliavm_install(){
21-
file=$(juliavm_get_file_name $1)
22-
url=$(juliavm_get_download_url $1)
23-
24-
JULIAVM_DISTS_DIR=$JULIAVM_WORK_DIR'/dists/'$1
21+
file=$(juliavm_get_file_name $1 $2)
22+
url=$(juliavm_get_download_url $1 $2)
23+
24+
dists_dir=$(juliavm_get_dist_dir $1 $2)
2525

26-
if [ -d "$JULIAVM_DISTS_DIR" ]; then
27-
echo $JULIAVM_DISTS_DIR' already exist'
26+
if [ -d "$dists_dir" ]; then
27+
echo $dists_dir' already exist'
2828
else
29-
eval 'mkdir $JULIAVM_DISTS_DIR'
30-
eval 'wget $url -P $JULIAVM_DISTS_DIR'
31-
eval 'tar -xvzf $JULIAVM_DISTS_DIR/$file.tar.gz -C $JULIAVM_DISTS_DIR --strip-components=1'
32-
eval 'rm $JULIAVM_DISTS_DIR/$file.tar.gz'
29+
eval 'mkdir $dists_dir'
30+
eval 'wget $url -P $dists_dir'
31+
eval 'tar -xvzf $dists_dir/$file.tar.gz -C $dists_dir --strip-components=1'
32+
eval 'rm $dists_dir/$file.tar.gz'
3333
fi
3434
juliavm_use $1
3535
}
3636

3737
juliavm_use(){
38-
EXEC_PATH="$JULIAVM_WORK_DIR/dists/$1/bin/julia"
38+
if [[ "$2" == '-x86' ]]; then
39+
EXEC_PATH="$JULIAVM_WORK_DIR/dists/$1$2/bin/julia"
40+
elif [[ "$2" == '-64' ]]; then
41+
EXEC_PATH="$JULIAVM_WORK_DIR/dists/$1/bin/julia"
42+
else
43+
EXEC_PATH="$JULIAVM_WORK_DIR/dists/$1/bin/julia"
44+
fi
3945
sed -i /'alias julia='/d ~/.bashrc
40-
echo "You're now using Julia $1"
46+
echo "You're now using Julia $1$2"
4147
echo "alias julia='$EXEC_PATH'" >> ~/.bashrc && exec bash
4248
}
4349

@@ -47,7 +53,14 @@ juliavm_ls(){
4753
}
4854

4955
juliavm_version_is_available_locale(){
50-
VERSION_DIR="$JULIAVM_WORK_DIR/dists/$1"
56+
if [[ "$2" == '-x86' ]]; then
57+
VERSION_DIR="$JULIAVM_WORK_DIR/dists/$1$2"
58+
elif [[ "$2" == '-x64' ]]; then
59+
VERSION_DIR="$JULIAVM_WORK_DIR/dists/$1"
60+
else
61+
VERSION_DIR="$JULIAVM_WORK_DIR/dists/$1"
62+
fi
63+
5164
if [ -d "$VERSION_DIR" ]; then
5265
return 0
5366
else
@@ -58,8 +71,8 @@ juliavm_version_is_available_locale(){
5871
}
5972

6073
juliavm_version_is_available_remote(){
61-
file=$(juliavm_get_file_name $1)
62-
url=$(juliavm_get_download_url $1)
74+
file=$(juliavm_get_file_name $1 $2)
75+
url=$(juliavm_get_download_url $1 $2)
6376
if eval "curl --output /dev/null --silent --head --fail \"$url\""; then
6477
return 0
6578
else
@@ -69,20 +82,71 @@ juliavm_version_is_available_remote(){
6982
fi
7083
}
7184

85+
86+
juliavm_get_file_name(){
87+
if [[ "$2" == '-x86' ]]; then
88+
file='julia-'$1'-linux-i686'
89+
echo $file
90+
elif [[ "$2" == '-x64' ]]; then
91+
file='julia-'$1'-linux-x86_64'
92+
echo $file
93+
else
94+
file='julia-'$1'-linux-x86_64'
95+
echo $file
96+
fi
97+
}
98+
99+
juliavm_get_download_url(){
100+
file=$(juliavm_get_file_name $1 $2)
101+
major=${1:0:3}'/'
102+
103+
if [[ "$2" == '-x86' ]]; then
104+
arch='x86/'
105+
url=$JULIAVM_JULIA_AWS$arch$major$file'.tar.gz'
106+
echo $url
107+
elif [[ "$2" == '-x64' ]]; then
108+
arch='x64/'
109+
url=$JULIAVM_JULIA_AWS$arch$major$file'.tar.gz'
110+
echo $url
111+
else
112+
arch='x64/'
113+
url=$JULIAVM_JULIA_AWS$arch$major$file'.tar.gz'
114+
echo $url
115+
fi
116+
}
117+
118+
juliavm_get_dist_dir(){
119+
if [[ "$2" == '-x86' ]]; then
120+
dist_dir=$JULIAVM_WORK_DIR'/dists/'$1$2
121+
echo $dist_dir
122+
elif [[ "$2" == '-x64' ]]; then
123+
dist_dir=$JULIAVM_WORK_DIR'/dists/'$1
124+
echo $dist_dir
125+
else
126+
dist_dir=$JULIAVM_WORK_DIR'/dists/'$1
127+
echo $dist_dir
128+
fi
129+
}
130+
131+
72132
juliavm_update(){
73133
eval 'cd $JULIAVM_WORK_DIR && git pull origin master'
74134
eval 'mv $JULIAVM_WORK_DIR/juliavm.sh $DIR/juliavm'
75135
}
76136

77137

78138
juliavm_help() {
79-
echo " install x.y.z - install x.y.x version"
80-
echo " use x.y.z - use x.y.x version"
81-
echo " ls-remote - list all remote versions"
82-
echo " ls - list all locale versions"
83-
echo " update - update juliavm with latest resources"
84-
echo " uninstall - uninstall juliavm and all julia versions downloaded inside juliavm"
85-
echo " help - list all commands"
139+
echo " install x.y.z install x.y.x version [ARCHITECTURE]"
140+
echo " use x.y.z use x.y.x version [ARCHITECTURE]"
141+
echo " ls-remote list all remote versions"
142+
echo " ls list all locale versions"
143+
echo " update update juliavm with latest resources"
144+
echo " uninstall uninstall juliavm and all julia versions downloaded inside juliavm"
145+
echo " help list all commands"
146+
echo " "
147+
echo "ARCHITECTURE options (if you don't pass unix 64 bits will be assumed):"
148+
echo " -x64 unix 64 bits"
149+
echo " -x86 unix 32 bits"
86150
}
87151

88152
juliavm_uninstall(){
@@ -92,29 +156,17 @@ juliavm_uninstall(){
92156
eval "rm -r ~/.juliavm"
93157
}
94158

95-
juliavm_get_file_name(){
96-
file='julia-'$1'-linux-x86_64'
97-
echo $file
98-
}
99-
100-
juliavm_get_download_url(){
101-
file=$(juliavm_get_file_name $1)
102-
major=${1:0:3}'/'
103-
url=$JULIAVM_JULIA_AWS$major$file'.tar.gz'
104-
echo $url
105-
}
106-
107159
if [[ "$1" == 'ls-remote' ]]; then
108160
juliavm_ls_remote
109161
elif [[ "$1" == 'install' ]]; then
110-
if juliavm_version_is_available_remote $2 ; then
111-
juliavm_install $2
162+
if juliavm_version_is_available_remote $2 $3; then
163+
juliavm_install $2 $3
112164
fi
113165
elif [[ "$1" == 'ls' ]]; then
114166
juliavm_ls $2
115167
elif [[ "$1" == 'use' ]]; then
116-
if juliavm_version_is_available_locale $2 ; then
117-
juliavm_use $2
168+
if juliavm_version_is_available_locale $2 $3; then
169+
juliavm_use $2 $3
118170
fi
119171
elif [[ "$1" == 'update' ]]; then
120172
juliavm_update

0 commit comments

Comments
 (0)