mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-11-29 23:30:51 +01:00
Support conditional package installation with --if <test>
This commit is contained in:
parent
3a426d13b7
commit
243e6fbecf
6 changed files with 23 additions and 26 deletions
|
|
@ -93,15 +93,15 @@ file_is_not_empty() {
|
|||
}
|
||||
|
||||
install_package() {
|
||||
install_package_using "tarball" 1 $*
|
||||
install_package_using "tarball" 1 "$@"
|
||||
}
|
||||
|
||||
install_git() {
|
||||
install_package_using "git" 2 $*
|
||||
install_package_using "git" 2 "$@"
|
||||
}
|
||||
|
||||
install_svn() {
|
||||
install_package_using "svn" 2 $*
|
||||
install_package_using "svn" 2 "$@"
|
||||
}
|
||||
|
||||
install_package_using() {
|
||||
|
|
@ -110,10 +110,22 @@ install_package_using() {
|
|||
local package_name="$3"
|
||||
shift 3
|
||||
|
||||
local fetch_args=( "$package_name" "${@:1:$package_type_nargs}" )
|
||||
local make_args=( "$package_name" )
|
||||
local arg last_arg
|
||||
|
||||
for arg in "${@:$(( $package_type_nargs + 1 ))}"; do
|
||||
if [ "$last_arg" = "--if" ]; then
|
||||
"$arg" || return 0
|
||||
elif [ "$arg" != "--if" ]; then
|
||||
make_args["${#make_args[@]}"]="$arg"
|
||||
fi
|
||||
last_arg="$arg"
|
||||
done
|
||||
|
||||
pushd "$BUILD_PATH" >&4
|
||||
"fetch_${package_type}" "$package_name" $*
|
||||
shift $(($package_type_nargs))
|
||||
make_package "$package_name" $*
|
||||
"fetch_${package_type}" "${fetch_args[@]}"
|
||||
make_package "${make_args[@]}"
|
||||
popd >&4
|
||||
|
||||
{ echo "Installed ${package_name} to ${PREFIX_PATH}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue