12 def build_used_package_list(source_uri)
13 source_uri.map do |source_uri|
14 fetch_file(source_uri).split("\n").reject do |l|
15 l.strip.start_with?('#') or l.strip == ""
20 def parse_debian_sources(data)
21 data.split("\n").push('').inject({}) do |pkgs, l|
23 pkg = pkgs[:_tmp] || {}
26 pkg[:_tmp][:data] << l.strip
28 pkg[pkg[:_tmp][:hdr]] = pkg[:_tmp][:data].compact
34 pkgs[pkg['Package'][0]] = pkg
37 hdr, data = l.strip.split(':', 2)
38 data.strip! unless data.nil?
39 pkg[:_tmp] = {:hdr => hdr, :data => [data]}
51 def build_package_list(repos, used, sources)
53 repos.each do |pkg, path|
54 g = Git.bare(working_dir = path)
55 next if not g.ls_tree('HEAD')["tree"].keys.include?("debian")
57 current_head = g.gcommit('HEAD')
58 next if not current_head.parent
61 :head_is_tagged => false,
66 :version_in_repo => nil
69 p[:used][dist] = l.include?(pkg)
72 p[:version_in_repo] = sources[pkg]['Version'][0]
75 for tag in g.tags.reverse
77 t = g.gcommit(tag.name)
79 #$stderr.puts "#{pkg}: Checking tag #{tag.name}: tag parent: #{t.parent.sha} HEAD: #{current_head.parent.sha}"
80 if t.parent.sha === current_head.parent.sha
81 p[:head_is_tagged] = true
82 p[:version] = tag.name
93 response = Net::HTTP.get_response(URI.parse(uri))
96 body = Zlib::GzipReader.new(StringIO.new(body.to_s)).read
101 def update_git_repos(git_repos)
102 git_repos.each do |name, path|
103 out = %x{cd #{path} && git remote update --prune}
104 puts "#{name}: " + out if DEBUG
108 template = ERB.new <<-EOF
111 <meta charset="utf-8">
112 <title>Grml.org Package Index</title>
113 <link rel="stylesheet" href="style.css">
117 <h1>All Grml packages</h1>
118 <p>Last update: <%= Time.now.to_s %></p>
123 <th>Package</th><th>Git</th><th>Download</th><th>Git Fresh?</th><th>grml-testing</th><th>In FULL?</th>
125 <% packages.keys.sort.each do |pn|
129 <td><%= p[:name] %></td>
130 <td class="git"><a href="http://git.grml.org/?p=<%= p[:name] %>.git;a=summary">Git</a></td>
131 <td class="download">
132 <% if p[:has_tags] %>
133 <a href="http://deb.grml.org/pool/main/<%= p[:name][0..0] %>/<%= p[:name] %>/">Download</a>
136 <% if p[:head_is_tagged] %>
137 <td class="ok">Version <%= p[:version] %></td>
139 <td class="error <% if p[:used][:full] %>important<% end %>">Untagged changes</td>
141 <td><%= p[:version_in_repo] || "" %></td>
142 <td class="installed"><%= p[:used][:full] ? "Yes" : "No" %></td>
154 :full => build_used_package_list([
155 'http://git.grml.org/?p=grml-live.git;a=blob_plain;f=etc/grml/fai/config/package_config/GRMLBASE',
156 'http://git.grml.org/?p=grml-live.git;a=blob_plain;f=etc/grml/fai/config/package_config/GRML_FULL',
159 sources = parse_debian_sources(fetch_file('http://deb.grml.org/dists/grml-testing/main/source/Sources.gz'))
161 git_repos = Hash[*(Dir.glob('git/*.git').map do |p| [File.basename(p, '.git'), p] end.flatten)]
163 update_git_repos git_repos
165 packages = build_package_list(git_repos, used_packages, sources)
167 File.open('index.html.new','w') do |f|
168 f.write template.result(binding)
170 File.open('packages.yaml.new','w') do |f|
171 f.write packages.to_yaml
174 FileUtils.mv 'index.html.new', 'index.html'
175 FileUtils.mv 'packages.yaml.new', 'packages.yaml'