Skip to content

Commit

Permalink
Fix computing major version
Browse files Browse the repository at this point in the history
  • Loading branch information
abelsiqueira committed Jan 2, 2024
1 parent 242bd41 commit 1a27df3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [unreleased]

### Changed

- Rename internal variables from major to minor

### Fixed

- Fix parsing of version when computing major

## [0.5.2] - 2023-05-09

### Added
Expand Down
36 changes: 18 additions & 18 deletions jill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ function get_url_from_platform_arch_version() {
platform=$1
arch=$2
version=$3
# TODO: Accept ARM and FreeBSD
[[ $arch == *"64" ]] && bit=64 || bit=32
# TODO: Accept ARM and FreeBSD
[[ $arch == "mac"* ]] && suffix=mac64.dmg || suffix="$platform-$arch.tar.gz"
minor=$(echo "$version" | cut -d. -f1-2 | cut -d- -f1)
url="https://julialang-s3.julialang.org/bin/$platform/x$bit/$minor/julia-$version-$suffix"
Expand Down Expand Up @@ -227,25 +227,25 @@ function install_julia_linux() {
version="$JLVERSION"
fi

major=${version:0:3}
rm -f "$JULIA_INSTALL"/julia{,-"$major",-"$version"}
minor=$(echo "$version" | cut -d. -f1-2 | cut -d- -f1)
rm -f "$JULIA_INSTALL"/julia{,-"$minor",-"$version"}
julia="$PWD/julia-$version/bin/julia"

if [[ "$UPGRADE_CONFIRM" == "1" ]]; then
old_major="${JULIA_OLD:0:3}"
old_minor=$(echo "$JULIA_OLD" | cut -d. -f1,2 | cut -d- -f1)
if [ "$USER" == "root" ] && [ -n "$SUDO_USER" ]; then
JULIAENV="/home/$SUDO_USER"
else
JULIAENV=$HOME
fi
JULIAENV="${JULIAENV}/.julia/environments"
echo "Copying environments in ${JULIAENV} from v${old_major} to v${major}"
cp -rp "${JULIAENV}/v${old_major}" "${JULIAENV}/v${major}"
echo "Copying environments in ${JULIAENV} from v${old_minor} to v${minor}"
cp -rp "${JULIAENV}/v${old_minor}" "${JULIAENV}/v${minor}"
fi

# create symlink
ln -s "$julia" "$JULIA_INSTALL/julia"
ln -s "$julia" "$JULIA_INSTALL/julia-$major"
ln -s "$julia" "$JULIA_INSTALL/julia-$minor"
ln -s "$julia" "$JULIA_INSTALL/julia-$version"
}

Expand All @@ -267,43 +267,43 @@ function install_julia_mac() {
$WGET -c "$url" -O "julia-$version.dmg"
fi

major="${version:0:3}"
minor=$(echo "$version" | cut -d. -f1,2 | cut -d- -f1)

hdiutil attach "julia-$version.dmg" -quiet -mount required -mountpoint "julia-$major"
if [ ! -d "julia-$major" ]; then
hdiutil attach "julia-$version.dmg" -quiet -mount required -mountpoint "julia-$minor"
if [ ! -d "julia-$minor" ]; then
# if it fails to mount for unknown reason, try it again after 1 second...
sleep 1
hdiutil attach "julia-$version.dmg" -quiet -mount required -mountpoint "julia-$major"
hdiutil attach "julia-$version.dmg" -quiet -mount required -mountpoint "julia-$minor"
fi

INSTALL_PATH="/Applications/julia-$major.app"
INSTALL_PATH="/Applications/julia-$minor.app"
EXEC_PATH="$INSTALL_PATH/Contents/Resources/julia/bin/julia"
rm -rf "$INSTALL_PATH"
cp -a "julia-$major/Julia-$major.app" /Applications/
cp -a "julia-$minor/Julia-$minor.app" /Applications/

if [[ "$UPGRADE_CONFIRM" == "1" ]]; then
old_major="${JULIA_OLD:0:3}"
old_minor=$(echo "$JULIA_OLD" | cut -d. -f1,2 | cut -d- -f1)
if [ "$USER" == "root" ] && [ -n "$SUDO_USER" ]; then
JULIAENV="/Users/$SUDO_USER"
else
JULIAENV=$HOME
fi
JULIAENV="${JULIAENV}/.julia/environments"
echo "Copying environments in ${JULIAENV} from v${old_major} to v${major}"
cp -rp "${JULIAENV}/v${old_major}" "${JULIAENV}/v${major}"
echo "Copying environments in ${JULIAENV} from v${old_minor} to v${minor}"
cp -rp "${JULIAENV}/v${old_minor}" "${JULIAENV}/v${minor}"
fi

# create symlink
ln -sf "$EXEC_PATH" "$JULIA_INSTALL/julia"
ln -sf "$EXEC_PATH" "$JULIA_INSTALL/julia-$major"
ln -sf "$EXEC_PATH" "$JULIA_INSTALL/julia-$minor"

if [[ "$LATEST" == "1" ]]; then
version="$("$JULIA_INSTALL"/julia -version | cut -d' ' -f3)"
fi
ln -sf "$EXEC_PATH" "$JULIA_INSTALL/julia-$version"

# post-installation
umount "julia-$major"
umount "julia-$minor"
}

# --------------------------------------------------------
Expand Down

0 comments on commit 1a27df3

Please sign in to comment.