Skip to content

Commit

Permalink
Merge pull request rkyleg#10 from lassepe/overhaul
Browse files Browse the repository at this point in the history
Overhaul: Make CI-checks pass, allow different architectures, support julia nightly builds, support freeBSD
  • Loading branch information
rkyleg authored Jul 7, 2020
2 parents a03cc3f + f318a79 commit 4a1ba30
Show file tree
Hide file tree
Showing 9 changed files with 179 additions and 129 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:
test:
name: Test ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
arch: [x64]
steps:
- uses: actions/checkout@v2
- name: asdf_plugin_test
uses: asdf-vm/actions/plugin-test@v1
with:
command: "julia --version"
env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Empty file modified .gitignore
100755 → 100644
Empty file.
15 changes: 0 additions & 15 deletions .gitlab-ci.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .travis.yml

This file was deleted.

Empty file modified LICENSE
100755 → 100644
Empty file.
33 changes: 11 additions & 22 deletions README.md
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,34 +1,23 @@
Travis CI Status:
[![Build Status](https://travis-ci.org/rkyleg/asdf-julia.svg?branch=master)](https://travis-ci.org/rkyleg/asdf-julia)
Gitlab CI Status:
[![build status](https://gitlab.com/rkyleg/asdf-julia/badges/master/build.svg)](https://gitlab.com/rkyleg/asdf-julia/commits/master)
# asdf-julia

Julia plugin for asdf version manager
![CI](https://github.com/lassepe/asdf-julia/workflows/CI/badge.svg)

**Install**
A julia plugin for the asdf version manager.

## Install

```bash
asdf plugin-add julia https://github.com/rkyleg/asdf-julia.git
```

**Use**
## Usage

Check [asdf](ashttps://github.com/asdf-vm/asdfdf) readme for instructions on how to install & manage versions of Julia.

**A few notes:**

The list-all script uses python to import and parse the list of releases from github.
If this causes problems for anyone, please let me know. I am making the assumption that python is
installed on everyone's machine.

Also, any pre-release or rc versions of julia are excluded as these didn't seem to be uploaded to their
Amazon S3 bucket.

On Linux:
There is an option to install the desktop entry at the end of the install process,
choose 'y' if you want to do this or 'n' if you do not.
## A few notes

On OSX:
The script pulls down the app package from the Julia website, but does not install
as a native app. Instead, it copies the julia directory from the Resources folder
inside the app package, thus providing the binary to asdf.

The script pulls down the app package from the Julia website, but does not install
as a native app. Instead, it copies the julia directory from the Resources folder
inside the app package, thus providing the binary to asdf.
211 changes: 140 additions & 71 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -4,81 +4,150 @@

set -e

install_julia(){
function get_arch_short {
local arch_long=$(uname -m)

case "$arch_long" in
"armv7l" | "aarch64")
local arch_short=$arch_long
;;
"i686")
local arch_short="x86"
;;
"x86_64")
local arch_short="x64"
;;
esac

echo $arch_short
}

function get_os {
local uname_str="$(uname)"

case $uname_str in
"Darwin")
local os="mac"
;;
*)
local os="$(echo $uname_str | tr '[:upper:]' '[:lower:]')"
;;
esac

echo $os
}

function get_file_extension {

case "$(get_os)" in
"mac")
local extension="dmg"
;;
*)
local extension="tar.gz"
;;
esac

echo $extension
}

function get_url_from_version {
local version=$1

local version_trim=${version%.*}
local arch_long=$(uname -m)
local arch_short=$(get_arch_short)
local os=$(get_os)
local extension=$(get_file_extension)

case $os in
"mac")
local version_postfix="mac64"
;;
*)
local version_postfix="$os-$arch_long"
;;
esac

echo "https://julialang-s3.julialang.org/bin/$os/$arch_short/$version_trim/julia-$version-$version_postfix.$extension"
}

function get_url_from_nightly {
local os=$(get_os)
local arch_short=$(get_arch_short)
local extension=$(get_file_extension)

case "$(get_os)" in
"mac")
local version_postfix="mac64"
;;
"linux")
case "$(uname -m)" in
"aarch64")
local version_postfix="linuxaarch64"
;;
"i686")
local version_postfix="linux32"
;;
"x86_64")
local version_postfix="linux64"
;;
*)
echo "Error: unrecognized os or arch." >&2
exit 1
;;
esac
;;
esac

echo "https://julialangnightlies-s3.julialang.org/bin/$os/$arch_short/julia-latest-$version_postfix.$extension"
}

function download_binary_archive {
local version=$1

local tmp_download_dir="$(mktemp -d -t asdf-julia.XXX)"
local tmp_download_file="$tmp_download_dir/julia.archive"

if [[ $version == "nightly" ]]; then
local url="$(get_url_from_nightly)"
else
local url="$(get_url_from_version $version)"
fi

echo "Downloading from:" >&2
echo $url >&2
curl -L --fail "$url" > "$tmp_download_file"

echo $tmp_download_file
}

