Add support for installing versions like foo, tag:foo and commit:foo

This commit is contained in:
Akash Manohar J 2014-11-30 14:13:07 +05:30
parent 87b548a46d
commit 281aaf705d
2 changed files with 54 additions and 18 deletions

View File

@ -14,16 +14,28 @@ run_command() {
install_command() {
local package=$1
local version=$2
local full_version=$2
local source_path=$(get_source_path $package)
check_if_source_exists $source_path
IFS=':' read -a version_info <<< "$full_version"
if [ "${version_info[0]}" -e "tag" ] || [ "${version_info[0]}" -e "commit" ]
then
local install_type="${version_info[0]}"
local version="${version_info[1]}"
else
local install_type="version"
local version="${version_info[0]}"
fi
local install_path=$(get_install_path $package $version)
${source_path}/install $version $install_path "${@:3}"
${source_path}/install $install_type $version $install_path "${@:3}"
if [ $? -e 0 ]
then
echo "$version $(basename $install_path)" >> $(dirname $install_path)/.versions
#TODO create shims for new version
else
exit 1
fi

View File

@ -1,19 +1,23 @@
#!/usr/bin/env sh
install_erlang() {
local version=$1
local install_path=$2
local source_path=$(get_download_file_path $1)
local install_type=$1
local version=$2
local install_path=$3
local source_path=$(get_download_file_path $install_type $version)
download_git_source $1
download_source $install_type $version
# running this in a subshell
# because we don't want to disturb current working dir
(
cd $(dirname $source_path)
tar zxf $source_path || exit 1
cd $(untar_path $1)
./otp_build autoconf || exit 1
cd $(untar_path $install_type $version)
if [ "$install_type" -ne "version"]
then
./otp_build autoconf || exit 1
fi
./configure --prefix=$install_path || exit 1
make || exit 1
make install || exit 1
@ -22,27 +26,47 @@ install_erlang() {
untar_path() {
local version=$1
echo "$TMPDIR/otp-OTP-$1"
local install_type=$1
local version=$2
if [ "$install_type" -e "version" ]
then
echo "$TMPDIR/otp_src_${version}"
else
echo "$TMPDIR/otp-${version}"
fi
}
download_git_source() {
curl -Lo $(get_download_file_path $1) $(get_github_download_url $1)
download_source() {
local install_type=$1
local version=$2
local download_path=$(get_download_file_path $install_type $version)
local download_url=$(get_download_url $install_type $version)
curl -Lo $download_path $download_url
}
get_download_file_path() {
local version=$1
local pkg_name="otp-$1.tar.gz"
local install_type=$1
local version=$2
local pkg_name="otp-${install_type}-${version}-src.tar.gz"
echo "$TMPDIR$pkg_name"
}
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"
get_download_url() {
local install_type=$1
local version=$2
if [ "$install_type" -e "version" ]
then
echo "http://www.erlang.org/download/otp_src_${version}.tar.gz"
else
echo "https://github.com/erlang/otp/archive/${version}.tar.gz"
fi
}