WIP: erlang package

This commit is contained in:
Akash Manohar J 2014-11-30 00:01:37 +05:30
parent d5f19e8bd0
commit 32fe431ae6
3 changed files with 75 additions and 10 deletions

View File

@ -1,11 +1,3 @@
#!/usr/bin/env sh
#TODO run command with args
#TODO decide which function to run based on args
ASDF_DIR=$(dirname $0)
run_command() {
run_callback_if_command "--version" $1 asdf_version "${@:2}"
run_callback_if_command "install" $1 install_command "${@:2}"
@ -20,12 +12,25 @@ run_command() {
install_command() {
local source_path=$(get_source_path $1)
local package=$1
local version=$2
local source_path=$(get_source_path $package)
check_if_source_exists $source_path
echo "TODO"
local install_path=$(get_install_path $package $version)
./${source_path}/install $version $install_path "${@:3}"
}
get_install_path() {
local package=$1
local versio=$2
mkdir -p $(asdf_dir)/installs/$package
echo $(asdf_dir)/installs/$package/$(generate_random_hash)
}
list_all_command() {
local source_path=$(get_source_path $1)

View File

@ -8,6 +8,11 @@ asdf_dir() {
}
generate_random_hash() {
openssl rand -hex 4
}
run_callback_if_command() {
if [ "$1" = "$2" ]
then

55
sources/erlang/install Executable file
View File

@ -0,0 +1,55 @@
#!/usr/bin/env sh
install_erlang() {
local version=$1
local install_path=$2
local source_path=$(get_download_file_path $1)
# download_git_source $1
cp ~/projects/asdf/tryout/otp-17.3.4.tar.gz $TMPDIR/
# running this in a subshell
# because we don't want to disturb current working dir
echo
(
cd $(dirname $source_path)
tar zxf $source_path
cd $(untar_path $1)
./otp_build autoconf
pwd
echo $install_path
./configure --prefix=$install_path
# make
# make install
)
}
untar_path() {
local version=$1
echo "$TMPDIR/otp-OTP-$1"
}
download_git_source() {
curl -Lo $(get_download_file_path $1) $(get_github_download_url $1)
}
get_download_file_path() {
local version=$1
echo "$TMPDIR/otp-$1.tar.gz"
}
get_github_download_url() {
local version=$1
#TODO support downloading tags, branches and commits
echo "https://github.com/erlang/otp/archive/OTP-${$1}.tar.gz"
}
install_erlang $@