From 25a570d1c8898b0a17631dbdcbeb5b244f51a4e3 Mon Sep 17 00:00:00 2001 From: Christian Hofstaedtler Date: Mon, 28 Nov 2011 22:16:05 +0100 Subject: [PATCH] Initial import from packages.grml.org --- style.css | 17 ++++++++++ update.rb | 113 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 style.css create mode 100755 update.rb diff --git a/style.css b/style.css new file mode 100644 index 0000000..6810479 --- /dev/null +++ b/style.css @@ -0,0 +1,17 @@ +.ok { color: green; } +.error { color: red; } +.important { font-weight: bold; } +table { border-collapse:collapse; } +td,th { padding-right: 5px; text-align: left; } +td { min-width: 100px; } +td.git, td.download { min-width: 0; } +tr:nth-child(even) { background-color: #eee; } +tr:hover { background-color: #ddd; } + +body { + font-family: Helvetica, Arial; font-size: 12pt; + background: url(http://grml.org/img/logo.png) no-repeat; + background-position: right top; + padding: 10px; + padding-top: 0px; +} diff --git a/update.rb b/update.rb new file mode 100755 index 0000000..e350638 --- /dev/null +++ b/update.rb @@ -0,0 +1,113 @@ +#!/usr/bin/env ruby +require 'git' +require 'builder' +require 'erb' +require 'yaml' + +def build_used_package_list(source_files) + source_files.map do |source_file| + File.read(source_file).split("\n").reject do |l| + l.strip.start_with?('#') or l.strip == "" + end + end.flatten +end + +used_packages = { + :full => build_used_package_list(['grml-live/etc/grml/fai/config/package_config/GRMLBASE', 'grml-live/etc/grml/fai/config/package_config/GRML_FULL']), +} + +def build_package_list(packages, used) + data = {} + packages.each do |pkg| + next if not File.exists?(File.join(pkg, 'debian')) + begin + g = Git.open(working_dir = pkg) + #g.pull(Git::Repo, Git::Branch) # fetch and a merge + rescue ArgumentError + g = Git.bare(working_dir = pkg) + end + + current_head = g.gcommit('HEAD') + next if not current_head.parent + + p = { + :head_is_tagged => false, + :used => {}, + :name => pkg, + :version => nil, + :has_tags => false, + } + used.each do |dist,l| + p[:used][dist] = l.include?(pkg) + end + + for tag in g.tags.reverse + p[:has_tags] = true + t = g.gcommit(tag.name) + next if not t.parent + #$stderr.puts "#{pkg}: Checking tag #{tag.name}: tag parent: #{t.parent.sha} HEAD: #{current_head.parent.sha}" + if t.parent.sha === current_head.parent.sha + p[:head_is_tagged] = true + p[:version] = tag.name + break + end + end + + data[pkg] = p + end + data.values.sort { |x,y| x[:name] <=> y[:name] } +end + +packages = build_package_list(ARGV, used_packages) + +template = ERB.new <<-EOF + + + + Grml.org Package Index + + + +
+

All Grml packages

+

Last update: <%= Time.now.to_s %>

+
+
+ + + + + <% packages.each do |p| %> + + + + + <% if p[:head_is_tagged] %> + + <% else %> + + <% end %> + + + <% end %> +
PackageGitDownloadFresh?In FULL?
<%= p[:name] %>Git + <% if p[:has_tags] %> + Download + <% end %> + Version <%= p[:version] %>Untagged changes<%= p[:used][:full] ? "Yes" : "No" %>
+
+ + + +EOF +File.open('index.html.new','w') do |f| + f.write template.result(binding) +end +File.open('packages.yaml.new','w') do |f| + f.write packages.to_yaml +end + +FileUtils.mv 'index.html.new', 'index.html' +FileUtils.mv 'packages.yaml.new', 'packages.yaml' + -- 2.1.4