Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 11440be355
Fetching contributors…

Cannot retrieve contributors at this time

file 59 lines (54 sloc) 2.025 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
#!/usr/bin/env ruby

OverlayRoot = '../'
ExcludeDirs = [ 'licenses', 'profiles', 'scripts' ]

class String
  def dir_entries
    output = []
    Dir.entries(self).each do |entry|
      output << entry if ! entry.match(/^\./) and File.directory?(self + '/' + entry)
    end
    return output
  end
end

# Parse overlay
overlay = {}
OverlayRoot.dir_entries.each do |category|
  if ! ExcludeDirs.include?(category) then
    overlay[category] = []
    (OverlayRoot + '/' + category).dir_entries.each do |name|
      package = {}
      package[:name] = name
      Dir.entries(OverlayRoot + '/' + category + '/' + name).each do |ebuild|
        package[:version] = [] if ! package[:version]
        package[:version] << ebuild.sub(name + '-', '').sub('.ebuild', '') if ebuild.match(name)
      end
      ebuild = "#{OverlayRoot}/#{category}/#{package[:name]}/#{package[:name]}-#{package[:version].first}.ebuild"
      File.open(ebuild, 'r').readlines.each do |line|
        package[:homepage] = line.gsub('"', '').sub('HOMEPAGE=', '').chomp if line.match('HOMEPAGE')
        package[:description] = line.gsub('"', '').sub('DESCRIPTION=', '').chomp if line.match('DESCRIPTION')
      end
      overlay[category] << package
    end
  end
end

# Generate README
readme = File.open(OverlayRoot + '/README.md', 'w')
readme.puts "## Usage\n\n layman -f\n layman -a scrill\n\n"
readme.puts "## Content\n"
overlay.keys.sort.each do |category|
  readme.puts "\n #{category} {"
  overlay[category].each do |package|
    readme.puts
    readme.puts " #{package[:name]} {"
    if package[:version].size > 1
      readme.puts " version => [ \"#{package[:version].sort.join('", "')}\" ]" + ','
    else
      readme.puts " version => \"#{package[:version].sort.join('", "')}\"" + ','
    end
    readme.puts " description => \"#{package[:description]}\"" + ','
    readme.puts " homepage => \"#{package[:homepage]}\""
    readme.puts " }"
  end
  readme.puts "\n }"
end

readme.close
Something went wrong with that request. Please try again.