Skip to content

Commit

Permalink
fix update-system and error messages, improved autolibs level detecti…
Browse files Browse the repository at this point in the history
…on in update-system, update #1720, update #1724

Conflicts:
	scripts/functions/build_requirements
  • Loading branch information
mpapis committed Mar 31, 2013
1 parent 4f065e6 commit 6e07dd3
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 48 deletions.
6 changes: 3 additions & 3 deletions scripts/functions/build_config
Expand Up @@ -132,18 +132,18 @@ __rvm_setup_compile_environment_osx_clang()
__rvm_version_compare "${_system_version}" -ge 10.7
then
__rvm_setup_compile_environment_osx_clang_installed ||
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Can not find 'Command Line Tools for Xcode',
You should install the latest version from: http://connect.apple.com" \
true || return $?

__rvm_setup_compile_environment_osx_clang_latest ||
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Found older 'Command Line Tools for Xcode',
You should install the latest version from: http://connect.apple.com" \
true || return $?
else
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"You are using 'clang' which is known to be buggy on older OSX (like: ${_system_version}).
Make sure 'gcc-4.2' is available and try again." \
true || return $?
Expand Down
36 changes: 17 additions & 19 deletions scripts/functions/build_requirements
Expand Up @@ -2,19 +2,26 @@

rvm_requiremnts_fail()
{
rvm_error "$1
Cowardly refusing to continue, your mode is '2' => check and fail,
please run and read 'rvm autolibs [help]' for more information."
rvm_$1 "$2
RVM autolibs is now configured with mode '2' => 'check and stop if missing',
please run \`rvm autolibs enable\` to let RVM do it's job or run and read \`rvm autolibs [help]\`
or visit https://rvm.io/rvm/autolibs for more information."
}

rvm_requiremnts_fail_or_run_action()
{
case "${rvm_autolibs_flag_number}" in
(0) rvm_debug "$1" ;;
(1) rvm_warn "$1" ;;
(0) rvm_debug "$2" ;;
(1) rvm_warn "$2" ;;
(2)
rvm_requiremnts_fail "$1"
return 1
if
(( $1 <= 2 ))
then
rvm_requiremnts_fail error "$2"
return 1
else
rvm_requiremnts_fail warn "$2"
fi
;;
(*)
shift 2
Expand All @@ -24,15 +31,6 @@ rvm_requiremnts_fail_or_run_action()
true # for osx
}

__rvm_requirements_fail_only_when()
{
typeset __ret=$?
if (( rvm_autolibs_flag_number >= $1 ))
then return ${__ret}
fi
true # for OSX
}

requirements_osx_update_openssl_cert_old() [[ "$cert_file" -ot /Library/Keychains/System.keychain ||
"$cert_file" -ot /System/Library/Keychains/SystemRootCertificates.keychain
]]
Expand Down Expand Up @@ -65,7 +63,7 @@ requirements_osx_update_openssl_cert()
if
requirements_osx_update_openssl_cert_old
then
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Skipping update of certificates in '$cert_file'." \
requirements_osx_update_openssl_cert_run ||
return $?
Expand Down Expand Up @@ -171,7 +169,7 @@ __rvm_filter_installed_packages_summary()
(( ${#packages_missing[@]} == 0 )) ||
{
_list="${packages_missing[*]}"
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Missing required packages: ${_list// /, }." \
true ||
return $?
Expand Down Expand Up @@ -215,7 +213,7 @@ __rvm_try_sudo()
return 0 # do not run nothing if it would require sudo
;;
(2)
rvm_requiremnts_fail "Running '$*' would require sudo."
rvm_requiremnts_fail error "Running '$*' would require sudo."
return 1
;;
(*)
Expand Down
5 changes: 3 additions & 2 deletions scripts/functions/requirements/arch
Expand Up @@ -20,8 +20,9 @@ requirements_arch_run()
{
case "$1" in
(update-system)
__rvm_dotted_run "Updating pacman" requirements_arch_libs_install pacman ||
__rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping pacman update, make sure your system is up to date." \
requirements_arch_libs_install pacman || return $?
;;
(rvm)
requirements_arch_libs_ensure bash curl git patch
Expand Down
19 changes: 13 additions & 6 deletions scripts/functions/requirements/freebsd
Expand Up @@ -16,17 +16,24 @@ requirements_freebsd_ensure_libs()
__rvm_filter_installed_packages freebsd "$@" || return $?
}

requirements_freebsd_update_system()
{
__rvm_try_sudo portsnap fetch extract &&
__rvm_try_sudo portsnap fetch update ||
return $?
# or the below to do it like the openbsd support does
# curl ftp://ftp.freebsd.org/pub/FreeBSD/releases/$(uname -m)/$(uname -r)/ports.txz | __rvm_try_sudo tar --xz -C /usr -xz
}


requirements_freebsd_run()
{
case "$1" in
(update-system)
[[ -d /usr/ports ]] || {
__rvm_try_sudo portsnap fetch extract &&
__rvm_try_sudo portsnap fetch update ||
__rvm_requirements_fail_only_when 3 ||
return $?
# or the below to do it like the openbsd support does
# curl ftp://ftp.freebsd.org/pub/FreeBSD/releases/$(uname -m)/$(uname -r)/ports.txz | __rvm_try_sudo tar --xz -C /usr -xz
rvm_requiremnts_fail_or_run_action 3 \
"Skipping ports installation, make sure '/usr/ports' is set up." \
requirements_freebsd_update_system || return $?
}
;;
(rvm)
Expand Down
4 changes: 3 additions & 1 deletion scripts/functions/requirements/gentoo
Expand Up @@ -17,7 +17,9 @@ requirements_gentoo_run()
{
case "$1" in
(update-system)
__rvm_try_sudo emerge --sync || __rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping \`emerge --sync\` make sure your system is up to date." \
__rvm_try_sudo emerge --sync || return $?
;;
(rvm)
requirements_gentoo_ensure_libs net-misc/curl git sys-devel/patch app-shells/bash
Expand Down
15 changes: 10 additions & 5 deletions scripts/functions/requirements/openbsd
Expand Up @@ -16,17 +16,22 @@ requirements_openbsd_ensure_libs()
__rvm_filter_installed_packages openbsd "$@" || return $?
}

requirements_openbsd_update_system()
{
curl ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/ports.tar.gz |
__rvm_try_sudo tar -C /usr -zx || return $?
__rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} || return $?
}

requirements_openbsd_run()
{
case "$1" in
(update-system)
[[ -d /usr/ports ]] ||
{
curl ftp://ftp.openbsd.org/pub/OpenBSD/$(uname -r)/ports.tar.gz |
__rvm_try_sudo tar -C /usr -zx ||
__rvm_requirements_fail_only_when 3 || return $?
__rvm_check_pipestatus ${PIPESTATUS[@]} ${pipestatus[@]} ||
__rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping ports installation, make sure '/usr/ports' is set up." \
requirements_openbsd_update_system || return $?
}
;;
(rvm)
Expand Down
5 changes: 3 additions & 2 deletions scripts/functions/requirements/opensuse
Expand Up @@ -20,8 +20,9 @@ requirements_opensuse_run()
{
case "$1" in
(update-system)
__rvm_dotted_run "Updating repositories" __rvm_try_sudo zypper refresh ||
__rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping \`zypper refresh\` make sure your system is up to date." \
__rvm_try_sudo zypper refresh || return $?
;;
(rvm)
requirements_opensuse_ensure_libs bash curl git patch
Expand Down
8 changes: 4 additions & 4 deletions scripts/functions/requirements/osx_brew
Expand Up @@ -28,7 +28,7 @@ requirements_brew_libs_try_upgrade()
if
(( ${#outdated_libs[@]} ))
then
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Homebrew libs require update - skipping." \
brew upgrade "${outdated_libs[@]}" ||
return $?
Expand Down Expand Up @@ -166,7 +166,7 @@ and make sure \`brew update\` works before continuing."
}
requirements_brew_update_system()
{
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 3 \
"Skipping \`brew update\` make sure your formulas are up to date." \
requirements_brew_update_system_run ||
return $?
Expand All @@ -176,7 +176,7 @@ requirements_brew_route_install()
{
case "$1" in
(update-system)
requirements_brew_update_system || __rvm_requirements_fail_only_when 3 || return $?
requirements_brew_update_system || return $?
;;
(rvm)
true
Expand All @@ -200,7 +200,7 @@ requirements_brew_ensure_brew_available()
{
which brew >/dev/null ||
{
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Requested installation with homebrew libs, but homebrew is not available." \
__rvm_log_command brew_install "Installing homebrew" requirements_brew_install_brew ||
return $?
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/requirements/osx_fink
Expand Up @@ -105,7 +105,7 @@ requirements_fink_ensure_fink_available()
{
which fink >/dev/null ||
{
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Requested installation with fink libs, but fink is not available." \
__rvm_log_command fink_install "Installing fink" requirements_fink_install_fink ||
return $?
Expand Down
6 changes: 4 additions & 2 deletions scripts/functions/requirements/osx_port
Expand Up @@ -71,7 +71,9 @@ requirements_port_route_install()
{
case "$1" in
(update-system)
__rvm_try_sudo port -dv selfupdate || __rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping \`port selfupdate\` make sure your macports are up to date." \
__rvm_try_sudo port -dv selfupdate || return $?
;;
(rvm)
# FIXME: requirements for rvm
Expand All @@ -96,7 +98,7 @@ requirements_port_ensure_port_available()
{
which port >/dev/null ||
{
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Requested installation with macports libs, but macports is not available." \
__rvm_log_command port_install "Installing macports" requirements_port_install_port ||
return $?
Expand Down
2 changes: 1 addition & 1 deletion scripts/functions/requirements/smf
Expand Up @@ -101,7 +101,7 @@ requirements_smf_ensure_smf_available()
{
which sm >/dev/null ||
{
rvm_requiremnts_fail_or_run_action \
rvm_requiremnts_fail_or_run_action 2 \
"Requested installation with SM Framework, but SM Framework is not available." \
__rvm_log_command smf_install "Installing SM Framework" requirements_smf_install_sm ||
return $?
Expand Down
5 changes: 3 additions & 2 deletions scripts/functions/requirements/ubuntu
Expand Up @@ -53,8 +53,9 @@ requirements_debian_run()
{
case "$1" in
(update-system)
__rvm_dotted_run "Updating repositories" __rvm_try_sudo apt-get --quiet --yes update ||
__rvm_requirements_fail_only_when 3 || return $?
rvm_requiremnts_fail_or_run_action 3 \
"Skipping \`apt-get update\` make sure your system is up to date." \
__rvm_try_sudo apt-get --quiet --yes update || return $?
;;
(rvm)
requirements_debian_ensure_libs bash curl git-core patch bzip2 ca-certificates
Expand Down

0 comments on commit 6e07dd3

Please sign in to comment.