#!/usr/bin/ruby # coding: utf-8 # require 'hpricot' # require 'open-uri' # html = Hpricot(open('https://people.debian.org/~anibal/ksp-dc16/names.html')) # keys = html.search('a').map {|a| a.inner_html}.select {|lin| lin=~/^[0-9A-F]{16}$/} # keys.each do |key| # filename = '0x%s' % key # puts 'Getting %s' % key # next if File.exists?(filename) # system('gpg' '--keyserver', 'pgp.gwolf.org', '--recv-keys', key) # system('gpg', '--armor', '--output', filename, '--export', key) # end def unutf(str) str.gsub('\xc3\xa8', 'è').gsub('\xc3\xb6', 'ö').gsub('\xc3\xa1','á'). gsub('\xc3\xb1','ñ').gsub('\xc3\xb3','ó').gsub('\xc3\xab','ë'). gsub('\xc3\xa9','é').gsub('\xc3\xbc','ü') end res = ['digraph G { layout = neato; edge[len=7.0, color=lightgray]; node[color=lightgray, fontcolor=lightgray]; fontsize=96; '] keys = {} sig_to = {} sig_from = {} Dir.glob('0x*').select {|f| f=~/^0x[\dABCDEF]{16}$/}.each do |key| has = [] pkts = `gpg --list-packets #{key}`.split(/\n/) name = pkts.select{|l| l=~/^:user ID/} name = name.first name.gsub!(/Oriole/, 'Didier Raboud') name =~/^:user ID packet: "([^<"(]+)/ && res <<( ' "%s" [label="%s"];' % [key, unutf($1)]) keys[key] = unutf($1) sig_to[key] = [] sig_from[key] = [] sigs = pkts.select{|l| l=~/^:signature/}.map {|l| l.gsub /.*, keyid /, ''}. select{ |sig| File.exists?('0x%s'%sig) }.each do |sig| next if key == sig next if has.include?(sig) sig_to[key] ||= [] sig_to[key] << sig sig_from['0x%s'%sig] ||= [] sig_from['0x%s'%sig] << key has << sig res << ' "%s" -> "0x%s";' % [key, sig] end end html = File.open('index.html', 'w') html.puts '