function install_julia {
local install_type=$1
local version=$2
local install_path=$3
local version_trim=${version%.*}
local tmp_download_dir="$(mktemp -d -t asdf-julia.XXX)"
# local version_trim=${version%.*}

if [[ "$(uname)" == "Darwin" ]]; then
# if [[ "$CI_SERVER" = "yes" ]]; then
# local mountpath="/Volumes/Julia";
# local appname="Julia.app";
# else
# local mountpath="/Volumes/Julia-$version";
# local appname="/Julia-$version_trim.app";
# fi
# https://julialang-s3.julialang.org/bin/mac/x64/0.6/julia-0.6.1-mac64.dmg
# https://julialang-s3.julialang.org/bin/mac/x64/0.5/julia-0.5.2-mac64.dmg
# local url=$(curl -s -0 https://julialang.org/downloads/ `# look at the logins page` \
# | grep $version `# find the requested version` \
# | grep mac64 `# get the mac binaries` \
# | sed -n "/href/ s/.*href=['\"]\([^'\"]*\)['\"].*/\1/gp `# parse out the url`
# ")
local url="https://julialang-s3.julialang.org/bin/mac/x64/$version_trim/julia-$version-mac64.dmg"
curl $url --create-dirs -so "$tmp_download_dir/julia.dmg"

local volume_path=$(
hdiutil mount "$tmp_download_dir/julia.dmg" `# mount the dmg`\
| grep Volume `# find the volume row in the output`\
| egrep -o '/Volumes[^\n]+' `# store the volume's path`\
)

local source_path=$(find $volume_path -type d -print 2> /dev/null `# find all directories in the new volume, redirect the errors so they don't interfere with the grep` \
| grep 'Contents/Resources/julia$' `#find the julia directory` \
| head -n 1
)

cp -R $source_path $install_path
hdiutil unmount $volume_path
exit;
fi

local url="https://julialang-s3.julialang.org/bin/linux/x64/$version_trim/julia-$version-linux-x86_64.tar.gz"
# local url="https://julialang-s3.julialang.org/bin/linux/x64/1.0/julia-1.0.1-linux-x86_64.tar.gz"
# local url="$(curl -s -0 https://julialang.org/downloads/ `# look at the logins page` \
# | grep 0.6.1 `# find the requested version` \
# | grep linux/x64 `# get the linux binaries` \
# | sed -n "/href/ s/.*href=['\"]\([^'\"]*\)['\"].*/\1/gp" `# parse out the url` \
# | head -1
# )"
curl "$url" --create-dirs -so "$tmp_download_dir/julia.tar.gz"
local output_dir="$(tar -xvf "$tmp_download_dir/julia.tar.gz" -C "$install_path")"
local install_dir="$(echo $output_dir | cut -f1 -d"/")"
# local julia_dir=${install_dir[@]:0:5}

if [[ -z "$CI_SERVER" ]]; then
mv $install_path/$install_dir $install_path/julia
fi
# if [[ -z $install_path/julia ]]; then
# mkdir $install_path/julia
# mv $install_path/$julia_dir/** $install_path/julia
# rm -r $install_path/$julia_dir
# fi

if [[ -z "$CI_SERVER" && "$(uname)" == "Linux" ]]; then
echo "Do you want to install the desktop entry for Julia (y/n)?"
read installdesktop
if [ ${installdesktop} == "y" ]; then
cp $install_path/$julia_dir/share/applications/julia.desktop $HOME/.local/share/applications/julia.desktop
fi
# cp $ASDF_INSTALL_PATH/$julia_dir/share/applications/julia.desktop $HOME/.local/share/applications/julia.desktop;
fi
tmp_download_file="$(download_binary_archive $version)"
tmp_download_dir="$(dirname $tmp_download_file)"

if [ "$(uname)" == "Darwin" ]; then
local volume_path=$(
hdiutil mount "$tmp_download_file" `# mount the dmg`\
| grep Volume `# find the volume row in the output`\
| egrep -o '/Volumes[^\n]+' `# store the volume's path`\
)

# cp -r $tmp_download_dir/julia $ASDF_INSTALL_PATH
rm -rf $tmp_download_dir
# chmod a+x $install_path/$julia_dir
local source_path=$(find $volume_path -type d -print 2> /dev/null `# find all directories in the new volume, redirect the errors so they don't interfere with the grep` \
| grep 'Contents/Resources/julia$' `#find the julia directory` \
| head -n 1
)

cp -R $source_path $install_path
hdiutil unmount $volume_path
else
local untar_list="$(tar -xvf "$tmp_download_file" -C $tmp_download_dir)"
local untar_dir="$tmp_download_dir/$(echo $untar_list | cut -f1 -d"/" | head -n 1)"
mv $untar_dir/* $install_path/
fi
}
install_julia $ASDF_INSTALL_TYPE $ASDF_INSTALL_VERSION $ASDF_INSTALL_PATH
10 changes: 4 additions & 6 deletions bin/list-all
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,22 @@ function sort_versions() {
LC_ALL=C sort -gt. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | sort -r - | awk '{print $2}'
}

cmd="curl -s -0"
cmd="curl -Ls0"
releases_path="https://api.github.com/repos/JuliaLang/julia/releases"

if [ -n "$OAUTH_TOKEN" ]; then
cmd="$cmd -H 'Authorization: token $OAUTH_TOKEN'"
if [ -n "$GITHUB_API_TOKEN" ]; then
cmd="$cmd -H 'Authorization: token $GITHUB_API_TOKEN'"
fi
cmd="$cmd $releases_path"

versions=($(eval $cmd | sed -n 's/.*"tag_name": "\(.*\)",/\1/p' | sed 'y/v/ /' | sort_versions))
# | cat -A

length=$(( ${#versions[@]} - 1 ))
for (( i=length; i >=0; i-- ))
do
if [ ${versions[i]} != "0.0.1" ]
then
echo -n "${versions[i]} "

fi
done
# echo ${#versions}
echo nightly
3 changes: 0 additions & 3 deletions bin/list-bin-paths

This file was deleted.

0 comments on commit 4a1ba30

Please sign in to comment.