Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
7d789494
Unverified
Commit
7d789494
authored
4 years ago
by
Maxim Belkin
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #8340 from maxim-belkin/code-reorg-utils-ruby-sh
utils/ruby.sh: reoganize code
parents
e9f3d6da
cfbc09f3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Library/Homebrew/utils/ruby.sh
+48
-48
48 additions, 48 deletions
Library/Homebrew/utils/ruby.sh
with
48 additions
and
48 deletions
Library/Homebrew/utils/ruby.sh
+
48
−
48
View file @
7d789494
...
...
@@ -9,6 +9,35 @@ test_ruby () {
Gem::Version.new('
$required_ruby_version
').to_s.split('.').first(2)"
2>/dev/null
}
find_ruby
()
{
if
[[
-n
"
$HOMEBREW_MACOS
"
]]
then
echo
"/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
else
IFS
=
$'
\n
'
# Do word splitting on new lines only
for
ruby_exec
in
$(
which
-a
ruby
)
$(
PATH
=
$HOMEBREW_PATH
which
-a
ruby
)
do
if
test_ruby
"
$ruby_exec
"
;
then
echo
"
$ruby_exec
"
break
fi
done
IFS
=
$'
\t\n
'
# Restore IFS to its default value
fi
}
unusable_ruby
()
{
if
[[
-n
"
$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
"
]]
then
return
1
elif
[[
-n
"
$HOMEBREW_RUBY_PATH
"
&&
-z
"
$HOMEBREW_FORCE_VENDOR_RUBY
"
]]
&&
test_ruby
"
$HOMEBREW_RUBY_PATH
"
then
return
1
else
return
0
fi
}
setup-ruby-path
()
{
local
vendor_dir
local
vendor_ruby_root
...
...
@@ -16,17 +45,27 @@ setup-ruby-path() {
local
vendor_ruby_terminfo
local
vendor_ruby_latest_version
local
vendor_ruby_current_version
local
usable_ruby
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
# also needs to be changed.
local
required_ruby_version
=
"2.6"
local
ruby_exec
local
advice
=
"
local
upgrade_fail
local
install_fail
if
[[
-n
$HOMEBREW_MACOS
]]
then
upgrade_fail
=
"Failed to upgrade Homebrew Portable Ruby!"
install_fail
=
"Failed to install Homebrew Portable Ruby (and your system version is too old)!"
else
local
advice
=
"
If there's no Homebrew Portable Ruby available for your processor:
- install Ruby
$required_ruby_version
with your system package manager (or rbenv/ruby-build)
- make it first in your PATH
- try again
"
upgrade_fail
=
"Failed to upgrade Homebrew Portable Ruby!
$advice
"
install_fail
=
"Failed to install Homebrew Portable Ruby and cannot find another Ruby
$required_ruby_version
!
$advice
"
fi
vendor_dir
=
"
$HOMEBREW_LIBRARY
/Homebrew/vendor"
vendor_ruby_root
=
"
$vendor_dir
/portable-ruby/current"
...
...
@@ -45,60 +84,21 @@ If there's no Homebrew Portable Ruby available for your processor:
if
[[
-x
"
$vendor_ruby_path
"
]]
then
HOMEBREW_RUBY_PATH
=
"
$vendor_ruby_path
"
[[
-z
"
$HOMEBREW_MACOS
"
]]
&&
TERMINFO_DIRS
=
"
$vendor_ruby_terminfo
"
TERMINFO_DIRS
=
"
$vendor_ruby_terminfo
"
if
[[
$vendor_ruby_current_version
!=
"
$vendor_ruby_latest_version
"
]]
then
if
!
brew vendor-install ruby
then
if
[[
-n
"
$HOMEBREW_MACOS
"
]]
then
odie
"Failed to upgrade Homebrew Portable Ruby!"
else
odie
"Failed to upgrade Homebrew Portable Ruby!
$advice
"
fi
fi
brew vendor-install ruby
||
odie
"
$upgrade_fail
"
fi
else
if
[[
-n
"
$HOMEBREW_MACOS
"
]]
then
HOMEBREW_RUBY_PATH
=
"/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
else
IFS
=
$'
\n
'
# Do word splitting on new lines only
for
ruby_exec
in
$(
which
-a
ruby
)
$(
PATH
=
$HOMEBREW_PATH
which
-a
ruby
)
do
if
test_ruby
"
$ruby_exec
"
;
then
HOMEBREW_RUBY_PATH
=
$ruby_exec
break
fi
done
IFS
=
$'
\t\n
'
# Restore IFS to its default value
fi
if
[[
-n
"
$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
"
]]
HOMEBREW_RUBY_PATH
=
$(
find_ruby
)
if
[[
-z
"
$HOMEBREW_RUBY_PATH
"
||
-n
"
$HOMEBREW_FORCE_VENDOR_RUBY
"
]]
||
unusable_ruby
then
usable_ruby
=
true
elif
[[
-n
"
$HOMEBREW_RUBY_PATH
"
&&
-z
"
$HOMEBREW_FORCE_VENDOR_RUBY
"
]]
&&
test_ruby
"
$HOMEBREW_RUBY_PATH
"
then
usable_ruby
=
true
fi
if
[[
-z
"
$HOMEBREW_RUBY_PATH
"
||
-n
"
$HOMEBREW_FORCE_VENDOR_RUBY
"
||
-z
$usable_ruby
]]
then
brew vendor-install ruby
if
[[
!
-x
"
$vendor_ruby_path
"
]]
then
if
[[
-n
"
$HOMEBREW_MACOS
"
]]
then
odie
"Failed to install Homebrew Portable Ruby (and your system version is too old)!"
else
odie
"Failed to install Homebrew Portable Ruby and cannot find another Ruby
$required_ruby_version
!
$advice
"
fi
fi
brew vendor-install ruby
||
odie
"
$install_fail
"
HOMEBREW_RUBY_PATH
=
"
$vendor_ruby_path
"
[[
-z
"
$HOMEBREW_MACOS
"
]]
&&
TERMINFO_DIRS
=
"
$vendor_ruby_terminfo
"
TERMINFO_DIRS
=
"
$vendor_ruby_terminfo
"
fi
fi
export
HOMEBREW_RUBY_PATH
export
TERMINFO_DIRS
[[
-n
"
$HOMEBREW_LINUX
"
&&
-n
"
$TERMINFO_DIRS
"
]]
&&
export
TERMINFO_DIRS
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment