| 1 |
#!/usr/bin/ruby -w
|
| 2 |
|
| 3 |
# hash for bin->src resolution
|
| 4 |
$srcpkg = {}
|
| 5 |
|
| 6 |
# hash for src->bins resolution
|
| 7 |
$pkgs = {}
|
| 8 |
|
| 9 |
# read *-Sources and feed $srcpkg and $pkgs
|
| 10 |
def read_sources
|
| 11 |
Dir::glob('{testing,unstable}-*-Sources') do |s|
|
| 12 |
src = nil
|
| 13 |
IO::read(s).each_line do |l|
|
| 14 |
if l =~ /^Package:/
|
| 15 |
src = l.split(' ')[1].chomp
|
| 16 |
$pkgs[src] = [] if $pkgs[src].nil?
|
| 17 |
elsif l =~ /^Binary:/
|
| 18 |
l.split(' ',2)[1].split(', ').each do |b|
|
| 19 |
b.chomp!
|
| 20 |
if $srcpkg[b].nil? # else, we already know that binary pkg
|
| 21 |
$srcpkg[b] = src
|
| 22 |
$pkgs[src] << b
|
| 23 |
end
|
| 24 |
end
|
| 25 |
end
|
| 26 |
end
|
| 27 |
end
|
| 28 |
end
|
| 29 |
|
| 30 |
read_sources
|
| 31 |
|
| 32 |
popcon = {}
|
| 33 |
`wget -q -O /dev/stdout http://popcon.debian.org/by_inst`.each_line do |l|
|
| 34 |
l.chomp!
|
| 35 |
next if l =~ /^#/
|
| 36 |
next if l =~ /^-----/
|
| 37 |
t = l.split
|
| 38 |
next if t[1] == "Total"
|
| 39 |
src = $srcpkg[t[1]]
|
| 40 |
next if src.nil?
|
| 41 |
puts "# #{src} #{t[2..-1].join(' ')}"
|
| 42 |
insts = t[2].to_i
|
| 43 |
if popcon[src]
|
| 44 |
if popcon[src] < insts
|
| 45 |
popcon[src] = insts
|
| 46 |
end
|
| 47 |
else
|
| 48 |
popcon[src] = insts
|
| 49 |
end
|
| 50 |
end
|
| 51 |
|
| 52 |
popcon.to_a.sort { |a,b| a[1] <=> b[1] }.reverse.each do |e|
|
| 53 |
puts e.join(' ')
|
| 54 |
end
|