From e8806caf61f9b926fa78a879bf387bf78076bc5e Mon Sep 17 00:00:00 2001 From: Akash Manohar J Date: Sat, 13 Dec 2014 21:56:56 +0530 Subject: [PATCH] Fix installs; list command working --- lib/asdf.sh | 18 +++--------------- lib/asdf/utils.sh | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/asdf.sh b/lib/asdf.sh index 823d3848..a0669a38 100755 --- a/lib/asdf.sh +++ b/lib/asdf.sh @@ -36,7 +36,7 @@ install_command() { local version="${version_info[0]}" fi - local install_path=$(get_install_path $package $full_version) + local install_path=$(get_install_path $package $install_type $version) ${source_path}/bin/install $install_type $version $install_path "${@:3}" } @@ -63,20 +63,11 @@ uninstall_command() { local version="${version_info[0]}" fi - local install_path=$(get_install_path $package $full_version) + local install_path=$(get_install_path $package $install_type $version) ${source_path}/bin/uninstall $install_type $version $install_path "${@:3}" } -get_install_path() { - local package=$1 - local version=$2 - mkdir -p $(asdf_dir)/installs/${package} - - echo $(asdf_dir)/installs/${package}/${version} -} - - list_all_command() { local source_path=$(get_source_path $1) check_if_source_exists $source_path @@ -87,10 +78,7 @@ list_all_command() { list_command() { local source_path=$(get_source_path $1) check_if_source_exists $source_path - echo "TODO" - # echo ./$(asdf_dir)/sources/$1/list - #TODO list versions installed with the installs/erlang/.installs file - # the .installs file will have lines of the format "version hash" + list_package_installs $1 } diff --git a/lib/asdf/utils.sh b/lib/asdf/utils.sh index 9ed3a324..9f956964 100644 --- a/lib/asdf/utils.sh +++ b/lib/asdf/utils.sh @@ -22,6 +22,31 @@ run_callback_if_command() { } +list_package_installs() { + local package=$1 + local package_installs_path=$(asdf_dir)/installs/${package} + + if [ -d $package_installs_path ] + then + for install in ${package_installs_path}/*/; do + echo "$(basename $install)" + done + else + echo 'Oohes nooes ~! Nothing found' + fi +} + + +get_install_path() { + local package=$1 + local install_type=$2 + local version=$3 + mkdir -p $(asdf_dir)/installs/${package} + + echo $(asdf_dir)/installs/${package}/${install_type}-${version} +} + + check_if_source_exists() { if [ ! -d $1 ] then