10 def build_used_package_list(source_files)
11 source_files.map do |source_file|
12 File.read(source_file).split("\n").reject do |l|
13 l.strip.start_with?('#') or l.strip == ""
18 def parse_debian_sources(data)
19 data.split("\n").push('').inject({}) do |pkgs, l|
21 pkg = pkgs[:_tmp] || {}
24 pkg[:_tmp][:data] << l.strip
26 pkg[pkg[:_tmp][:hdr]] = pkg[:_tmp][:data].compact
32 pkgs[pkg['Package'][0]] = pkg
35 hdr, data = l.strip.split(':', 2)
36 data.strip! unless data.nil?
37 pkg[:_tmp] = {:hdr => hdr, :data => [data]}
49 def build_package_list(packages, used, sources)
51 packages.each do |pkg|
52 next if not File.exists?(File.join(pkg, 'debian'))
54 g = Git.open(working_dir = pkg)
55 #g.pull(Git::Repo, Git::Branch) # fetch and a merge
57 g = Git.bare(working_dir = pkg)
60 current_head = g.gcommit('HEAD')
61 next if not current_head.parent
64 :head_is_tagged => false,
69 :version_in_repo => nil
72 p[:used][dist] = l.include?(pkg)
75 p[:version_in_repo] = sources[pkg]['Version'][0]
78 for tag in g.tags.reverse
80 t = g.gcommit(tag.name)
82 #$stderr.puts "#{pkg}: Checking tag #{tag.name}: tag parent: #{t.parent.sha} HEAD: #{current_head.parent.sha}"
83 if t.parent.sha === current_head.parent.sha
84 p[:head_is_tagged] = true
85 p[:version] = tag.name
96 response = Net::HTTP.get_response(URI.parse(uri))
99 body = Zlib::GzipReader.new(StringIO.new(body.to_s)).read
104 template = ERB.new <<-EOF
107 <meta charset="utf-8">
108 <title>Grml.org Package Index</title>
109 <link rel="stylesheet" href="style.css">
113 <h1>All Grml packages</h1>
114 <p>Last update: <%= Time.now.to_s %></p>
119 <th>Package</th><th>Git</th><th>Download</th><th>Fresh?</th><th>grml-testing</th><th>In FULL?</th>
121 <% packages.keys.sort.each do |pn|
125 <td><%= p[:name] %></td>
126 <td class="git"><a href="http://git.grml.org/?p=<%= p[:name] %>.git;a=summary">Git</a></td>
127 <td class="download">
128 <% if p[:has_tags] %>
129 <a href="http://deb.grml.org/pool/main/<%= p[:name][0..0] %>/<%= p[:name] %>/">Download</a>
132 <% if p[:head_is_tagged] %>
133 <td class="ok">Version <%= p[:version] %></td>
135 <td class="error <% if p[:used][:full] %>important<% end %>">Untagged changes</td>
137 <td><%= p[:version_in_repo] || "" %></td>
138 <td class="installed"><%= p[:used][:full] ? "Yes" : "No" %></td>
150 :full => build_used_package_list(['grml-live/etc/grml/fai/config/package_config/GRMLBASE', 'grml-live/etc/grml/fai/config/package_config/GRML_FULL']),
152 sources = parse_debian_sources(fetch_file('http://deb.grml.org/dists/grml-testing/main/source/Sources.gz'))
154 packages = build_package_list(ARGV, used_packages, sources)
156 File.open('index.html.new','w') do |f|
157 f.write template.result(binding)
159 File.open('packages.yaml.new','w') do |f|
160 f.write packages.to_yaml
163 FileUtils.mv 'index.html.new', 'index.html'
164 FileUtils.mv 'packages.yaml.new', 'packages.yaml'