Skip to content

Commit

Permalink
add support for binary ruby, reworked fetching and packaging, extract…
Browse files Browse the repository at this point in the history
… remote file and extension building, closes #1241
  • Loading branch information
mpapis committed Oct 30, 2012
1 parent 5c92a14 commit da93081
Show file tree
Hide file tree
Showing 13 changed files with 228 additions and 154 deletions.
4 changes: 3 additions & 1 deletion config/db
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ maglev_repo_url=git://github.com/MagLev/maglev.git
ironruby_version=1.0 ironruby_version=1.0
ironruby_repo_url=git://github.com/ironruby/ironruby.git ironruby_repo_url=git://github.com/ironruby/ironruby.git
ironruby_1.0_url=http://rubyforge.org/frs/download.php/70179/ ironruby_1.0_url=http://rubyforge.org/frs/download.php/70179/
rvm_remote_server_url=https://rvm.io/binaries rvm_remote_server_url=http://jruby.org.s3.amazonaws.com
rvm_remote_server_path=downloads
rvm_remote_server_url1=https://rvm.io/binaries
# rvm_remote_server_path=gentoo/ec2-2013.09/amd64 # rvm_remote_server_path=gentoo/ec2-2013.09/amd64
# Packages # Packages
readline_url=http://ftp.gnu.org/gnu/readline readline_url=http://ftp.gnu.org/gnu/readline
Expand Down
1 change: 1 addition & 0 deletions config/md5
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ GemStone-27184.Darwin-i386.tar.gz=292b3b169656a8451cfa19c228828e5a
GemStone-27184.Linux-x86_64.tar.gz=cfabd4dd73d2656fc10243e35dd7452b GemStone-27184.Linux-x86_64.tar.gz=cfabd4dd73d2656fc10243e35dd7452b
GemStone-27184.SunOS-i86pc.tar.gz=5755a0689488748dfeab3bc74572aaa8 GemStone-27184.SunOS-i86pc.tar.gz=5755a0689488748dfeab3bc74572aaa8
MagLev-1.0.0.tar.gz=e02cb8ee04438451eb78df14f91a68a9 MagLev-1.0.0.tar.gz=e02cb8ee04438451eb78df14f91a68a9
http://jruby.org.s3.amazonaws.com/downloads/1.7.0/jruby-bin-1.7.0.tar.gz=21861e0ecdbf48cda713c8ade82fdddb
https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p194.tar.bz2=384ea18aef77b95e49df6f3944fc3e11 https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p194.tar.bz2=384ea18aef77b95e49df6f3944fc3e11
https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p286.tar.bz2=e7ee7c1a6dc913f6e7fad3ba03e459da https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p286.tar.bz2=e7ee7c1a6dc913f6e7fad3ba03e459da
https://rvm.io/binaries/centos/5.6/x86_64/ruby-1.9.3-p194.tar.bz2=3e1aa66177d0d1a7af1bb2617e836464 https://rvm.io/binaries/centos/5.6/x86_64/ruby-1.9.3-p194.tar.bz2=3e1aa66177d0d1a7af1bb2617e836464
Expand Down
1 change: 1 addition & 0 deletions config/sha512
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,4 @@
http://jruby.org.s3.amazonaws.com/downloads/1.7.0/jruby-bin-1.7.0.tar.gz=1e466a3f8d52b553c9def09827fda4b8433576b0262c40ee505602754521a00defd821d5ead5052be52baf281c6cb080fd03a8b15c628a0ee67b4e417633e5e2
https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p194.tar.bz2=289f3921543eb096b0d50a2ce7f8655176f6f4dbc8a52aa1342b5238e33f36c9dc78948e4144f41eeca616920ba3422adb0a17d216ec7d2cfaae51f570c1f9b3 https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p194.tar.bz2=289f3921543eb096b0d50a2ce7f8655176f6f4dbc8a52aa1342b5238e33f36c9dc78948e4144f41eeca616920ba3422adb0a17d216ec7d2cfaae51f570c1f9b3
https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p286.tar.bz2=29d827ca2241fe8b6ee2b6e5bf454820594c4631f46748e8cb4402052b848b43b3f2095d97f57aeb84815193af0e191f80b0f4967aeeaacf9109af1386f17295 https://rvm.io/binaries/arch/libc-2.15/x86_64/ruby-1.9.3-p286.tar.bz2=29d827ca2241fe8b6ee2b6e5bf454820594c4631f46748e8cb4402052b848b43b3f2095d97f57aeb84815193af0e191f80b0f4967aeeaacf9109af1386f17295
https://rvm.io/binaries/centos/5.6/x86_64/ruby-1.9.3-p194.tar.bz2=6c541bab1e17e712adb7cdbd464a188c365ee109d8b0df044917806cd3263563e48fc8b2f2817804f0984a6c1a94510bcfab569b86cbd231e0504f92114a4080 https://rvm.io/binaries/centos/5.6/x86_64/ruby-1.9.3-p194.tar.bz2=6c541bab1e17e712adb7cdbd464a188c365ee109d8b0df044917806cd3263563e48fc8b2f2817804f0984a6c1a94510bcfab569b86cbd231e0504f92114a4080
Expand Down
47 changes: 28 additions & 19 deletions scripts/external
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -236,13 +236,14 @@ external_import_configure()
(http*) true ;; (http*) true ;;
(*) (*)
__rvm_ruby_string __rvm_ruby_string
rvm_ruby_url="$(__rvm_remote_server_path "${rvm_ruby_string}.${rvm_remote_extension:-tar.bz2}" )" rvm_ruby_url="$(__rvm_remote_server_path "${rvm_ruby_string}" )"
;; ;;
esac esac


