Clean pod2man-generated manpages after formula build
This commit is contained in:
		
							parent
							
								
									c5e2aa63e5
								
							
						
					
					
						commit
						652f5966d4
					
				@ -185,6 +185,8 @@ class Build
 | 
				
			|||||||
            # Find and link metafiles
 | 
					            # Find and link metafiles
 | 
				
			||||||
            formula.prefix.install_metafiles formula.buildpath
 | 
					            formula.prefix.install_metafiles formula.buildpath
 | 
				
			||||||
            formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
 | 
					            formula.prefix.install_metafiles formula.libexec if formula.libexec.exist?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            normalize_pod2man_outputs!(formula)
 | 
				
			||||||
          end
 | 
					          end
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
@ -214,6 +216,11 @@ class Build
 | 
				
			|||||||
  rescue
 | 
					  rescue
 | 
				
			||||||
    raise "#{formula.opt_prefix} not present or broken\nPlease reinstall #{formula.full_name}. Sorry :("
 | 
					    raise "#{formula.opt_prefix} not present or broken\nPlease reinstall #{formula.full_name}. Sorry :("
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def normalize_pod2man_outputs!(formula)
 | 
				
			||||||
 | 
					    keg = Keg.new(formula.prefix)
 | 
				
			||||||
 | 
					    keg.normalize_pod2man_outputs!
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
begin
 | 
					begin
 | 
				
			||||||
 | 
				
			|||||||
@ -554,6 +554,31 @@ class Keg
 | 
				
			|||||||
    path.find { |pn| FileUtils.rm_rf pn if pn.basename.to_s == "__pycache__" }
 | 
					    path.find { |pn| FileUtils.rm_rf pn if pn.basename.to_s == "__pycache__" }
 | 
				
			||||||
  end
 | 
					  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
 | 
					  def binary_executable_or_library_files
 | 
				
			||||||
    []
 | 
					    []
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user