aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsanmiguel <[email protected]>2017-02-18 14:41:11 +0100
committersanmiguel <[email protected]>2017-02-18 14:41:11 +0100
commit0adce8690bd703d08c4c1af6d19d67ab78ff8bd8 (patch)
tree75a317375e95a199101010d72e298552183be8c6
parent7ec1f8e0463b99ada8cc85de098b7aa9e6ab3f04 (diff)
parent0daeaa064d20dd3f72d4df6c105deba8e24c4543 (diff)
downloadkerl-0adce8690bd703d08c4c1af6d19d67ab78ff8bd8.tar.gz
kerl-0adce8690bd703d08c4c1af6d19d67ab78ff8bd8.tar.bz2
kerl-0adce8690bd703d08c4c1af6d19d67ab78ff8bd8.zip
Merge branch 'get_active_path-cli' into enable-travis-ci
-rw-r--r--README.md6
-rw-r--r--bash_completion/kerl9
-rwxr-xr-xkerl47
-rw-r--r--zsh_completion/_kerl14
4 files changed, 71 insertions, 5 deletions
diff --git a/README.md b/README.md
index b67bab8..5f7dfb1 100644
--- a/README.md
+++ b/README.md
@@ -598,6 +598,12 @@ will honor that instead, and will not do any automatic configuration.
Changelog
---------
+12 February 2017 - 1.4.1
+
+ - Fix reading a checksum file for compile options (#180)
+ - Get a little smarter about figuring out what apps to use
+ when building a PLT file for dialyzer (#181)
+
5 February 2017 - 1.4.0
- Fix environment variable handling and a typo (#179)
diff --git a/bash_completion/kerl b/bash_completion/kerl
index 689463d..d620a4d 100644
--- a/bash_completion/kerl
+++ b/bash_completion/kerl
@@ -12,7 +12,7 @@ _kerl()
case $prev in
kerl)
- COMPREPLY=( $( compgen -W "build install update list delete active status" -- "$cur" ) )
+ COMPREPLY=( $( compgen -W "build install update list delete active path status" -- "$cur" ) )
;;
list)
COMPREPLY=( $( compgen -W "releases builds installations" -- "$cur" ) )
@@ -42,6 +42,13 @@ _kerl()
fi
COMPREPLY=( $( compgen -W "$BUILDS" -- "$cur") )
;;
+ path)
+ INSTALL_LIST="$HOME"/.kerl/otp_installations
+ if [ -f "$INSTALL_LIST" ]; then
+ NAMES=$(cut -d ' ' -f 2 "$INSTALL_LIST" | xargs basename)
+ fi
+ COMPREPLY=( $( compgen -W "$NAMES" -- "$cur") )
+ ;;
deploy)
if [ "$COMP_CWORD" -eq 3 ]; then
if [ -f "$HOME"/.kerl/otp_installations ]; then
diff --git a/kerl b/kerl
index 090021d..2ea08e4 100755
--- a/kerl
+++ b/kerl
@@ -171,7 +171,7 @@ usage()
{
echo "kerl: build and install Erlang/OTP"
echo "usage: $0 <command> [options ...]"
- printf "\n <command> Command to be executed\n\n"
+ echo "\n <command> Command to be executed\n\n"
echo "Valid commands are:"
echo " build Build specified release or git repository"
echo " install Install the specified release at the given location"
@@ -588,7 +588,7 @@ _do_build()
# Check for a .kerl_config.md5 file
if [ -e "./$KERL_CONFIG_STORAGE_FILENAME.md5" ]; then
# Compare our current options to the saved ones
- OLD_SUM=read -r < "./$KERL_CONFIG_STORAGE_FILENAME.md5"
+ OLD_SUM=$(read -r < "./$KERL_CONFIG_STORAGE_FILENAME.md5")
if [ "$SUM" -ne "$OLD_SUM" ]; then
echo "Configure options have changed. Reconfiguring..."
rm -f configure
@@ -946,8 +946,9 @@ build_plt()
plt=$dialyzerd/plt
build_log=$dialyzerd/build.log
dialyzer=$1/bin/dialyzer
- apps=`ls -1 $1/lib | cut -d- -f1 | grep -Ev 'erl_interface|jinterface' | xargs echo`
- $dialyzer --output_plt $plt --build_plt --apps $apps > $build_log 2>&1
+ dirs=`find $1/lib -maxdepth 2 -name ebin -type d -exec dirname {} \;`
+ apps=`for app in $dirs; do basename $app | cut -d- -f1 ; done | grep -Ev 'erl_interface|jinterface' | xargs echo`
+ $dialyzer --output_plt $plt --build_plt --apps $apps >> $build_log 2>&1
status=$?
if [ $status -eq 0 -o $status -eq 2 ]; then
echo "Done building $plt"
@@ -1228,6 +1229,11 @@ list_has()
return 1
}
+path_usage()
+{
+ echo "usage: $0 path [<install_name>]"
+}
+
list_usage()
{
echo "usage: $0 list <releases|builds|installations>"
@@ -1548,6 +1554,39 @@ case "$1" in
;;
esac
;;
+ path)
+ # Usage:
+ # kerl path
+ # # Print currently active installation path, else non-zero exit
+ # kerl path <install>
+ # Print path to installation with name <install>, else non-zero exit
+ if [ -z "$2" ]; then
+ activepath=$(get_active_path)
+ if [ -z "$activepath" ]; then
+ echo "No active kerl-managed erlang installation"
+ exit 1
+ fi
+ echo "$activepath"
+ else
+ # There are some possible extensions to this we could
+ # consider, such as:
+ # - if 2+ matches: prefer one in a subdir from $PWD
+ # - prefer $KERL_DEFAULT_INSTALL_DIR
+ match=
+ for ins in $(list_print installations | cut -d' ' -f2); do
+ if [ "$(basename $ins)" = "$2" ]; then
+ if [ -z "$match" ]; then
+ match="$ins"
+ else
+ echo "Error: too many matching installations" >&2
+ exit 2
+ fi
+ fi
+ done
+ [ -n "$match" ] && echo "$match" && exit 0
+ echo "Error: no matching installation found" >&2 && exit 1
+ fi
+ ;;
delete)
if [ $# -ne 3 ]; then
delete_usage
diff --git a/zsh_completion/_kerl b/zsh_completion/_kerl
index e58eb8b..7c9f0d6 100644
--- a/zsh_completion/_kerl
+++ b/zsh_completion/_kerl
@@ -30,6 +30,10 @@ _kerl_installations() {
installations=(${(f)"$(_call_program installations kerl list installations 2>/dev/null | cut -f 2 -d " ")"})
}
+_kerl_installnames() {
+ installnames=(${(f)"$(_call_program installations kerl list installations 2>/dev/null | cut -f 2 -d " " | xargs basename)"})
+}
+
local -a _1st_arguments
_1st_arguments=(
'build:Build specified release or git repository'
@@ -39,6 +43,7 @@ _1st_arguments=(
'list:List releases, builds and installations'
'delete:Delete builds and installations'
'active:Print the path of the active installation'
+ 'path:Print the path of any installation'
'status:Print available builds and installations'
'prompt:Print a string suitable for insertion in prompt'
'cleanup:Remove compilation artifacts (use after installation)'
@@ -96,6 +101,15 @@ case "$words[1]" in
# TODO: suggest starting location of "$KERLDIR/$(lowercase $build)"
_directories
;;
+ path)
+ _arguments \
+ '1: :->installnames' && return 0
+ if [[ "$state" == installnames ]]; then
+ _kerl_installnames
+ _wanted installnames expl '' compadd -a installnames
+ return
+ fi
+ ;;
deploy)
_arguments \
'1: :->hosts' \