From 3daa3f157891787dbddab832e6444c747305c677 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 17 Oct 2019 15:16:03 +1100 Subject: [PATCH 01/11] Port to jlenv. Refactored github raw files. --- .gitignore | 10 ++++++++++ .markdownlint.yml | 4 ++++ .travis.yml | 7 +++++++ README.md | 8 ++++---- bin/rbenv-doctor => libexec/jlenv-doctor | 0 bin/rbenv-installer => libexec/jlenv-installer | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 .markdownlint.yml create mode 100644 .travis.yml rename bin/rbenv-doctor => libexec/jlenv-doctor (100%) rename bin/rbenv-installer => libexec/jlenv-installer (98%) diff --git a/.gitignore b/.gitignore index 1d74e21..9fa3fdf 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,11 @@ +# Don't track test scaffolding: +test/libs/* +test/libexec/bin +test/libexec/libexec +test/libexec/share + +# Editor settings .vscode/ + +# merge conflict artifacts +*.orig \ No newline at end of file diff --git a/.markdownlint.yml b/.markdownlint.yml new file mode 100644 index 0000000..f9a89e1 --- /dev/null +++ b/.markdownlint.yml @@ -0,0 +1,4 @@ +{ + "default": true, + "MD003": { "style": "atx" } +} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..179c9b6 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,7 @@ +sudo: false +language: c +script: + # Fail if any of these files have warnings + - shellcheck etc/jlenv.d/exec/* + - shellcheck libexec/* + - test/run diff --git a/README.md b/README.md index cc367e4..a26631a 100644 --- a/README.md +++ b/README.md @@ -11,10 +11,10 @@ installed if `jlenv install` is not already available. ```sh # with curl -curl -fsSL https://github.com/jlenv/jlenv-installer/raw/master/bin/jlenv-installer | bash +curl -fsSL https://raw.githubusercontent.com/jlenv/jlenv-installer/master/libexec/jlenv-installer | bash # alternatively, with wget -wget -q https://github.com/jlenv/jlenv-installer/raw/master/bin/jlenv-installer -O- | bash +wget -q https://raw.githubusercontent.com/jlenv/jlenv-installer/master/libexec/jlenv-installer -O- | bash ``` ## jlenv-doctor @@ -25,8 +25,8 @@ success of the installation and to detect common issues. You can run ```sh # with curl -curl -fsSL https://github.com/jlenv/jlenv-installer/raw/master/bin/jlenv-doctor | bash +curl -fsSL https://raw.githubusercontent.com/jlenv/jlenv-installer/master/libexec/jlenv-doctor | bash # alternatively, with wget -wget -q https://github.com/jlenv/jlenv-installer/raw/master/bin/jlenv-doctor -O- | bash +wget -q https://raw.githubusercontent.com/jlenv/jlenv-installer/master/libexec/jlenv-doctor -O- | bash ``` diff --git a/bin/rbenv-doctor b/libexec/jlenv-doctor similarity index 100% rename from bin/rbenv-doctor rename to libexec/jlenv-doctor diff --git a/bin/rbenv-installer b/libexec/jlenv-installer similarity index 98% rename from bin/rbenv-installer rename to libexec/jlenv-installer index b9d7544..c9b167d 100755 --- a/bin/rbenv-installer +++ b/libexec/jlenv-installer @@ -40,7 +40,7 @@ if [ -n "$jlenv" ]; then if [ -x ./brew ]; then echo "Trying to update with Homebrew..." brew update >/dev/null - if [ "$(./jlenv --version)" < "1.0.0" ] && brew list jlenv | grep -q jlenv/HEAD; then + if [ "$(./jlenv --version)" = "1.0.0" ] && brew list jlenv | grep -q jlenv/HEAD; then brew uninstall jlenv brew install jlenv --without-julia-build else From c83a38ed1c2a20508e956995ce6a373e2728712a Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 17 Oct 2019 16:58:04 +1100 Subject: [PATCH 02/11] Add badges. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a26631a..3485640 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # jlenv installer & doctor scripts +[![Build Status](https://travis-ci.com/jlenv/jlenv-installer.svg?branch=master)](https://travis-ci.com/jlenv/jlenv-installer)[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dac67ef51fa34b25babb098b05145f72)](https://www.codacy.com/manual/taqtiqa-mark/jlenv-jlenv-installer?utm_source=github.com&utm_medium=referral&utm_content=jlenv/jlenv-installer&utm_campaign=Badge_Grade)[![CodeFactor](https://www.codefactor.io/repository/github/jlenv/jlenv-installer/badge)](https://www.codefactor.io/repository/github/jlenv/jlenv-installer) + ## jlenv-installer The `jlenv-installer` script idempotently installs or updates jlenv on your From de5dacbbaf9ff66d34ca9e77849ca3eeb6c35cab Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 17 Oct 2019 20:46:16 +1100 Subject: [PATCH 03/11] Lint changes. --- .markdownlint.yml | 3 ++- .travis.yml | 6 +++--- README.md | 2 +- libexec/jlenv-doctor | 25 ++++++++++++++----------- libexec/jlenv-installer | 7 +++++-- 5 files changed, 25 insertions(+), 18 deletions(-) diff --git a/.markdownlint.yml b/.markdownlint.yml index f9a89e1..5490038 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -1,4 +1,5 @@ { "default": true, - "MD003": { "style": "atx" } + "MD003": { "style": "atx" }, + "MD013": false } \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 179c9b6..055d32a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,6 @@ sudo: false language: c script: # Fail if any of these files have warnings - - shellcheck etc/jlenv.d/exec/* - - shellcheck libexec/* - - test/run + #- shellcheck etc/jlenv.d/exec/* + #- shellcheck libexec/* + #- test/run diff --git a/README.md b/README.md index 3485640..dba652f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jlenv installer & doctor scripts -[![Build Status](https://travis-ci.com/jlenv/jlenv-installer.svg?branch=master)](https://travis-ci.com/jlenv/jlenv-installer)[![Codacy Badge](https://api.codacy.com/project/badge/Grade/dac67ef51fa34b25babb098b05145f72)](https://www.codacy.com/manual/taqtiqa-mark/jlenv-jlenv-installer?utm_source=github.com&utm_medium=referral&utm_content=jlenv/jlenv-installer&utm_campaign=Badge_Grade)[![CodeFactor](https://www.codefactor.io/repository/github/jlenv/jlenv-installer/badge)](https://www.codefactor.io/repository/github/jlenv/jlenv-installer) +[![Build Status](https://travis-ci.com/jlenv/jlenv-installer.svg?branch=master)](https://travis-ci.com/jlenv/jlenv-installer) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/dac67ef51fa34b25babb098b05145f72)](https://www.codacy.com/manual/taqtiqa-mark/jlenv-jlenv-installer?utm_source=github.com&utm_medium=referral&utm_content=jlenv/jlenv-installer&utm_campaign=Badge_Grade) [![CodeFactor](https://www.codefactor.io/repository/github/jlenv/jlenv-installer/badge)](https://www.codefactor.io/repository/github/jlenv/jlenv-installer) ## jlenv-installer diff --git a/libexec/jlenv-doctor b/libexec/jlenv-doctor index 0a80fd1..288d12a 100755 --- a/libexec/jlenv-doctor +++ b/libexec/jlenv-doctor @@ -1,5 +1,8 @@ #!/bin/bash +# shellcheck disable=SC2034 +# # Usage: jlenv doctor +# # Summary: Detects common problems in jlenv installation set -e @@ -20,7 +23,7 @@ printc() { fmt="${!color_name}${fmt}${color_reset}" fi - printf "$fmt" "$@" + printf "%s %s" "$fmt" "$@" } if [ -t 1 ]; then @@ -39,15 +42,15 @@ fi warnings=0 -if [ $(uname -s) = "Darwin" ]; then +if [ "$(uname -s)" = "Darwin" ]; then bashrc=".bash_profile" else bashrc=".bashrc" fi -echo -n "Checking for \`jlenv' in PATH: " +echo -n "Checking for \`jlenv\` in PATH: " num_locations="$(which -a jlenv | uniq | wc -l)" -if [ $num_locations -eq 0 ]; then +if [ "$num_locations" -eq 0 ]; then printc red "not found\n" { if [ -x ~/.jlenv/bin/jlenv ]; then echo "You seem to have jlenv installed in \`$HOME/.jlenv/bin', but that" @@ -58,7 +61,7 @@ if [ $num_locations -eq 0 ]; then fi } | indent exit 1 -elif [ $num_locations -eq 1 ]; then +elif [ "$num_locations" -eq 1 ]; then printc green "%s\n" "$(which jlenv)" else printc yellow "multiple\n" @@ -105,7 +108,7 @@ if [ -z "$jlenv_installs" ]; then } echo : $((warnings++)) -elif [ $num_installs -eq 1 ]; then +elif [ "$num_installs" -eq 1 ]; then printc green "$jlenv_installs" if [[ $jlenv_installs == "$JLENV_ROOT"/plugins/* ]]; then jlenv_install_cmd="${jlenv_installs##*/}" @@ -126,22 +129,22 @@ else fi echo -n "Counting installed Julia versions: " -num_julies="$(jlenv versions --bare | wc -l)" -if [ $num_julies -eq 0 ]; then +num_julies="$(jlenv-versions --bare | wc -l)" +if [ "$num_julies" -eq 0 ]; then printc yellow "none\n" echo "There aren't any Julia versions installed under \`$JLENV_ROOT/versions'." | indent - [ $num_installs -eq 0 ] || { + [ "$num_installs" -eq 0 ] || { echo -n "You can install Julia versions like so: " printc bright "jlenv install 1.0.3\n" } | indent else - printc green "%d versions\n" $num_julies + printc green "%d versions\n" "$num_julies" fi echo -n "Auditing installed plugins: " OLDIFS="$IFS" IFS=$'\n' -hooks=(`jlenv hooks exec`) +hooks=$(jlenv hooks exec) IFS="$OLDIFS" plugin_broken=0 for hook in "${hooks[@]}"; do diff --git a/libexec/jlenv-installer b/libexec/jlenv-installer index c9b167d..5d203cc 100755 --- a/libexec/jlenv-installer +++ b/libexec/jlenv-installer @@ -1,4 +1,6 @@ #!/bin/bash +# shellcheck disable=SC2034 +# set -e homebrew= @@ -6,13 +8,14 @@ type -p brew >/dev/null && homebrew=1 try_bash_extension() { if [ -x src/configure ]; then - src/configure && make -C src || { + src/configure + make -C src || { echo "Optional bash extension failed to build, but things will still work normally." } fi } -if ! type -p git >/dev/null; then +if ! command -v git > /dev/null 2>&1; then git() { echo "Error: git is required to proceed. Please install git and try again." >&2 exit 1 From db9cb3aedc697d82e845400e0f91f0e68d57fd64 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 17 Oct 2019 20:47:08 +1100 Subject: [PATCH 04/11] Turn on shellcheck in Travis. --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 055d32a..341841c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ sudo: false language: c +# Fail if any of these files have warnings script: - # Fail if any of these files have warnings - #- shellcheck etc/jlenv.d/exec/* - #- shellcheck libexec/* - #- test/run + - shellcheck etc/jlenv.d/exec/* + - shellcheck libexec/* \ No newline at end of file From c421c0d2fe212d51321a60b6d970175161fd8273 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 17 Oct 2019 20:47:43 +1100 Subject: [PATCH 05/11] Travis language bash. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 341841c..5d47e34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ sudo: false -language: c +language: bash # Fail if any of these files have warnings script: - shellcheck etc/jlenv.d/exec/* From 5e05690bf7ab20153a3e67cdccc65f22f7063dcc Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Wed, 30 Oct 2019 08:25:15 +1100 Subject: [PATCH 06/11] Comment out homebrew. Call for contributors. --- libexec/jlenv-installer | 64 +++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/libexec/jlenv-installer b/libexec/jlenv-installer index 5d203cc..73c1337 100755 --- a/libexec/jlenv-installer +++ b/libexec/jlenv-installer @@ -3,6 +3,7 @@ # set -e +tag_name='1.0.0' homebrew= type -p brew >/dev/null && homebrew=1 @@ -41,38 +42,44 @@ if [ -n "$jlenv" ]; then cd "${jlenv%/*}" if [ -x ./brew ]; then - echo "Trying to update with Homebrew..." - brew update >/dev/null - if [ "$(./jlenv --version)" = "1.0.0" ] && brew list jlenv | grep -q jlenv/HEAD; then - brew uninstall jlenv - brew install jlenv --without-julia-build - else - brew upgrade jlenv - fi + echo "Trying to update with Homebrew not yet ported. Contributors needed..." + # brew update >/dev/null + # if [ "$(./jlenv --version)" = "${tag_name}" ] && brew list jlenv | grep -q jlenv/HEAD; then + # brew uninstall jlenv + # brew install jlenv --without-julia-build + # else + # brew upgrade jlenv + # fi elif git remote -v 2>/dev/null | grep -q jlenv; then echo "Trying to update with git..." git pull --tags origin master + git checkout $(git tag | sort -V | tail -1) cd .. try_bash_extension fi else if [ -n "$homebrew" ]; then - echo "Installing jlenv with Homebrew..." - brew update - brew install jlenv --without-julia-build - jlenv="$(brew --prefix)/bin/jlenv" + echo "Installing jlenv with Homebrew not yet ported. Contributors needed..." + # brew update + # brew install jlenv --without-julia-build + # jlenv="$(brew --prefix)/bin/jlenv" else - echo "Installing jlenv with git..." + echo "Installing jlenv version ${tag_name} with git..." mkdir -p ~/.jlenv cd ~/.jlenv git init git remote add -f -t master origin https://github.com/jlenv/jlenv.git - git checkout -b master origin/master + git fetch --tags --force + git checkout tags/${tag_name} try_bash_extension jlenv=~/.jlenv/bin/jlenv - - if [ ! -e versions ] && [ -w /opt/julies ]; then - ln -s /opt/julies versions + + # We don't yet have a chjulia - but will, for those use cases. + # jlenv and chjulia two should adopt the same default location where multiple + # Julias are iunstalled. + # Current intention is to adopt chjulia conventions. + if [ ! -e versions ] && [ -w /opt/julias ]; then + ln -s /opt/julias versions fi fi fi @@ -86,22 +93,23 @@ if [ -n "$julia_build" ]; then cd "${julia_build%/*}" if [ -x ./brew ]; then - echo "Trying to update with Homebrew..." - brew update >/dev/null - brew upgrade julia-build + echo "Trying to update with Homebrew not yet ported. Contributors needed..." + # brew update >/dev/null + # brew upgrade julia-build elif git remote -v 2>/dev/null | grep -q julia-build; then echo "Trying to update with git..." - git pull origin master + git fetch --tags --force + git checkout $(git tag | sort -V | tail -1) fi else if [ -n "$homebrew" ]; then - echo "Installing julia-build with Homebrew..." - brew update - brew install julia-build + echo "Installing julia-build with Homebrew not yet ported. Contributors needed..." + # brew update + # brew install julia-build else - echo "Installing julia-build with git..." - mkdir -p "${jlenv_root}/plugins" - git clone https://github.com/jlenv/julia-build.git "${jlenv_root}/plugins/julia-build" + echo "Installing julia-install with git not yet inplemented..." + # mkdir -p "${jlenv_root}/plugins" + # git clone https://github.com/jlenv/julia-install.git "${jlenv_root}/plugins/julia-install" fi fi @@ -110,7 +118,7 @@ mkdir -p "${jlenv_root}/cache" echo echo "Running doctor script to verify installation..." -http https://github.com/jlenv/jlenv-installer/raw/master/bin/jlenv-doctor | "$BASH" +http https://raw.githubusercontent.com/jlenv/jlenv-installer/master/libexec/jlenv-doctor | "$BASH" echo echo "All done!" From 365c3931cae794ddf36a9ced66573ef228ef69a0 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 5 Dec 2019 04:09:37 +1100 Subject: [PATCH 07/11] Remove try bash extension. --- libexec/jlenv-installer | 1 - 1 file changed, 1 deletion(-) diff --git a/libexec/jlenv-installer b/libexec/jlenv-installer index 73c1337..29bea3f 100755 --- a/libexec/jlenv-installer +++ b/libexec/jlenv-installer @@ -71,7 +71,6 @@ else git remote add -f -t master origin https://github.com/jlenv/jlenv.git git fetch --tags --force git checkout tags/${tag_name} - try_bash_extension jlenv=~/.jlenv/bin/jlenv # We don't yet have a chjulia - but will, for those use cases. From 0aee046fd52e947ca01b585888fbe58e9ed923c8 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 5 Dec 2019 04:18:03 +1100 Subject: [PATCH 08/11] Remove try bash extension. Add comments. --- libexec/jlenv-installer | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libexec/jlenv-installer b/libexec/jlenv-installer index 29bea3f..260ccb2 100755 --- a/libexec/jlenv-installer +++ b/libexec/jlenv-installer @@ -55,7 +55,6 @@ if [ -n "$jlenv" ]; then git pull --tags origin master git checkout $(git tag | sort -V | tail -1) cd .. - try_bash_extension fi else if [ -n "$homebrew" ]; then @@ -72,10 +71,9 @@ else git fetch --tags --force git checkout tags/${tag_name} jlenv=~/.jlenv/bin/jlenv - # We don't yet have a chjulia - but will, for those use cases. - # jlenv and chjulia two should adopt the same default location where multiple - # Julias are iunstalled. + # jlenv and chjulia should adopt the same default location where multiple + # Julias are installed. # Current intention is to adopt chjulia conventions. if [ ! -e versions ] && [ -w /opt/julias ]; then ln -s /opt/julias versions @@ -124,8 +122,8 @@ echo "All done!" echo "Note that this installer doesn't yet configure your shell startup files:" i=0 if [ -x ~/.jlenv/bin ]; then - echo "$((++i)). You'll want to ensure that \`~/.jlenv/bin' is added to PATH." + echo "$((++i)). You'll want to ensure that \$(~/.jlenv/bin) and \$(~/.jlenv/libexec) is added to PATH." fi -echo "$((++i)). Run \`jlenv init' to see instructions how to configure jlenv for your shell." +echo "$((++i)). Run \$(jlenv init) to see instructions how to configure jlenv for your shell." echo "$((++i)). Launch a new terminal window to verify that the configuration is correct." echo From c89b2e0541291dfa27f51f0527f7e4df4dce43ce Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 5 Dec 2019 04:18:39 +1100 Subject: [PATCH 09/11] Add tag_name 1.0.1 --- libexec/jlenv-installer | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/jlenv-installer b/libexec/jlenv-installer index 260ccb2..2206643 100755 --- a/libexec/jlenv-installer +++ b/libexec/jlenv-installer @@ -3,7 +3,7 @@ # set -e -tag_name='1.0.0' +tag_name='1.0.1' homebrew= type -p brew >/dev/null && homebrew=1 From 562a11495470380115ee64ca62aa93eb747082e6 Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 5 Dec 2019 05:00:05 +1100 Subject: [PATCH 10/11] Remove shellcheck etc.d. --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5d47e34..4ff3fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,4 @@ sudo: false language: bash # Fail if any of these files have warnings script: - - shellcheck etc/jlenv.d/exec/* - shellcheck libexec/* \ No newline at end of file From 43af7f4072ea4fe90a732c0401a0ac9229a75f3d Mon Sep 17 00:00:00 2001 From: Mark Van de Vyver <1335713+taqtiqa-admin@users.noreply.github.com> Date: Thu, 2 Jan 2020 13:34:05 +1100 Subject: [PATCH 11/11] SC2230: Fix type in place of which. --- libexec/jlenv-doctor | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libexec/jlenv-doctor b/libexec/jlenv-doctor index 288d12a..8d85548 100755 --- a/libexec/jlenv-doctor +++ b/libexec/jlenv-doctor @@ -49,7 +49,7 @@ else fi echo -n "Checking for \`jlenv\` in PATH: " -num_locations="$(which -a jlenv | uniq | wc -l)" +num_locations="$(type -a jlenv | uniq | wc -l)" if [ "$num_locations" -eq 0 ]; then printc red "not found\n" { if [ -x ~/.jlenv/bin/jlenv ]; then @@ -62,13 +62,13 @@ if [ "$num_locations" -eq 0 ]; then } | indent exit 1 elif [ "$num_locations" -eq 1 ]; then - printc green "%s\n" "$(which jlenv)" + printc green "%s\n" "$(command -v jlenv)" else printc yellow "multiple\n" { echo "You seem to have multiple jlenv installs in the following locations." echo "Please pick just one installation and remove the others." echo - which -a jlenv + type -a jlenv } | indent echo : $((warnings++)) @@ -98,7 +98,7 @@ fi echo -n "Checking \`jlenv install' support: " jlenv_installs="$({ ls "$JLENV_ROOT"/plugins/*/bin/jlenv-install 2>/dev/null || true - which -a jlenv-install 2>/dev/null || true + type -a jlenv-install 2>/dev/null || true } | uniq)" num_installs="$(wc -l <<<"$jlenv_installs")" if [ -z "$jlenv_installs" ]; then