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
2c6e93cf
Commit
2c6e93cf
authored
13 years ago
by
Jack Nagel
Browse files
Options
Downloads
Patches
Plain Diff
audit: handle new formula specs
parent
64209435
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/cmd/audit.rb
+35
-54
35 additions, 54 deletions
Library/Homebrew/cmd/audit.rb
with
35 additions
and
54 deletions
Library/Homebrew/cmd/audit.rb
+
35
−
54
View file @
2c6e93cf
...
...
@@ -195,20 +195,6 @@ def audit_formula_options f, text
return
problems
end
def
audit_formula_version
f
,
text
# Version as defined in the DSL (or nil)
version_text
=
f
.
class
.
send
(
'version'
).
to_s
# Version as determined from the URL
version_url
=
Pathname
.
new
(
f
.
url
).
version
if
version_url
==
version_text
return
[
" * version
#{
version_text
}
is redundant with version scanned from url"
]
end
return
[]
end
def
audit_formula_patches
f
problems
=
[]
patches
=
Patches
.
new
(
f
.
patches
)
...
...
@@ -238,8 +224,7 @@ def audit_formula_urls f
problems
<<
" * Google Code homepage should end with a slash."
end
urls
=
[(
f
.
url
rescue
nil
),
(
f
.
head
rescue
nil
)].
reject
{
|
p
|
p
.
nil?
}
urls
.
uniq!
# head-only formulae result in duplicate entries
urls
=
[(
f
.
stable
.
url
rescue
nil
),
(
f
.
devel
.
url
rescue
nil
),
(
f
.
head
.
url
rescue
nil
)].
reject
{
|
p
|
p
.
nil?
}
# Check GNU urls; doesn't apply to mirrors
urls
.
each
do
|
p
|
...
...
@@ -249,10 +234,8 @@ def audit_formula_urls f
end
# the rest of the checks apply to mirrors as well
f
.
mirrors
.
each
do
|
m
|
mirror
=
m
.
values_at
:url
urls
<<
(
mirror
.
to_s
rescue
nil
)
end
mirrors
=
[(
f
.
stable
.
mirrors
rescue
[]),
(
f
.
devel
.
mirrors
rescue
[])].
flatten
.
reject
{
|
m
|
m
.
nil?
}
urls
.
concat
mirrors
.
map
{
|
m
|
m
[
:url
]
}
# Check SourceForge urls
urls
.
each
do
|
p
|
...
...
@@ -290,19 +273,40 @@ def audit_formula_urls f
return
problems
end
def
audit_formula_specs
text
def
audit_formula_specs
f
problems
=
[]
if
text
=~
/devel .+(url '.+').+(url '.+')/m
problems
<<
" * 'devel' block found before stable 'url'"
end
[
:stable
,
:devel
].
each
do
|
spec
|
s
=
f
.
send
(
spec
)
next
if
s
.
nil?
if
text
=~
/devel .+(head '.+')/m
problems
<<
" * 'devel' block found before 'head'"
end
if
s
.
version
.
to_s
.
empty?
problems
<<
" * invalid or missing
#{
spec
}
version"
else
version_text
=
s
.
version
if
s
.
explicit_version?
version_url
=
Pathname
.
new
(
s
.
url
).
version
if
version_url
==
version_text
problems
<<
" *
#{
spec
}
version
#{
version_text
}
is redundant with version scanned from URL"
end
end
if
text
=~
/devel do\s+end/
problems
<<
" * Empty 'devel' block found"
cksum
=
s
.
checksum_type
unless
cksum
.
nil?
hash
=
s
.
send
(
cksum
).
strip
len
=
case
cksum
when
:md5
then
32
when
:sha1
then
40
when
:sha256
then
64
end
if
hash
.
empty?
problems
<<
" *
#{
cksum
}
is empty"
else
problems
<<
" *
#{
cksum
}
should be
#{
len
}
characters"
unless
hash
.
length
==
len
problems
<<
" *
#{
cksum
}
contains invalid characters"
unless
hash
=~
/^[a-fA-F0-9]+$/
problems
<<
" *
#{
cksum
}
should be lowercase"
unless
hash
==
hash
.
downcase
end
end
end
return
problems
...
...
@@ -337,35 +341,13 @@ EOS
end
end
problems
+=
[
' * invalid or missing version'
]
if
f
.
version
.
to_s
.
empty?
%w[md5 sha1 sha256]
.
each
do
|
checksum
|
hash
=
f
.
instance_variable_get
(
"@
#{
checksum
}
"
)
next
if
hash
.
nil?
hash
=
hash
.
strip
len
=
case
checksum
when
'md5'
then
32
when
'sha1'
then
40
when
'sha256'
then
64
end
if
hash
.
empty?
problems
<<
" *
#{
checksum
}
is empty"
else
problems
<<
" *
#{
checksum
}
should be
#{
len
}
characters"
unless
hash
.
length
==
len
problems
<<
" *
#{
checksum
}
contains invalid characters"
unless
hash
=~
/^[a-fA-F0-9]+$/
problems
<<
" *
#{
checksum
}
should be lowercase"
unless
hash
==
hash
.
downcase
end
end
return
problems
end
# Formula extensions for auditing
class
Formula
def
head_only?
@
unstable
and
@sta
ndard
.
nil?
@
head
and
@sta
ble
.
nil?
end
def
formula_text
...
...
@@ -412,8 +394,7 @@ module Homebrew extend self
problems
+=
audit_formula_text
(
f
.
name
,
text_without_patch
)
problems
+=
audit_formula_options
(
f
,
text_without_patch
)
problems
+=
audit_formula_version
(
f
,
text_without_patch
)
problems
+=
audit_formula_specs
(
text_without_patch
)
problems
+=
audit_formula_specs
(
f
)
unless
problems
.
empty?
errors
=
true
...
...
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