rvm_ruby_string="${rvm_ruby_string##*/}" rvm_ruby_string="${rvm_ruby_string##*/}"
rvm_ruby_string="${rvm_ruby_string%.t*}" rvm_ruby_string="${rvm_ruby_string%.t*}"
rvm_ruby_package_file="bin-${rvm_ruby_string}.${rvm_remote_extension:-tar.bz2}" __rvm_ruby_package_file "${rvm_ruby_string}"
rvm_ruby_package_file="bin-${rvm_ruby_string}.$(__rvm_remote_extension "${rvm_ruby_string}" -)"
} }


external_import_download() external_import_download()
Expand All @@ -264,7 +265,7 @@ external_import_download()
fi fi


downloaded_names="$( downloaded_names="$(
tar tjf "$rvm_archives_path/${rvm_ruby_package_file}" | awk -F/ '{print $1}' | sort -u __rvm_package list "$rvm_archives_path/${rvm_ruby_package_file}" | awk -F/ '{print $1}' | sort -u
)" )"
[[ "${rvm_ruby_string}" == "${downloaded_names}" ]] || { [[ "${rvm_ruby_string}" == "${downloaded_names}" ]] || {
$err_command "The downloaded package ${rvm_ruby_url} contains '${downloaded_names}' instead of '${rvm_ruby_string}'." $err_command "The downloaded package ${rvm_ruby_url} contains '${downloaded_names}' instead of '${rvm_ruby_string}'."
Expand All @@ -274,8 +275,7 @@ external_import_download()


external_import_extract() external_import_extract()
{ {
chpwd_functions="" builtin cd "${rvm_rubies_path}" __rvm_package extract "$rvm_archives_path/${rvm_ruby_package_file}" "${rvm_rubies_path}" || {
tar xjf "$rvm_archives_path/${rvm_ruby_package_file}" || {
$err_command "Unpacking ${rvm_ruby_package_file} failed." $err_command "Unpacking ${rvm_ruby_package_file} failed."
return 6 return 6
} }
Expand Down Expand Up @@ -334,6 +334,12 @@ __rvm_fix_wrappers()
-e "/^ENV\[[\"']PATH[\"']\]=/ d" -e "/^ENV\[[\"']PATH[\"']\]=/ d"
fi fi
done done
if
[[ ! -f "$rvm_rubies_path/$rvm_ruby_string/bin/ruby" ]] &&
[[ -f "$rvm_rubies_path/$rvm_ruby_string/bin/jruby" ]]
then
ln -s "$rvm_rubies_path/$rvm_ruby_string/bin/jruby" "$rvm_rubies_path/$rvm_ruby_string/bin/ruby"
fi
} }


__rvm_fix_lib_files() __rvm_fix_lib_files()
Expand All @@ -353,9 +359,9 @@ __rvm_fix_lib_files()
external_import_setup() external_import_setup()
{ {
__rvm_ruby_string __rvm_ruby_string
__rvm_rubygems_create_link
__rvm_fix_wrappers __rvm_fix_wrappers
__rvm_fix_lib_files __rvm_fix_lib_files
__rvm_rubygems_create_link "$rvm_rubies_path/$rvm_ruby_string/bin/ruby"


rvm_create_flag=1 __rvm_use rvm_create_flag=1 __rvm_use


Expand Down Expand Up @@ -410,19 +416,22 @@ external_prepare_package()
fi fi


rvm_log "Preparing ${rvm_ruby_string} ..." rvm_log "Preparing ${rvm_ruby_string} ..."
case "${file_name}" in if
(*.tar.bz2) __rvm_package create "${file_name}" "${rvm_rubies_path}" "${rvm_ruby_string}"
tar cjf "${file_name}" -C "${rvm_rubies_path}" "${rvm_ruby_string}" then
;; rvm_log "Prepared ${file_name}."
(*.tar.gz|*.tgz) else
tar czf "${file_name}" -C "${rvm_rubies_path}" "${rvm_ruby_string}" case $? in
;; 199)
(*) rvm_error "Unrecognized archive format for ${file_name}"
rvm_error "Do not know how to package '${file_name}'." return 199
return 1 ;;
;; *)
esac rvm_error "Error packaging ${file_name}."
rvm_log "Prepared $1." return 1
;;
esac
fi
} }


