mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Merge pull request #19174 from alebcay/pod2man-shim
Clean pod2man-generated manpages after formula build
This commit is contained in:
commit
0c2c76351c
@ -188,6 +188,8 @@ class Build
|
||||
# Find and link metafiles
|
||||
formula.prefix.install_metafiles formula.buildpath
|
||||
formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
|
||||
|
||||
normalize_pod2man_outputs!(formula)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -217,6 +219,11 @@ class Build
|
||||
rescue
|
||||
raise "#{formula.opt_prefix} not present or broken\nPlease reinstall #{formula.full_name}. Sorry :("
|
||||
end
|
||||
|
||||
def normalize_pod2man_outputs!(formula)
|
||||
keg = Keg.new(formula.prefix)
|
||||
keg.normalize_pod2man_outputs!
|
||||
end
|
||||
end
|
||||
|
||||
begin
|
||||
|
@ -555,6 +555,31 @@ class Keg
|
||||
path.find { |pn| FileUtils.rm_rf pn if pn.basename.to_s == "__pycache__" }
|
||||
end
|
||||
|
||||
def normalize_pod2man_outputs!
|
||||
manpages = Dir[path/"share/man/*/*"]
|
||||
generated_regex = /^\.\\"\s*Automatically generated by .*\n/
|
||||
manpages.each do |f|
|
||||
manpage = Pathname.new(f)
|
||||
next unless manpage.file?
|
||||
|
||||
content = manpage.read
|
||||
content = content.gsub(generated_regex, "")
|
||||
content = content.lines.map do |line|
|
||||
next line unless line.start_with?(".TH")
|
||||
|
||||
# Split the line by spaces, but preserve quoted strings
|
||||
parts = line.split(/\s(?=(?:[^"]|"[^"]*")*$)/)
|
||||
next line if parts.length != 6
|
||||
|
||||
# pod2man embeds the perl version used into the 5th field of the footer
|
||||
T.must(parts[4]).gsub!(/^"perl v.*"$/, "\"\"")
|
||||
"#{parts.join(" ")}\n"
|
||||
end.join
|
||||
|
||||
manpage.atomic_write(content)
|
||||
end
|
||||
end
|
||||
|
||||
def binary_executable_or_library_files
|
||||
[]
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user