def package_docs(package_site)
      site_map.sites.each do |site|
        next if not package_site == '' and not package_site == site.id
        site.distros.each do |distro_id,branches|
          branches.each do |branch|
            src_dir  = File.join(preview_dir,distro_id,branch.dir)
            tgt_tdir = branch.dir.split('/')
            tgt_tdir.pop
            tgt_dir  = ''
            if tgt_tdir.length > 0
              tgt_dir = File.join(package_dir,site.id,tgt_tdir.join('/'))
            else
              tgt_dir = File.join(package_dir,site.id)
            end
            next if not File.directory?(src_dir)
            FileUtils.mkdir_p(tgt_dir)
            FileUtils.cp_r(src_dir,tgt_dir)
          end
          site_dir = File.join(package_dir,site.id)
          if File.directory?(site_dir)
            log_unknown("Packaging #{distro_id} for #{site.id} site.")

            # Any files in the root of the docs repo with names ending in:
            #     *-#{site}.html
            # will get copied into the root dir of the packaged site with
            # the site name stripped out.
            #
            # Example: for site name 'commercial', the files:
            #     * index-commercial.html would end up as #{site_root}/index.html
            #     * search-commercial.html would end up as #{site_root}/search.html
            #     * index-community.html would be ignored
            site_files = Dir.glob(File.join(docs_root_dir, '*-' + site.id + '.html'))
            unless site_files.empty?
              site_files.each do |fpath|
                target_basename = File.basename(fpath).gsub(/-#{site.id}\.html$/, '.html')
                FileUtils.cp(fpath,File.join(package_dir,site.id,target_basename))
              end
            else
              FileUtils.cp(File.join(preview_dir,distro_id,'index.html'),File.join(package_dir,site.id,'index.html'))
            end
            ['_images','_stylesheets'].each do |support_dir|
              FileUtils.cp_r(File.join(docs_root_dir,support_dir),File.join(package_dir,site.id,support_dir))
            end

            # Now build a sitemap
            site_dir_path = Pathname.new(site_dir)
            SitemapGenerator::Sitemap.create(
              :default_host => site.url,
              :public_path  => site_dir_path,
              :compress     => false,
              :filename     => File.join(site_dir,'sitemap')
            ) do
              file_list = Find.find(site_dir).select{ |path| not path.nil? and path =~ /.*\.html$/ }.map{ |path| '/' + Pathname.new(path).relative_path_from(site_dir_path).to_s }
              file_list.each do |file|
                add(file, :changefreq => 'daily')
              end
            end
          end
        end
      end
    end
def package_docs(package_site)
      site_map.sites.each do |site|
        next if not package_site == '' and not package_site == site.id
        site.distros.each do |distro_id,branches|
          branches.each do |branch|
            src_dir  = File.join(preview_dir,distro_id,branch.dir)
            tgt_tdir = branch.dir.split('/')
            tgt_tdir.pop
            tgt_dir  = ''
            if tgt_tdir.length > 0
              tgt_dir = File.join(package_dir,site.id,tgt_tdir.join('/'))
            else
              tgt_dir = File.join(package_dir,site.id)
            end
            next if not File.directory?(src_dir)
            FileUtils.mkdir_p(tgt_dir)
            FileUtils.cp_r(src_dir,tgt_dir)
          end
          site_dir = File.join(package_dir,site.id)
          if File.directory?(site_dir)
            log_unknown("Packaging #{distro_id} for #{site.id} site.")

            # Any files in the root of the docs repo with names ending in:
            #     *-#{site}.html
            # will get copied into the root dir of the packaged site with
            # the site name stripped out.
            #
            # Example: for site name 'commercial', the files:
            #     * index-commercial.html would end up as #{site_root}/index.html
            #     * search-commercial.html would end up as #{site_root}/search.html
            #     * index-community.html would be ignored
            site_files = Dir.glob(File.join(docs_root_dir, '*-' + site.id + '.html'))
            unless site_files.empty?
              site_files.each do |fpath|
                target_basename = File.basename(fpath).gsub(/-#{site.id}\.html$/, '.html')
                FileUtils.cp(fpath,File.join(package_dir,site.id,target_basename))
              end
            else
              FileUtils.cp(File.join(preview_dir,distro_id,'index.html'),File.join(package_dir,site.id,'index.html'))
            end
            ['_images','_stylesheets'].each do |support_dir|
              FileUtils.cp_r(File.join(docs_root_dir,support_dir),File.join(package_dir,site.id,support_dir))
            end

            # Now build a sitemap
            site_dir_path = Pathname.new(site_dir)
            SitemapGenerator::Sitemap.create(
              :default_host => site.url,
              :public_path  => site_dir_path,
              :compress     => false,
              :filename     => File.join(site_dir,'sitemap')
            ) do
              file_list = Find.find(site_dir).select{ |path| not path.nil? and path =~ /.*\.html$/ }.map{ |path| '/' + Pathname.new(path).relative_path_from(site_dir_path).to_s }
              file_list.each do |file|
                add(file, :changefreq => 'daily')
              end
            end
          end
        end
      end
    end
package_docs
 This method generates the docs and then organizes them the way they will be arranged
 for the production websites.