#TODO: move to SMF ! RVM2 ? #TODO: move to SMF ! RVM2 ?
Expand Down
55 changes: 16 additions & 39 deletions scripts/functions/manage/base
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ __rvm_install_ruby_try_remote()
: rvm_disable_binary_flag:${rvm_disable_binary_flag:=0}: rvm_remote_flag:${rvm_remote_flag:=0}: : rvm_disable_binary_flag:${rvm_disable_binary_flag:=0}: rvm_remote_flag:${rvm_remote_flag:=0}:
(( rvm_disable_binary_flag )) || (( rvm_disable_binary_flag )) ||
{ {
rubies=($( typeset __rvm_ruby_url
__list_remote_rubies_for "$( __rvm_remote_server_path "${rvm_ruby_string//\./\.}\.tar\..*" )" __rvm_ruby_url="$( __rvm_remote_server_path "${rvm_ruby_string}" )"
)) if
case ${#rubies[@]} in [[ -z "${__rvm_ruby_url}" ]]
(0) then
if if
(( rvm_remote_flag )) (( rvm_remote_flag ))
then then
Expand All @@ -279,28 +279,16 @@ __rvm_install_ruby_try_remote()
rvm_warn "No binary rubies available for: $(__rvm_system_path -)/${rvm_ruby_string}. rvm_warn "No binary rubies available for: $(__rvm_system_path -)/${rvm_ruby_string}.
Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies." Continuing with compilation. Please read 'rvm mount' to get more information on binary rubies."
fi fi
;; else
(1)
if if
rvm_remote_flag=1 "${rvm_scripts_path}/external" mount "$rvm_ruby_string" rvm_remote_flag=1 "${rvm_scripts_path}/external" mount "${__rvm_ruby_url}" "${rvm_ruby_string}"
then then
return 0 return 0
else else
__rvm_rm_rf "$rvm_rubies_path/$rvm_ruby_string" __rvm_rm_rf "$rvm_rubies_path/$rvm_ruby_string" # cleanup so standard installation works
rvm_warn "Mounting remote ruby failed, trying to compile." rvm_warn "Mounting remote ruby failed, trying to compile."
fi fi
;; fi
(*)
if
(( rvm_remote_flag ))
then
rvm_error "Requested binary installation but multiple rubies are available to download, this most likely is a bug, please report an issue!"
return 1
else
rvm_warn "More then one binary ruby found, this most likely is a bug, please report an issue!"
fi
;;
esac
} }
return 2 # continue with compilation return 2 # continue with compilation
} }
Expand Down Expand Up @@ -549,29 +537,18 @@ __rvm_fetch_ruby()
then then
mkdir -p "${rvm_tmp_path:-/tmp}/rvm_src_$$" mkdir -p "${rvm_tmp_path:-/tmp}/rvm_src_$$"


