mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1863 from YunoHost/fix_go_helper
helpers: goenv is broken when checking out latest master commit.
This commit is contained in:
commit
893e1230ef
1 changed files with 34 additions and 42 deletions
|
@ -111,43 +111,35 @@ ynh_install_go () {
|
||||||
test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv
|
test -x /usr/bin/go && mv /usr/bin/go /usr/bin/go_goenv
|
||||||
|
|
||||||
# Install or update goenv
|
# Install or update goenv
|
||||||
goenv="$(command -v goenv $goenv_install_dir/bin/goenv | head -1)"
|
mkdir -p $goenv_install_dir
|
||||||
if [ -n "$goenv" ]; then
|
pushd "$goenv_install_dir"
|
||||||
ynh_print_info --message="goenv already seems installed in \`$goenv'."
|
if ! [ -x "$goenv_install_dir/bin/goenv" ]; then
|
||||||
pushd "${goenv%/*/*}"
|
ynh_print_info --message="Downloading goenv..."
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/syndbg/goenv.git"; then
|
|
||||||
echo "Trying to update with Git..."
|
|
||||||
git pull -q --tags origin master
|
|
||||||
cd ..
|
|
||||||
ynh_go_try_bash_extension
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
else
|
|
||||||
ynh_print_info --message="Installing goenv with Git..."
|
|
||||||
mkdir -p $goenv_install_dir
|
|
||||||
pushd $goenv_install_dir
|
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/syndbg/goenv.git > /dev/null 2>&1
|
git remote add origin https://github.com/syndbg/goenv.git
|
||||||
git checkout -q -b master origin/master
|
else
|
||||||
ynh_go_try_bash_extension
|
ynh_print_info --message="Updating goenv..."
|
||||||
goenv=$goenv_install_dir/bin/goenv
|
fi
|
||||||
popd
|
git fetch -q --tags --prune origin
|
||||||
fi
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
|
git checkout -q "$git_latest_tag"
|
||||||
|
ynh_go_try_bash_extension
|
||||||
|
goenv=$goenv_install_dir/bin/goenv
|
||||||
|
popd
|
||||||
|
|
||||||
goenv_latest="$(command -v "$goenv_install_dir"/plugins/*/bin/goenv-latest goenv-latest | head -1)"
|
# Install or update xxenv-latest
|
||||||
if [ -n "$goenv_latest" ]; then
|
mkdir -p "$goenv_install_dir/plugins/xxenv-latest"
|
||||||
ynh_print_info --message="\`goenv latest' command already available in \`$goenv_latest'."
|
pushd "$goenv_install_dir/plugins/xxenv-latest"
|
||||||
pushd "${goenv_latest%/*/*}"
|
if ! [ -x "$goenv_install_dir/plugins/xxenv-latest/bin/goenv-latest" ]; then
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
ynh_print_info --message="Downloading xxenv-latest..."
|
||||||
ynh_print_info --message="Trying to update xxenv-latest with git..."
|
git init -q
|
||||||
git pull -q origin master
|
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
||||||
fi
|
else
|
||||||
popd
|
ynh_print_info --message="Updating xxenv-latest..."
|
||||||
else
|
fi
|
||||||
ynh_print_info --message="Installing xxenv-latest with Git..."
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
mkdir -p "${goenv_install_dir}/plugins"
|
git checkout -q "$git_latest_tag"
|
||||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${goenv_install_dir}/plugins/xxenv-latest"
|
popd
|
||||||
fi
|
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
mkdir -p "${goenv_install_dir}/cache"
|
mkdir -p "${goenv_install_dir}/cache"
|
||||||
|
@ -162,12 +154,12 @@ ynh_install_go () {
|
||||||
test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go
|
test -x /usr/bin/go_goenv && mv /usr/bin/go_goenv /usr/bin/go
|
||||||
|
|
||||||
# Install the requested version of Go
|
# Install the requested version of Go
|
||||||
local final_go_version=$(goenv latest --print $go_version)
|
local final_go_version=$(goenv latest --print "$go_version")
|
||||||
ynh_print_info --message="Installation of Go-$final_go_version"
|
ynh_print_info --message="Installation of Go-$final_go_version"
|
||||||
goenv install --skip-existing $final_go_version
|
goenv install --skip-existing "$final_go_version"
|
||||||
|
|
||||||
# Store go_version into the config of this app
|
# Store go_version into the config of this app
|
||||||
ynh_app_setting_set --app=$app --key=go_version --value=$final_go_version
|
ynh_app_setting_set --app="$app" --key="go_version" --value="$final_go_version"
|
||||||
|
|
||||||
# Cleanup Go versions
|
# Cleanup Go versions
|
||||||
ynh_cleanup_go
|
ynh_cleanup_go
|
||||||
|
@ -189,7 +181,7 @@ eval \"\$(goenv init -)\"
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_go
|
# usage: ynh_remove_go
|
||||||
ynh_remove_go () {
|
ynh_remove_go () {
|
||||||
local go_version=$(ynh_app_setting_get --app=$app --key=go_version)
|
local go_version=$(ynh_app_setting_get --app="$app" --key="go_version")
|
||||||
|
|
||||||
# Load goenv path in PATH
|
# Load goenv path in PATH
|
||||||
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$goenv_install_dir/bin:$PATH"
|
||||||
|
@ -198,7 +190,7 @@ ynh_remove_go () {
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
# Remove the line for this app
|
# Remove the line for this app
|
||||||
ynh_app_setting_delete --app=$app --key=go_version
|
ynh_app_setting_delete --app="$app" --key="go_version"
|
||||||
|
|
||||||
# Cleanup Go versions
|
# Cleanup Go versions
|
||||||
ynh_cleanup_go
|
ynh_cleanup_go
|
||||||
|
@ -224,7 +216,7 @@ ynh_cleanup_go () {
|
||||||
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Go versions
|
# Remove no more needed Go versions
|
||||||
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_go_version in $installed_go_versions
|
for installed_go_version in $installed_go_versions
|
||||||
|
@ -232,7 +224,7 @@ ynh_cleanup_go () {
|
||||||
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
||||||
then
|
then
|
||||||
ynh_print_info --message="Removing of Go-$installed_go_version"
|
ynh_print_info --message="Removing of Go-$installed_go_version"
|
||||||
$goenv_install_dir/bin/goenv uninstall --force $installed_go_version
|
$goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue