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
54618074
Commit
54618074
authored
12 years ago
by
Adam Vandenberg
Browse files
Options
Downloads
Patches
Plain Diff
Stop stripping binary files
parent
4ffc06f9
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/cleaner.rb
+22
-35
22 additions, 35 deletions
Library/Homebrew/cleaner.rb
with
22 additions
and
35 deletions
Library/Homebrew/cleaner.rb
+
22
−
35
View file @
54618074
# Cleans a newly installed keg.
# By default:
# * removes info files
# * removes .la files
# * removes empty directories
# * sets permissions on executables
class
Cleaner
# Create a cleaner for the given formula name, and clean the keg
def
initialize
f
@f
=
Formula
.
factory
f
[
f
.
bin
,
f
.
sbin
,
f
.
lib
].
select
{
|
d
|
d
.
exist?
}.
each
{
|
d
|
clean_dir
d
}
...
...
@@ -14,9 +22,8 @@ class Cleaner
f
.
info
.
rmtree
if
f
.
info
.
directory?
and
not
f
.
skip_clean?
f
.
info
end
# Hunt for empty folders and nuke them unless they are protected by
# f.skip_clean? We want post-order traversal, so put the dirs in a stack
# and then pop them off later.
# Remove empty folders.
# We want post-order traversal, so use a stack.
paths
=
[]
f
.
prefix
.
find
do
|
path
|
paths
<<
path
if
path
.
directory?
...
...
@@ -32,56 +39,36 @@ class Cleaner
private
def
strip
path
,
args
=
''
return
if
@f
.
skip_clean?
path
puts
"strip
#{
path
}
"
if
ARGV
.
verbose?
path
.
chmod
0644
# so we can strip
unless
path
.
stat
.
nlink
>
1
system
"
#{
MacOS
.
locate
(
'strip'
)
}
"
,
*
(
args
+
path
)
# Set permissions for executables and non-executables
def
clean_file_permissions
path
perms
=
if
path
.
mach_o_executable?
||
path
.
text_executable?
0555
else
path
=
path
.
to_s
.
gsub
' '
,
'\\ '
# strip unlinks the file and recreates it, thus breaking hard links!
# is this expected behaviour? patch does it too… still, this fixes it
tmp
=
`/usr/bin/mktemp -t homebrew_strip`
.
chomp
begin
`
#{
MacOS
.
locate
(
'strip'
)
}
#{
args
}
-o
#{
tmp
}
#{
path
}
`
`/bin/cat
#{
tmp
}
>
#{
path
}
`
ensure
FileUtils
.
rm
tmp
end
end
end
def
clean_file
path
perms
=
0444
if
path
.
dylib?
# Stripping libraries is causing no end of trouble. Lets just give up,
# and try to do it manually in instances where it makes sense.
#strip path, '-SxX'
elsif
path
.
mach_o_executable?
strip
path
perms
=
0555
elsif
path
.
text_executable?
perms
=
0555
0444
end
path
.
chmod
perms
end
# Clean a single folder (non-recursively)
def
clean_dir
d
d
.
find
do
|
path
|
if
path
.
directory?
# Stop cleaning this subtree if protected
Find
.
prune
if
@f
.
skip_clean?
path
elsif
not
path
.
file?
# Sanity?
next
elsif
path
.
extname
==
'.la'
# *.la files are stupid
path
.
unlink
unless
@f
.
skip_clean?
path
elsif
path
==
@f
.
lib
+
'charset.alias'
# Many formulae symlink this file, but it is not strictly needed
path
.
unlink
unless
@f
.
skip_clean?
path
elsif
not
path
.
symlink?
clean_file
path
# Fix permissions
clean_file_permissions
path
end
end
end
end
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