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
fab2cffe
Commit
fab2cffe
authored
8 years ago
by
Josh Hagins
Browse files
Options
Downloads
Patches
Plain Diff
keg_relocate: wrap relocation locations in struct
parent
adc4b1f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Library/Homebrew/extend/os/mac/keg_relocate.rb
+6
-6
6 additions, 6 deletions
Library/Homebrew/extend/os/mac/keg_relocate.rb
Library/Homebrew/keg_relocate.rb
+37
-18
37 additions, 18 deletions
Library/Homebrew/keg_relocate.rb
with
43 additions
and
24 deletions
Library/Homebrew/extend/os/mac/keg_relocate.rb
+
6
−
6
View file @
fab2cffe
...
@@ -17,19 +17,19 @@ class Keg
...
@@ -17,19 +17,19 @@ class Keg
generic_fix_dynamic_linkage
generic_fix_dynamic_linkage
end
end
def
relocate_dynamic_linkage
(
old_prefix
,
new_prefix
,
old_cellar
,
new_cellar
)
def
relocate_dynamic_linkage
(
relocation
)
mach_o_files
.
each
do
|
file
|
mach_o_files
.
each
do
|
file
|
file
.
ensure_writable
do
file
.
ensure_writable
do
if
file
.
dylib?
if
file
.
dylib?
id
=
dylib_id_for
(
file
).
sub
(
old_prefix
,
new_prefix
)
id
=
dylib_id_for
(
file
).
sub
(
relocation
.
old_prefix
,
relocation
.
new_prefix
)
change_dylib_id
(
id
,
file
)
change_dylib_id
(
id
,
file
)
end
end
each_install_name_for
(
file
)
do
|
old_name
|
each_install_name_for
(
file
)
do
|
old_name
|
if
old_name
.
start_with?
old_cellar
if
old_name
.
start_with?
relocation
.
old_cellar
new_name
=
old_name
.
sub
(
old_cellar
,
new_cellar
)
new_name
=
old_name
.
sub
(
relocation
.
old_cellar
,
relocation
.
new_cellar
)
elsif
old_name
.
start_with?
old_prefix
elsif
old_name
.
start_with?
relocation
.
old_prefix
new_name
=
old_name
.
sub
(
old_prefix
,
new_prefix
)
new_name
=
old_name
.
sub
(
relocation
.
old_prefix
,
relocation
.
new_prefix
)
end
end
change_install_name
(
old_name
,
new_name
,
file
)
if
new_name
change_install_name
(
old_name
,
new_name
,
file
)
if
new_name
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/keg_relocate.rb
+
37
−
18
View file @
fab2cffe
...
@@ -3,6 +3,14 @@ class Keg
...
@@ -3,6 +3,14 @@ class Keg
CELLAR_PLACEHOLDER
=
"@@HOMEBREW_CELLAR@@"
.
freeze
CELLAR_PLACEHOLDER
=
"@@HOMEBREW_CELLAR@@"
.
freeze
REPOSITORY_PLACEHOLDER
=
"@@HOMEBREW_REPOSITORY@@"
.
freeze
REPOSITORY_PLACEHOLDER
=
"@@HOMEBREW_REPOSITORY@@"
.
freeze
Relocation
=
Struct
.
new
(
:old_prefix
,
:old_cellar
,
:old_repository
,
:new_prefix
,
:new_cellar
,
:new_repository
)
do
# Use keyword args instead of positional args for initialization
def
initialize
(
**
kwargs
)
super
(
*
members
.
map
{
|
k
|
kwargs
[
k
]
})
end
end
def
fix_dynamic_linkage
def
fix_dynamic_linkage
symlink_files
.
each
do
|
file
|
symlink_files
.
each
do
|
file
|
link
=
file
.
readlink
link
=
file
.
readlink
...
@@ -15,38 +23,49 @@ class Keg
...
@@ -15,38 +23,49 @@ class Keg
end
end
alias
generic_fix_dynamic_linkage
fix_dynamic_linkage
alias
generic_fix_dynamic_linkage
fix_dynamic_linkage
def
relocate_dynamic_linkage
(
_
old_prefix
,
_new_prefix
,
_old_cellar
,
_new_cellar
)
def
relocate_dynamic_linkage
(
_
relocation
)
[]
[]
end
end
def
replace_locations_with_placeholders
def
replace_locations_with_placeholders
relocate_dynamic_linkage
(
HOMEBREW_PREFIX
.
to_s
,
PREFIX_PLACEHOLDER
,
relocation
=
Relocation
.
new
(
HOMEBREW_CELLAR
.
to_s
,
CELLAR_PLACEHOLDER
)
old_prefix:
HOMEBREW_PREFIX
.
to_s
,
replacements
=
{
old_cellar:
HOMEBREW_CELLAR
.
to_s
,
HOMEBREW_PREFIX
.
to_s
=>
PREFIX_PLACEHOLDER
,
old_repository:
HOMEBREW_REPOSITORY
.
to_s
,
HOMEBREW_CELLAR
.
to_s
=>
CELLAR_PLACEHOLDER
,
new_prefix:
PREFIX_PLACEHOLDER
,
HOMEBREW_REPOSITORY
.
to_s
=>
REPOSITORY_PLACEHOLDER
,
new_cellar:
CELLAR_PLACEHOLDER
,
}
new_repository:
REPOSITORY_PLACEHOLDER
replace_text_in_files
(
replacements
)
)
relocate_dynamic_linkage
(
relocation
)
replace_text_in_files
(
relocation
)
end
end
def
replace_placeholders_with_locations
(
files
)
def
replace_placeholders_with_locations
(
files
)
relocate_dynamic_linkage
(
PREFIX_PLACEHOLDER
,
HOMEBREW_PREFIX
.
to_s
,
relocation
=
Relocation
.
new
(
CELLAR_PLACEHOLDER
,
HOMEBREW_CELLAR
.
to_s
)
old_prefix:
PREFIX_PLACEHOLDER
,
replacements
=
{
old_cellar:
CELLAR_PLACEHOLDER
,
PREFIX_PLACEHOLDER
=>
HOMEBREW_PREFIX
.
to_s
,
old_repository:
REPOSITORY_PLACEHOLDER
,
CELLAR_PLACEHOLDER
=>
HOMEBREW_CELLAR
.
to_s
,
new_prefix:
HOMEBREW_PREFIX
.
to_s
,
REPOSITORY_PLACEHOLDER
=>
HOMEBREW_REPOSITORY
.
to_s
,
new_cellar:
HOMEBREW_CELLAR
.
to_s
,
}
new_repository:
HOMEBREW_REPOSITORY
.
to_s
replace_text_in_files
(
replacements
,
files
)
)
relocate_dynamic_linkage
(
relocation
)
replace_text_in_files
(
relocation
,
files:
files
)
end
end
def
replace_text_in_files
(
re
placements
,
files
=
nil
)
def
replace_text_in_files
(
re
location
,
files
:
nil
)
files
||=
text_files
|
libtool_files
files
||=
text_files
|
libtool_files
changed_files
=
[]
changed_files
=
[]
files
.
map
(
&
path
.
method
(
:join
)).
group_by
{
|
f
|
f
.
stat
.
ino
}.
each_value
do
|
first
,
*
rest
|
files
.
map
(
&
path
.
method
(
:join
)).
group_by
{
|
f
|
f
.
stat
.
ino
}.
each_value
do
|
first
,
*
rest
|
s
=
first
.
open
(
"rb"
,
&
:read
)
s
=
first
.
open
(
"rb"
,
&
:read
)
replacements
=
{
relocation
.
old_prefix
=>
relocation
.
new_prefix
,
relocation
.
old_cellar
=>
relocation
.
new_cellar
,
relocation
.
old_repository
=>
relocation
.
new_repository
,
}
regexp
=
Regexp
.
union
(
replacements
.
keys
)
regexp
=
Regexp
.
union
(
replacements
.
keys
)
changed
=
s
.
gsub!
(
regexp
,
replacements
)
changed
=
s
.
gsub!
(
regexp
,
replacements
)
...
...
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