Skip to content

Commit

Permalink
fix man path for multiuser installations, fix #998
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapis committed Aug 10, 2012
1 parent d45fcff commit dbd4210
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 10 deletions.
21 changes: 15 additions & 6 deletions binscripts/rvm-installer
Expand Up @@ -8,9 +8,11 @@ then
exit 1
fi

export HOME PS4
export rvm_trace_flag rvm_debug_flag rvm_user_install_flag rvm_ignore_rvmrc rvm_prefix rvm_path

shopt -s extglob
PS4="+ \${BASH_SOURCE##\${rvm_path:-}} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
export PS4
set -o errtrace
set -o errexit

Expand Down Expand Up @@ -174,7 +176,7 @@ Could not download '${_url}'.
if [[ "$*" =~ --trace ]] || (( ${rvm_trace_flag:-0} > 0 ))
then
set -o xtrace
export rvm_trace_flag=1
rvm_trace_flag=1
fi

# Variable initialization, remove trailing slashes if they exist on HOME
Expand Down Expand Up @@ -208,12 +210,19 @@ if [[ -z "${rvm_path:-}" ]]
then
if (( UID == 0 ))
then
rvm_path="/usr/local/rvm"
rvm_user_install_flag=0
rvm_prefix="/usr/local"
rvm_path="${rvm_prefix}/rvm"
else
rvm_path="${HOME}/.rvm"
rvm_user_install_flag=1
rvm_prefix="$HOME"
rvm_path="${rvm_prefix}/.rvm"
fi
fi
export HOME rvm_path
if [[ -z "${rvm_prefix}" ]]
then
rvm_prefix=$( dirname $rvm_path )
fi

install_rubies=()
install_gems=()
Expand All @@ -226,7 +235,7 @@ do

--trace)
set -o xtrace
export rvm_trace_flag=1
rvm_trace_flag=1
;;

--path)
Expand Down
21 changes: 18 additions & 3 deletions scripts/functions/installer
Expand Up @@ -50,6 +50,8 @@ install_setup()
PATH="${rvm_user_path_prefix}:$PATH"
fi

true ${rvm_group_name:=rvm}

# TODO: Figure out a much better name for 'rvm_user_install_flag'
# mpapis: self contained was a quite good name
if (( UID == 0 )) ||
Expand Down Expand Up @@ -618,6 +620,16 @@ correct_binary_permissions()
done
}

get_file_group()
{
case "$(uname)" in
"Darwin") stat -f "%Sg" "$1" ;;
*) stat -c "%G" "$1" ;;
esac
}

is_file_group() [[ "$(get_file_group "$1")" == "$2" ]]

install_man_pages()
{
files=($(
Expand All @@ -630,14 +642,19 @@ install_man_pages()
if [[ ! -d $rvm_man_path/${file%\/*} ]]
then
mkdir -p $rvm_man_path/${file%\/*}
(( ${rvm_user_install_flag:-0} == 1 )) ||
is_file_group $rvm_man_path/${file%\/*} $rvm_group_name ||
chown :$rvm_group_name $rvm_man_path/${file%\/*}
fi
cp -Rf "$install_source_path/man/$file" "$rvm_man_path/$file" || \
printf "%b" "
Please run the installer using rvmsudo to fix file permissions
"
chown :$rvm_group_name "$rvm_man_path/$file"
(( ${rvm_user_install_flag:-0} == 1 )) ||
is_file_group "$rvm_man_path/$file" $rvm_group_name ||
chown :$rvm_group_name "$rvm_man_path/$file"
done
}

Expand Down Expand Up @@ -1036,8 +1053,6 @@ PATH=\$PATH:\$HOME/.rvm/bin # Add RVM to PATH for scripting

root_canal()
{
true ${rvm_group_name:=rvm}

if (( UID == 0 )) && system_check
then
setup_rvm_group
Expand Down
2 changes: 1 addition & 1 deletion scripts/initialize
Expand Up @@ -98,7 +98,7 @@ Error:
# configurable by the end users for whatever their needs may be.
# They should be set in /etc/rvmrc and then $HOME/.rvmrc
#
if [[ -z "${rvm_user_install_flag:-}" ]]
if (( ${rvm_user_install_flag:-0} == 0 ))
then
export rvm_user_install_flag rvm_man_path

Expand Down

0 comments on commit dbd4210

Please sign in to comment.