case "$rvm_archive_extension" in __rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
tar.gz|tgz) __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
_current_command=( case $? in
"$rvm_tar_command" xzf "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" -C "${rvm_tmp_path:-/tmp}/rvm_src_$$" ${rvm_tar_options:-} 199)
) rvm_error "\nUnrecognized archive format '$archive_format'"
;; return 199
tar.bz2)
_current_command=(
"$rvm_tar_command" xjf "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" -C "${rvm_tmp_path:-/tmp}/rvm_src_$$" ${rvm_tar_options:-}
)
;;
zip)
_current_command=(
unzip -q -o "${rvm_archives_path}/$rvm_ruby_package_file" -d "${rvm_tmp_path:-/tmp}/rvm_src_$$"
)
;; ;;
*) *)
rvm_error "Unknown archive format extension '$rvm_archive_extension'.\nHalting the installation." rvm_error "There has been an error while trying to extract the source. Halting the installation."
return 1 return 1
;; ;;
esac esac
__rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
"${_current_command[@]}" || return $?


__rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string" __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string"


Expand Down
21 changes: 12 additions & 9 deletions scripts/functions/manage/maglev
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,15 +71,18 @@ maglev_install()
mkdir -p "${rvm_src_path}/${rvm_gemstone_package_file}" mkdir -p "${rvm_src_path}/${rvm_gemstone_package_file}"
fi fi


__rvm_run "gemstone.extract" \ __rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
"$rvm_tar_command xzf \"${rvm_archives_path}/${rvm_gemstone_package_file}.${rvm_archive_extension}\" -C ${rvm_src_path}/ ${rvm_tar_options:-}" __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
result=$? case $? in

199)
if (( result > 0 )) rvm_error "\nUnrecognized archive format '$archive_format'"
then return 199
rvm_error "There has been an error while trying to extract the GemStone package. \nHalting the installation." ;;
exit $result *)
fi rvm_error "There has been an error while trying to extract the source. Halting the installation."
return 1
;;
esac


ln -fs "${rvm_src_path}/$rvm_gemstone_package_file" "gemstone" ln -fs "${rvm_src_path}/$rvm_gemstone_package_file" "gemstone"


Expand Down
44 changes: 22 additions & 22 deletions scripts/functions/manage/ree
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -21,38 +21,38 @@ ree_install()


chpwd_functions="" builtin cd "${rvm_src_path}" chpwd_functions="" builtin cd "${rvm_src_path}"


if [[ -d "${rvm_src_path}/$rvm_ruby_string" && if
-x "${rvm_src_path}/$rvm_ruby_string/installer" ]] [[ -d "${rvm_src_path}/$rvm_ruby_string" ]] &&
[[ -x "${rvm_src_path}/$rvm_ruby_string/installer" ]]
then then
rvm_log "It appears that the archive has already been extracted. Skipping extract (use reinstall to do fresh installation)." rvm_log "It appears that the archive has already been extracted. Skipping extract (use reinstall to do fresh installation)."

else else
rvm_log "$rvm_ruby_string - #fetching ($rvm_ruby_package_file)" rvm_log "$rvm_ruby_string - #fetching ($rvm_ruby_package_file)"

if
"$rvm_scripts_path/fetch" "$rvm_ruby_url" "$rvm_scripts_path/fetch" "$rvm_ruby_url"
result=$?

if (( result > 0 ))
then then
true
else
result=$?
rvm_error "There has been an error while trying to fetch the source. \nHalting the installation." rvm_error "There has been an error while trying to fetch the source. \nHalting the installation."
return $result return $result
fi fi


__rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string" __rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
__rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
case $? in
199)
rvm_error "\nUnrecognized archive format '$archive_format'"
return 199
;;
*)
rvm_error "There has been an error while trying to extract the source. Halting the installation."
return 1
;;
esac


__rvm_run "extract" \ __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string"
"$rvm_tar_command xzf \"${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension\" -C ${rvm_src_path} ${rvm_tar_options:-}" \ mv "${rvm_src_path}/$rvm_ruby_package_file" "${rvm_src_path}/$rvm_ruby_string"
"$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string"
result=$?

if (( result > 0 ))
then
rvm_error "There has been an error while trying to extract the source. Halting the installation."
return $result
fi

mv "${rvm_src_path}/$rvm_ruby_package_file" \
"${rvm_src_path}/$rvm_ruby_string"
fi fi


chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string" chpwd_functions="" builtin cd "${rvm_src_path}/$rvm_ruby_string"
Expand Down
21 changes: 12 additions & 9 deletions scripts/functions/manage/rubinius
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ rubinius_install()
rvm_error "There has been an error while trying to fetch the source. Halting the installation." rvm_error "There has been an error while trying to fetch the source. Halting the installation."
return $result return $result
fi fi
__rvm_run "extract" \
"$rvm_tar_command xzf \"${rvm_archives_path}/$(basename ${rvm_ruby_package_file})\" -C ${rvm_src_path} ${rvm_tar_options:-}" \
"$rvm_ruby_string - #extracting"
result=$?


if (( result > 0 )) __rvm_log_command "extract" "$rvm_ruby_string - #extracting $rvm_ruby_package_file to ${rvm_src_path}/$rvm_ruby_string" \
then __rvm_package extract "${rvm_archives_path}/$rvm_ruby_package_file.$rvm_archive_extension" "${rvm_tmp_path:-/tmp}/rvm_src_$$" ||
rvm_error "There has been an error while trying to extract the source. \nHalting the installation." case $? in
return $result 199)
fi rvm_error "\nUnrecognized archive format '$archive_format'"
return 199
;;
*)
rvm_error "There has been an error while trying to extract the source. Halting the installation."
return 1
;;
esac


# Remove the left over folder first. # Remove the left over folder first.
__rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string" __rvm_rm_rf "${rvm_src_path}/$rvm_ruby_string"
Expand Down
27 changes: 8 additions & 19 deletions scripts/functions/pkg
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,27 +7,16 @@ install_package()
chpwd_functions="" builtin cd "$rvm_src_path" chpwd_functions="" builtin cd "$rvm_src_path"
rvm_log "Fetching $package-$version.$archive_format to $rvm_archives_path" rvm_log "Fetching $package-$version.$archive_format to $rvm_archives_path"


case "$archive_format" in "$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $?
tar.gz|tgz) __rvm_log_command "$package/extract" "Extracting ${package} to $rvm_src_path/$package-$version" \
"$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $? __rvm_package extract "$rvm_archives_path/$package-$version.$archive_format" "$rvm_src_path" ||
__rvm_run "$package/extract" \ case $? in
"$rvm_tar_command xmzf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path ${rvm_tar_options:-}" \ 199)
"Extracting $package-$version.$archive_format to $rvm_src_path" rvm_error "\nUnrecognized archive format '$archive_format'"
;; return 199
tar.bz2)
"$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $?
__rvm_run "$package/extract" \
"$rvm_tar_command xmjf $rvm_archives_path/$package-$version.$archive_format -C $rvm_src_path ${rvm_tar_options:-} "\
"Extracting $package-$version.$archive_format to $rvm_src_path"
;;
zip)
"$rvm_scripts_path/fetch" "$package_url/$package-$version.$archive_format" || return $?
__rvm_run "$package/extract" \
"unzip -q -o $rvm_archives_path/$package-$version.$archive_format -d $rvm_src_path/$package-$version" \
"Extracting $package-$version.$archive_format to $rvm_src_path"
;; ;;
*) *)
printf "%b" "\nUnrecognized archive format '$archive_format'" rvm_error "There has been an error while trying to extract the source. Halting the installation."
return 1 return 1
;; ;;
esac esac
Expand Down
26 changes: 15 additions & 11 deletions scripts/functions/support
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -106,20 +106,24 @@ __rvm_array_add_or_update()
# Assumes that filename is the first argument, all others are passed onto sed # Assumes that filename is the first argument, all others are passed onto sed
__rvm_sed_i() __rvm_sed_i()
{ {
typeset _filename _executable typeset _filename _executable
_filename="$1" [[ -n "${1:-}" ]] || {
shift rvm_debug "no file given for __rvm_sed_i"
return 0
}
_filename="$1"
shift


if [[ -x "${_filename}" ]] if [[ -x "${_filename}" ]]
then _executable=true then _executable=true
fi fi


sed "$@" < "${_filename}" > "${_filename}.new" sed "$@" < "${_filename}" > "${_filename}.new"
\mv "${_filename}.new" "${_filename}" \mv "${_filename}.new" "${_filename}"


if [[ -n "${_executable:-}" ]] if [[ -n "${_executable:-}" ]]
then chmod +x "${_filename}" then chmod +x "${_filename}"
fi fi
} }


# Drop in replacement for which compatible with OSX / ZSH # Drop in replacement for which compatible with OSX / ZSH
Expand Down
Loading

0 comments on commit da93081

Please sign in to comment.