Simplify post-install audit output

This commit is contained in:
Jack Nagel 2014-10-13 23:13:00 -05:00
parent 09d53f4fc5
commit b46ebf8a29
3 changed files with 62 additions and 65 deletions

View File

@ -550,10 +550,8 @@ class FormulaAuditor
Symbol === dep ? dep.inspect : "'#{dep}'" Symbol === dep ? dep.inspect : "'#{dep}'"
end end
def audit_check_output warning_and_description def audit_check_output(output)
return unless warning_and_description problem(output) if output
warning, description = *warning_and_description
problem "#{warning}\n#{description}"
end end
def audit_installed def audit_installed

View File

@ -10,32 +10,32 @@ module FormulaCellarChecks
prefix_bin = prefix_bin.realpath prefix_bin = prefix_bin.realpath
return if ORIGINAL_PATHS.include? prefix_bin return if ORIGINAL_PATHS.include? prefix_bin
["#{prefix_bin} is not in your PATH", <<-EOS.undent
"You can amend this by altering your ~/.bashrc file"] #{prefix_bin} is not in your PATH
You can amend this by altering your ~/.bashrc file
EOS
end end
def check_manpages def check_manpages
# Check for man pages that aren't in share/man # Check for man pages that aren't in share/man
return unless (f.prefix+'man').directory? return unless (f.prefix+'man').directory?
['A top-level "man" directory was found.', <<-EOS.undent
<<-EOS.undent A top-level "man" directory was found
Homebrew requires that man pages live under share. Homebrew requires that man pages live under share.
This can often be fixed by passing "--mandir=\#{man}" to configure. This can often be fixed by passing "--mandir=\#{man}" to configure.
EOS EOS
]
end end
def check_infopages def check_infopages
# Check for info pages that aren't in share/info # Check for info pages that aren't in share/info
return unless (f.prefix+'info').directory? return unless (f.prefix+'info').directory?
['A top-level "info" directory was found.', <<-EOS.undent
<<-EOS.undent A top-level "info" directory was found
Homebrew suggests that info pages live under share. Homebrew suggests that info pages live under share.
This can often be fixed by passing "--infodir=\#{info}" to configure. This can often be fixed by passing "--infodir=\#{info}" to configure.
EOS EOS
]
end end
def check_jars def check_jars
@ -43,16 +43,15 @@ module FormulaCellarChecks
jars = f.lib.children.select { |g| g.extname == ".jar" } jars = f.lib.children.select { |g| g.extname == ".jar" }
return if jars.empty? return if jars.empty?
["JARs were installed to \"#{f.lib}\".", <<-EOS.undent
<<-EOS.undent JARs were installed to "#{f.lib}"
Installing JARs to "lib" can cause conflicts between packages. Installing JARs to "lib" can cause conflicts between packages.
For Java software, it is typically better for the formula to For Java software, it is typically better for the formula to
install to "libexec" and then symlink or wrap binaries into "bin". install to "libexec" and then symlink or wrap binaries into "bin".
See "activemq", "jruby", etc. for examples. See "activemq", "jruby", etc. for examples.
The offending files are: The offending files are:
#{jars * "\n "} #{jars * "\n "}
EOS EOS
]
end end
def check_non_libraries def check_non_libraries
@ -66,13 +65,12 @@ module FormulaCellarChecks
end end
return if non_libraries.empty? return if non_libraries.empty?
["Non-libraries were installed to \"#{f.lib}\".", <<-EOS.undent
<<-EOS.undent Non-libraries were installed to "#{f.lib}"
Installing non-libraries to "lib" is discouraged. Installing non-libraries to "lib" is discouraged.
The offending files are: The offending files are:
#{non_libraries * "\n "} #{non_libraries * "\n "}
EOS EOS
]
end end
def check_non_executables bin def check_non_executables bin
@ -81,12 +79,11 @@ module FormulaCellarChecks
non_exes = bin.children.select { |g| g.directory? or not g.executable? } non_exes = bin.children.select { |g| g.directory? or not g.executable? }
return if non_exes.empty? return if non_exes.empty?
["Non-executables were installed to \"#{bin}\".", <<-EOS.undent
<<-EOS.undent Non-executables were installed to "#{bin}"
The offending files are: The offending files are:
#{non_exes * "\n "} #{non_exes * "\n "}
EOS EOS
]
end end
def check_generic_executables bin def check_generic_executables bin
@ -95,16 +92,15 @@ module FormulaCellarChecks
generics = bin.children.select { |g| generic_names.include? g.basename.to_s } generics = bin.children.select { |g| generic_names.include? g.basename.to_s }
return if generics.empty? return if generics.empty?
["Generic binaries were installed to \"#{bin}\".", <<-EOS.undent
<<-EOS.undent Generic binaries were installed to "#{bin}"
Binaries with generic names are likely to conflict with other software, Binaries with generic names are likely to conflict with other software,
and suggest that this software should be installed to "libexec" and and suggest that this software should be installed to "libexec" and then
then symlinked as needed. symlinked as needed.
The offending files are: The offending files are:
#{generics * "\n "} #{generics * "\n "}
EOS EOS
]
end end
def check_shadowed_headers def check_shadowed_headers
@ -116,21 +112,25 @@ module FormulaCellarChecks
return if files.empty? return if files.empty?
["Header files that shadow system header files were installed to \"#{f.include}\".", <<-EOS.undent
"The offending files are: \n #{files * "\n "}"] Header files that shadow system header files were installed to "#{f.include}"
The offending files are:
#{files * "\n "}
EOS
end end
def check_easy_install_pth lib def check_easy_install_pth lib
pth_found = Dir["#{lib}/python{2.7,3.4}/site-packages/easy-install.pth"].map { |f| File.dirname(f) } pth_found = Dir["#{lib}/python{2.7,3.4}/site-packages/easy-install.pth"].map { |f| File.dirname(f) }
return if pth_found.empty? return if pth_found.empty?
["easy-install.pth files were found in #{pth_found.join(", ")}.", <<-EOS.undent
<<-EOS.undent easy-install.pth files were found
These .pth files are likely to cause link conflicts. Please These .pth files are likely to cause link conflicts. Please invoke
invoke setup.py with options --single-version-externally-managed setup.py with options
--record=install.txt. --single-version-externally-managed --record=install.txt
EOS The offending files are
] #{pth_found * "\n "}
EOS
end end
private private

View File

@ -639,12 +639,11 @@ class FormulaInstaller
## checks ## checks
def print_check_output warning_and_description def print_check_output(output)
return unless warning_and_description if output
warning, description = *warning_and_description opoo output
opoo warning @show_summary_heading = true
puts description end
@show_summary_heading = true
end end
def audit_bin def audit_bin