mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
helpers2.1: var rename / cosmetic etc for nodejs/ruby/go version and install directories
This commit is contained in:
parent
5f6df6a859
commit
2b1f74268f
3 changed files with 75 additions and 76 deletions
|
@ -8,19 +8,18 @@ ynh_go_try_bash_extension() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
goenv_install_dir="/opt/goenv"
|
readonly GOENV_INSTALL_DIR="/opt/goenv"
|
||||||
go_version_path="$goenv_install_dir/versions"
|
|
||||||
# goenv_ROOT is the directory of goenv, it needs to be loaded as a environment variable.
|
# goenv_ROOT is the directory of goenv, it needs to be loaded as a environment variable.
|
||||||
export GOENV_ROOT="$goenv_install_dir"
|
export GOENV_ROOT="$GOENV_INSTALL_DIR"
|
||||||
|
|
||||||
_ynh_load_go_in_path_and_other_tweaks() {
|
_ynh_load_go_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Get the absolute path of this version of go
|
# Get the absolute path of this version of go
|
||||||
local go_path="$go_version_path/$app/bin"
|
go_dir="$GOENV_INSTALL_DIR/versions/$app/bin"
|
||||||
|
|
||||||
# Load the path of this version of go in $PATH
|
# Load the path of this version of go in $PATH
|
||||||
if [[ :$PATH: != *":$go_path"* ]]; then
|
if [[ :$PATH: != *":$go_dir"* ]]; then
|
||||||
PATH="$go_path:$PATH"
|
PATH="$go_dir:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
||||||
|
@ -32,7 +31,7 @@ _ynh_load_go_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Sets the local application-specific go version
|
# Sets the local application-specific go version
|
||||||
pushd ${install_dir}
|
pushd ${install_dir}
|
||||||
$goenv_install_dir/bin/goenv local $go_version
|
$GOENV_INSTALL_DIR/bin/goenv local $go_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +55,7 @@ ynh_go_install () {
|
||||||
[[ -n "${go_version:-}" ]] || ynh_die "\$go_version should be defined prior to calling ynh_go_install"
|
[[ -n "${go_version:-}" ]] || ynh_die "\$go_version should be defined prior to calling ynh_go_install"
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Go prior installation
|
# Remove /usr/local/bin in PATH in case of Go prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
@ -65,9 +64,9 @@ ynh_go_install () {
|
||||||
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
|
||||||
mkdir -p $goenv_install_dir
|
mkdir -p $GOENV_INSTALL_DIR
|
||||||
pushd "$goenv_install_dir"
|
pushd "$GOENV_INSTALL_DIR"
|
||||||
if ! [ -x "$goenv_install_dir/bin/goenv" ]; then
|
if ! [ -x "$GOENV_INSTALL_DIR/bin/goenv" ]; then
|
||||||
ynh_print_info "Downloading goenv..."
|
ynh_print_info "Downloading goenv..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/syndbg/goenv.git
|
git remote add origin https://github.com/syndbg/goenv.git
|
||||||
|
@ -78,13 +77,13 @@ ynh_go_install () {
|
||||||
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
git checkout -q "$git_latest_tag"
|
git checkout -q "$git_latest_tag"
|
||||||
ynh_go_try_bash_extension
|
ynh_go_try_bash_extension
|
||||||
goenv=$goenv_install_dir/bin/goenv
|
goenv=$GOENV_INSTALL_DIR/bin/goenv
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Install or update xxenv-latest
|
# Install or update xxenv-latest
|
||||||
mkdir -p "$goenv_install_dir/plugins/xxenv-latest"
|
mkdir -p "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
||||||
pushd "$goenv_install_dir/plugins/xxenv-latest"
|
pushd "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
||||||
if ! [ -x "$goenv_install_dir/plugins/xxenv-latest/bin/goenv-latest" ]; then
|
if ! [ -x "$GOENV_INSTALL_DIR/plugins/xxenv-latest/bin/goenv-latest" ]; then
|
||||||
ynh_print_info "Downloading xxenv-latest..."
|
ynh_print_info "Downloading xxenv-latest..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
||||||
|
@ -97,10 +96,10 @@ ynh_go_install () {
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
mkdir -p "${goenv_install_dir}/cache"
|
mkdir -p "${GOENV_INSTALL_DIR}/cache"
|
||||||
|
|
||||||
# Create shims directory if needed
|
# Create shims directory if needed
|
||||||
mkdir -p "${goenv_install_dir}/shims"
|
mkdir -p "${GOENV_INSTALL_DIR}/shims"
|
||||||
|
|
||||||
# Restore /usr/local/bin in PATH
|
# Restore /usr/local/bin in PATH
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
@ -122,8 +121,8 @@ ynh_go_install () {
|
||||||
|
|
||||||
# Set environment for Go users
|
# Set environment for Go users
|
||||||
echo "#goenv
|
echo "#goenv
|
||||||
export GOENV_ROOT=$goenv_install_dir
|
export GOENV_ROOT=$GOENV_INSTALL_DIR
|
||||||
export PATH=\"$goenv_install_dir/bin:$PATH\"
|
export PATH=\"$GOENV_INSTALL_DIR/bin:$PATH\"
|
||||||
eval \"\$(goenv init -)\"
|
eval \"\$(goenv init -)\"
|
||||||
#goenv" > /etc/profile.d/goenv.sh
|
#goenv" > /etc/profile.d/goenv.sh
|
||||||
|
|
||||||
|
@ -142,7 +141,7 @@ ynh_go_remove () {
|
||||||
local go_version=$(ynh_app_setting_get --key="go_version")
|
local go_version=$(ynh_app_setting_get --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"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Go prior installation
|
# Remove /usr/local/bin in PATH in case of Go prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
@ -182,7 +181,7 @@ _ynh_go_cleanup () {
|
||||||
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 "Removing of Go-$installed_go_version"
|
ynh_print_info "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
|
||||||
|
|
||||||
|
@ -191,7 +190,7 @@ _ynh_go_cleanup () {
|
||||||
then
|
then
|
||||||
# Remove goenv environment configuration
|
# Remove goenv environment configuration
|
||||||
ynh_print_info "Removing of goenv"
|
ynh_print_info "Removing of goenv"
|
||||||
ynh_safe_rm "$goenv_install_dir"
|
ynh_safe_rm "$GOENV_INSTALL_DIR"
|
||||||
ynh_safe_rm "/etc/profile.d/goenv.sh"
|
ynh_safe_rm "/etc/profile.d/goenv.sh"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
n_install_dir="/opt/node_n"
|
readonly N_INSTALL_DIR="/opt/node_n"
|
||||||
node_version_path="$n_install_dir/n/versions/node"
|
|
||||||
# N_PREFIX is the directory of n, it needs to be loaded as a environment variable.
|
# N_PREFIX is the directory of n, it needs to be loaded as a environment variable.
|
||||||
export N_PREFIX="$n_install_dir"
|
export N_PREFIX="$N_INSTALL_DIR"
|
||||||
|
|
||||||
_ynh_load_nodejs_in_path_and_other_tweaks() {
|
_ynh_load_nodejs_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Get the absolute path of this version of node
|
# Get the absolute path of this version of node
|
||||||
local nodejs_path="$node_version_path/$nodejs_version/bin"
|
nodejs_dir="$N_INSTALL_DIR/n/versions/node/$nodejs_version/bin"
|
||||||
|
|
||||||
# Load the path of this version of node in $PATH
|
# Load the path of this version of node in $PATH
|
||||||
if [[ :$PATH: != *":$nodejs_path"* ]]; then
|
if [[ :$PATH: != *":$nodejs_dir"* ]]; then
|
||||||
PATH="$nodejs_path:$PATH"
|
PATH="$nodejs_dir:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
||||||
|
@ -46,11 +45,11 @@ ynh_nodejs_install() {
|
||||||
|
|
||||||
[[ -n "${nodejs_version:-}" ]] || ynh_die "\$nodejs_version should be defined prior to calling ynh_nodejs_install"
|
[[ -n "${nodejs_version:-}" ]] || ynh_die "\$nodejs_version should be defined prior to calling ynh_nodejs_install"
|
||||||
|
|
||||||
# Create $n_install_dir
|
# Create $N_INSTALL_DIR
|
||||||
mkdir --parents "$n_install_dir"
|
mkdir --parents "$N_INSTALL_DIR"
|
||||||
|
|
||||||
# Load n path in PATH
|
# Load n path in PATH
|
||||||
CLEAR_PATH="$n_install_dir/bin:$PATH"
|
CLEAR_PATH="$N_INSTALL_DIR/bin:$PATH"
|
||||||
# Remove /usr/local/bin in PATH in case of node prior installation
|
# Remove /usr/local/bin in PATH in case of node prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
|
||||||
|
@ -59,10 +58,10 @@ ynh_nodejs_install() {
|
||||||
test -x /usr/bin/npm && mv /usr/bin/npm /usr/bin/npm_n
|
test -x /usr/bin/npm && mv /usr/bin/npm /usr/bin/npm_n
|
||||||
|
|
||||||
# Install (or update if YunoHost vendor/ folder updated since last install) n
|
# Install (or update if YunoHost vendor/ folder updated since last install) n
|
||||||
mkdir -p $n_install_dir/bin/
|
mkdir -p $N_INSTALL_DIR/bin/
|
||||||
cp "$YNH_HELPERS_DIR/vendor/n/n" $n_install_dir/bin/n
|
cp "$YNH_HELPERS_DIR/vendor/n/n" $N_INSTALL_DIR/bin/n
|
||||||
# Tweak for n to understand it's installed in $N_PREFIX
|
# Tweak for n to understand it's installed in $N_PREFIX
|
||||||
ynh_replace --match="^N_PREFIX=\${N_PREFIX-.*}$" --replace="N_PREFIX=\${N_PREFIX-$N_PREFIX}" --file="$n_install_dir/bin/n"
|
ynh_replace --match="^N_PREFIX=\${N_PREFIX-.*}$" --replace="N_PREFIX=\${N_PREFIX-$N_PREFIX}" --file="$N_INSTALL_DIR/bin/n"
|
||||||
|
|
||||||
# Restore /usr/local/bin in PATH
|
# Restore /usr/local/bin in PATH
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
@ -80,16 +79,18 @@ ynh_nodejs_install() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Find the last "real" version for this major version of node.
|
# Find the last "real" version for this major version of node.
|
||||||
real_nodejs_version=$(find $node_version_path/$nodejs_version* -maxdepth 0 | sort --version-sort | tail --lines=1)
|
real_nodejs_version=$(find $N_INSTALL_DIR/n/versions/node/$nodejs_version* -maxdepth 0 | sort --version-sort | tail --lines=1)
|
||||||
real_nodejs_version=$(basename $real_nodejs_version)
|
real_nodejs_version=$(basename $real_nodejs_version)
|
||||||
|
|
||||||
# Create a symbolic link for this major version if the file doesn't already exist
|
# Create a symbolic link for this major version if the file doesn't already exist
|
||||||
if [ ! -e "$node_version_path/$nodejs_version" ]; then
|
if [ ! -e "$N_INSTALL_DIR/n/versions/node/$nodejs_version" ]; then
|
||||||
ln --symbolic --force --no-target-directory $node_version_path/$real_nodejs_version $node_version_path/$nodejs_version
|
ln --symbolic --force --no-target-directory \
|
||||||
|
$N_INSTALL_DIR/n/versions/node/$real_nodejs_version \
|
||||||
|
$N_INSTALL_DIR/n/versions/node/$nodejs_version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Store the ID of this app and the version of node requested for it
|
# Store the ID of this app and the version of node requested for it
|
||||||
echo "$YNH_APP_INSTANCE_NAME:$nodejs_version" | tee --append "$n_install_dir/ynh_app_version"
|
echo "$YNH_APP_INSTANCE_NAME:$nodejs_version" | tee --append "$N_INSTALL_DIR/ynh_app_version"
|
||||||
|
|
||||||
# Store nodejs_version into the config of this app
|
# Store nodejs_version into the config of this app
|
||||||
ynh_app_setting_set --key=nodejs_version --value=$nodejs_version
|
ynh_app_setting_set --key=nodejs_version --value=$nodejs_version
|
||||||
|
@ -111,17 +112,16 @@ ynh_nodejs_remove() {
|
||||||
[[ -n "${nodejs_version:-}" ]] || ynh_die "\$nodejs_version should be defined prior to calling ynh_nodejs_remove"
|
[[ -n "${nodejs_version:-}" ]] || ynh_die "\$nodejs_version should be defined prior to calling ynh_nodejs_remove"
|
||||||
|
|
||||||
# Remove the line for this app
|
# Remove the line for this app
|
||||||
sed --in-place "/$YNH_APP_INSTANCE_NAME:$nodejs_version/d" "$n_install_dir/ynh_app_version"
|
sed --in-place "/$YNH_APP_INSTANCE_NAME:$nodejs_version/d" "$N_INSTALL_DIR/ynh_app_version"
|
||||||
|
|
||||||
# If no other app uses this version of nodejs, remove it.
|
# If no other app uses this version of nodejs, remove it.
|
||||||
if ! grep --quiet "$nodejs_version" "$n_install_dir/ynh_app_version"; then
|
if ! grep --quiet "$nodejs_version" "$N_INSTALL_DIR/ynh_app_version"; then
|
||||||
$n_install_dir/bin/n rm $nodejs_version
|
$N_INSTALL_DIR/bin/n rm $nodejs_version
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no other app uses n, remove n
|
# If no other app uses n, remove n
|
||||||
if [ ! -s "$n_install_dir/ynh_app_version" ]; then
|
if [ ! -s "$N_INSTALL_DIR/ynh_app_version" ]; then
|
||||||
ynh_safe_rm "$n_install_dir"
|
ynh_safe_rm "$N_INSTALL_DIR"
|
||||||
ynh_safe_rm "/usr/local/n"
|
|
||||||
sed --in-place "/N_PREFIX/d" /root/.bashrc
|
sed --in-place "/N_PREFIX/d" /root/.bashrc
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
rbenv_install_dir="/opt/rbenv"
|
readonly RBENV_INSTALL_DIR="/opt/rbenv"
|
||||||
ruby_version_path="$rbenv_install_dir/versions"
|
|
||||||
|
|
||||||
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
|
# RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable.
|
||||||
export RBENV_ROOT="$rbenv_install_dir"
|
export RBENV_ROOT="$RBENV_INSTALL_DIR"
|
||||||
export rbenv_root="$rbenv_install_dir"
|
export rbenv_root="$RBENV_INSTALL_DIR"
|
||||||
|
|
||||||
_ynh_load_ruby_in_path_and_other_tweaks() {
|
_ynh_load_ruby_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Get the absolute path of this version of Ruby
|
# Get the absolute path of this version of Ruby
|
||||||
local ruby_path="$ruby_version_path/$app/bin"
|
ruby_dir="$RBENV_INSTALL_DIR/versions/$app/bin"
|
||||||
|
|
||||||
# Load the path of this version of ruby in $PATH
|
# Load the path of this version of ruby in $PATH
|
||||||
if [[ :$PATH: != *":$ruby_path"* ]]; then
|
if [[ :$PATH: != *":$ruby_dir"* ]]; then
|
||||||
PATH="$ruby_path:$PATH"
|
PATH="$ruby_dir:$PATH"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
# Export PATH such that it's available through sudo -E / ynh_exec_as $app
|
||||||
|
@ -26,7 +25,7 @@ _ynh_load_ruby_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Sets the local application-specific Ruby version
|
# Sets the local application-specific Ruby version
|
||||||
pushd ${install_dir}
|
pushd ${install_dir}
|
||||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
$RBENV_INSTALL_DIR/bin/rbenv local $ruby_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +54,7 @@ ynh_ruby_install () {
|
||||||
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_install"
|
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_install"
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$RBENV_INSTALL_DIR/bin:$PATH"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
@ -64,8 +63,8 @@ ynh_ruby_install () {
|
||||||
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv
|
||||||
|
|
||||||
# Install or update rbenv
|
# Install or update rbenv
|
||||||
mkdir -p $rbenv_install_dir
|
mkdir -p $RBENV_INSTALL_DIR
|
||||||
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
rbenv="$(command -v rbenv $RBENV_INSTALL_DIR/bin/rbenv | grep "$RBENV_INSTALL_DIR/bin/rbenv" | head -1)"
|
||||||
if [ -n "$rbenv" ]; then
|
if [ -n "$rbenv" ]; then
|
||||||
pushd "${rbenv%/*/*}"
|
pushd "${rbenv%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||||
|
@ -75,30 +74,30 @@ ynh_ruby_install () {
|
||||||
else
|
else
|
||||||
echo "Reinstalling rbenv..."
|
echo "Reinstalling rbenv..."
|
||||||
cd ..
|
cd ..
|
||||||
ynh_safe_rm $rbenv_install_dir
|
ynh_safe_rm $RBENV_INSTALL_DIR
|
||||||
mkdir -p $rbenv_install_dir
|
mkdir -p $RBENV_INSTALL_DIR
|
||||||
cd $rbenv_install_dir
|
cd $RBENV_INSTALL_DIR
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing rbenv..."
|
echo "Installing rbenv..."
|
||||||
pushd $rbenv_install_dir
|
pushd $RBENV_INSTALL_DIR
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "${rbenv_install_dir}/plugins"
|
mkdir -p "${RBENV_INSTALL_DIR}/plugins"
|
||||||
|
|
||||||
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
ruby_build="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||||
if [ -n "$ruby_build" ]; then
|
if [ -n "$ruby_build" ]; then
|
||||||
pushd "${ruby_build%/*/*}"
|
pushd "${ruby_build%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||||
|
@ -108,10 +107,10 @@ ynh_ruby_install () {
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing ruby-build..."
|
echo "Installing ruby-build..."
|
||||||
git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build"
|
git clone -q https://github.com/rbenv/ruby-build.git "${RBENV_INSTALL_DIR}/plugins/ruby-build"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
rbenv_alias="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||||
if [ -n "$rbenv_alias" ]; then
|
if [ -n "$rbenv_alias" ]; then
|
||||||
pushd "${rbenv_alias%/*/*}"
|
pushd "${rbenv_alias%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||||
|
@ -121,10 +120,10 @@ ynh_ruby_install () {
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing rbenv-aliases..."
|
echo "Installing rbenv-aliases..."
|
||||||
git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase"
|
git clone -q https://github.com/tpope/rbenv-aliases.git "${RBENV_INSTALL_DIR}/plugins/rbenv-aliase"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
rbenv_latest="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||||
if [ -n "$rbenv_latest" ]; then
|
if [ -n "$rbenv_latest" ]; then
|
||||||
pushd "${rbenv_latest%/*/*}"
|
pushd "${rbenv_latest%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||||
|
@ -134,14 +133,14 @@ ynh_ruby_install () {
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing xxenv-latest..."
|
echo "Installing xxenv-latest..."
|
||||||
git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest"
|
git clone -q https://github.com/momo-lab/xxenv-latest.git "${RBENV_INSTALL_DIR}/plugins/xxenv-latest"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
mkdir -p "${rbenv_install_dir}/cache"
|
mkdir -p "${RBENV_INSTALL_DIR}/cache"
|
||||||
|
|
||||||
# Create shims directory if needed
|
# Create shims directory if needed
|
||||||
mkdir -p "${rbenv_install_dir}/shims"
|
mkdir -p "${RBENV_INSTALL_DIR}/shims"
|
||||||
|
|
||||||
# Restore /usr/local/bin in PATH
|
# Restore /usr/local/bin in PATH
|
||||||
PATH=$CLEAR_PATH
|
PATH=$CLEAR_PATH
|
||||||
|
@ -175,8 +174,8 @@ ynh_ruby_install () {
|
||||||
|
|
||||||
# Set environment for Ruby users
|
# Set environment for Ruby users
|
||||||
echo "#rbenv
|
echo "#rbenv
|
||||||
export RBENV_ROOT=$rbenv_install_dir
|
export RBENV_ROOT=$RBENV_INSTALL_DIR
|
||||||
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
export PATH=\"$RBENV_INSTALL_DIR/bin:$PATH\"
|
||||||
eval \"\$(rbenv init -)\"
|
eval \"\$(rbenv init -)\"
|
||||||
#rbenv" > /etc/profile.d/rbenv.sh
|
#rbenv" > /etc/profile.d/rbenv.sh
|
||||||
|
|
||||||
|
@ -192,10 +191,11 @@ eval \"\$(rbenv init -)\"
|
||||||
#
|
#
|
||||||
# usage: ynh_ruby_remove
|
# usage: ynh_ruby_remove
|
||||||
ynh_ruby_remove () {
|
ynh_ruby_remove () {
|
||||||
local ruby_version=$(ynh_app_setting_get --key=ruby_version)
|
|
||||||
|
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_remove"
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
local CLEAR_PATH="$rbenv_install_dir/bin:$PATH"
|
local CLEAR_PATH="$RBENV_INSTALL_DIR/bin:$PATH"
|
||||||
|
|
||||||
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
# Remove /usr/local/bin in PATH in case of Ruby prior installation
|
||||||
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@')
|
||||||
|
@ -235,7 +235,7 @@ _ynh_ruby_cleanup () {
|
||||||
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
||||||
then
|
then
|
||||||
echo "Removing Ruby-$installed_ruby_version"
|
echo "Removing Ruby-$installed_ruby_version"
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
$RBENV_INSTALL_DIR/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ _ynh_ruby_cleanup () {
|
||||||
then
|
then
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
echo "Removing rbenv"
|
echo "Removing rbenv"
|
||||||
ynh_safe_rm "$rbenv_install_dir"
|
ynh_safe_rm "$RBENV_INSTALL_DIR"
|
||||||
ynh_safe_rm "/etc/profile.d/rbenv.sh"
|
ynh_safe_rm "/etc/profile.d/rbenv.sh"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue