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
ad01b141
Commit
ad01b141
authored
15 years ago
by
Ben Alpert
Browse files
Options
Downloads
Patches
Plain Diff
Don't use file, just check the magic numbers instead
Closes Homebrew/homebrew#58
parent
e339a2a7
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/download_strategy.rb
+8
-4
8 additions, 4 deletions
Library/Homebrew/download_strategy.rb
with
8 additions
and
4 deletions
Library/Homebrew/download_strategy.rb
+
8
−
4
View file @
ad01b141
...
...
@@ -49,12 +49,15 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
return
@dl
# thus performs checksum verification
end
def
stage
case
`file -b
#{
@dl
}
`
when
/^Zip archive data/
# magic numbers stolen from /usr/share/file/magic/
File
.
open
(
@dl
)
do
|
f
|
# get the first four bytes
case
f
.
read
(
4
)
when
/^PK\003\004/
# .zip archive
safe_system
'/usr/bin/unzip'
,
'-qq'
,
@dl
chdir
when
/^
(
gzip
|
bz
ip2)
compressed
data/
# TODO
do file -z now to see if it is in fact a tar
when
/^
\037\213/
,
/^BZh/
#
gzip
/
bz
2
compressed
# TODO
check if it's really a tar archive
safe_system
'/usr/bin/tar'
,
'xf'
,
@dl
chdir
else
...
...
@@ -64,6 +67,7 @@ class HttpDownloadStrategy <AbstractDownloadStrategy
# HOWEVER if this breaks some expectation you had we *will* change the
# behaviour, just open an issue at github
FileUtils
.
mv
@dl
,
File
.
basename
(
@url
)
end
end
end
private
...
...
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