[PATCH/foreman 1/1] Fixes #1198 - puppetdoc issues

Signed-off-by: Paul Kelly <paul.ian.kelly@googlemail.com>

··· From: Paul Kelly --- app/models/puppetclass.rb | 7 ++++--- extras/rdoc/rdoc_prepare_script.rb | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/app/models/puppetclass.rb b/app/models/puppetclass.rb
index 9801935…4158629 100644
— a/app/models/puppetclass.rb
+++ b/app/models/puppetclass.rb
@@ -90,6 +90,7 @@ class Puppetclass < ActiveRecord::Base
def self.rdoc root
debug, verbose = false, false
relocated = root != “/” # This is true if the prepare phase copied the modules tree

  • verbose false

    Retrieve an optional http server’s DocumentRoot from the settings.yaml file, and prepare it for writing

    doc_root = Pathname.new(Setting[:document_root])
    @@ -118,11 +119,11 @@ class Puppetclass < ActiveRecord::Base
    sh cmd do |ok, res|
    if ok
    # Add a link to the class browser

  •      files =  %x{find #{out} -exec grep -l 'validator-badges' {} \\; 2>/dev/null}.gsub(/\n/, " ")
    
  •      files =  %x{find #{out} -exec grep -l 'validator-badges' {} \\; 2>/dev/null}.split(/\n/)
         if files.empty?
           warn "No files to update with the browser link in #{out}. This is probably due to a previous error."
         else
    
  •        cmd = "ruby -p -i -e '$_.gsub!(/#{validator}/,\"#{replacement}\")' #{files}"
    
  •        cmd = "ruby -p -i -e '$_.gsub!(/#{validator}/,\"#{replacement}\")' #{files.map{|f| "'#{f}'"}.join(" ")}"
           puts cmd if debug
          sh cmd
         end
    

@@ -133,7 +134,7 @@ class Puppetclass < ActiveRecord::Base
puts cmd if debug
sh cmd
# Now relocate the files/* files to match the rewritten url

  •        mv Dir.glob("#{out}/files/#{root}/*"), "#{out}/files", :verbose => verbose
    
  •        FileUtils.cp_r Dir.glob("#{out}/files/#{root}/*"), "#{out}/files", :verbose => verbose
         end
       else
         logger.warn "Failed to process puppetdocs for #{out} while executing #{cmd}"
    

diff --git a/extras/rdoc/rdoc_prepare_script.rb b/extras/rdoc/rdoc_prepare_script.rb
index 2b4dbcf…c7f19be 100755
— a/extras/rdoc/rdoc_prepare_script.rb
+++ b/extras/rdoc/rdoc_prepare_script.rb
@@ -1,4 +1,5 @@
#!/usr/bin/ruby
+#require ‘pathname’ Pathname just does not work!!!
verbose = false
require ‘fileutils’

Takes a list of directories and copies them, ignoring version control directories, to a new location

@@ -12,10 +13,10 @@ dirs = ARGV[0…100]

We need to copy in the checked out puppet modules tree. Skipping all the .svn entries.

modules = “/etc/puppet/modules”
-exit -1 unless system “tar --create --file - --exclude-vcs #{modules[1…-1]} | tar --extract --file - --read-full-records --directory #{modules_root}”
+exit -1 unless system “tar --create --file - --exclude=.svn #{modules[1…-1]} | tar --extract --file - --read-full-records --directory #{modules_root}”

This copies in the /etc/puppent/env directory symlink trees

-exit -1 unless system “tar --create --file - --exclude-vcs #{dirs.map{|d| d[1…-1]}.join(” “)} | tar --extract --file - --read-full-records --directory #{modules_root}”
+exit -1 unless system “tar --create --file - --exclude=.svn #{dirs.map{|d| d[1…-1]}.join(” ")} | tar --extract --file - --read-full-records --directory #{modules_root}"
for dir in dirs
here = modules_root + dir

Scan each modulepath for symlinks and remove them if they point at “.”.

@@ -41,7 +42,7 @@ for link in links
next
end

Remove links pointing to “.”

  • if File.readlink(link) =~ /.|,//
  • if File.readlink(link) =~ /^.$|^./$/
    File.unlink(link)
    puts “Removing #{link}” if verbose
    else

    1.7.4.1