| 1 |
#!/usr/bin/ruby -w |
#!/usr/bin/ruby -w |
| 2 |
require 'dbi' |
require 'dbi' |
| 3 |
require 'cgi' |
require 'cgi' |
| 4 |
require 'actions' |
|
| 5 |
|
tstart = Time::now |
| 6 |
|
|
| 7 |
|
class Actions |
| 8 |
|
attr_reader :actions, :act_todo, :act_status, :act_comment |
| 9 |
|
def initialize |
| 10 |
|
@actions = [] |
| 11 |
|
@act_status = "" |
| 12 |
|
@act_todo = false |
| 13 |
|
@act_comment = "" |
| 14 |
|
end |
| 15 |
|
|
| 16 |
|
def add(desc) |
| 17 |
|
desc.chomp! |
| 18 |
|
date, who, act, comment = desc.split(' ', 4) |
| 19 |
|
date = Date::parse(date) |
| 20 |
|
if act =~ /^(.+)\((.+)\)$/ |
| 21 |
|
act_name, act_arg = $1, $2 |
| 22 |
|
if [ 'PROP_RM', 'PROP_RM_O', 'PROP_O', 'O', 'REQ_RM', 'RM', 'SEC_RM', 'O_PROP_RM' ].include?(act_name) |
| 23 |
|
# FIXME check bug |
| 24 |
|
elsif act_name == 'WAIT' |
| 25 |
|
act_arg = act_arg.to_i |
| 26 |
|
else |
| 27 |
|
puts "Unknown action: #{act} (#{desc})" |
| 28 |
|
end |
| 29 |
|
@actions << [date, who, [act_name, act_arg], comment] |
| 30 |
|
elsif act == 'OK' |
| 31 |
|
act_name = 'OK' |
| 32 |
|
act_arg = nil |
| 33 |
|
@actions << [date, who, [act_name, act_arg], comment] |
| 34 |
|
else |
| 35 |
|
puts "Unparseable action: #{act} (#{desc})" |
| 36 |
|
exit(1) |
| 37 |
|
end |
| 38 |
|
end |
| 39 |
|
|
| 40 |
|
def analyze_actions |
| 41 |
|
@actions.sort! { |a,b| b[0] <=> a[0] } |
| 42 |
|
idx = 0 |
| 43 |
|
rm_o = false |
| 44 |
|
while idx < @actions.length |
| 45 |
|
if @actions[idx][2][0] == 'OK' |
| 46 |
|
@act_status = "" |
| 47 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 48 |
|
break |
| 49 |
|
elsif @actions[idx][2][0] == 'WAIT' |
| 50 |
|
if @actions[idx][0] + @actions[idx][2][1] <= CURDATE |
| 51 |
|
idx += 1 |
| 52 |
|
next # OK not valid anymore, consider next action |
| 53 |
|
else |
| 54 |
|
# nothing to do except waiting |
| 55 |
|
@act_status = "Waiting until #{@actions[idx][0] + @actions[idx][2][1]}" |
| 56 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 57 |
|
break |
| 58 |
|
end |
| 59 |
|
elsif @actions[idx][2][0] == 'REQ_RM' or @actions[idx][2][0] == 'RM' |
| 60 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal was requested</a>" |
| 61 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 62 |
|
break |
| 63 |
|
elsif @actions[idx][2][0] == 'O' |
| 64 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned</a>" |
| 65 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 66 |
|
break |
| 67 |
|
elsif @actions[idx][2][0] == 'PROP_RM_O' |
| 68 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Was orphaned, will need removal</a>" |
| 69 |
|
rm_o = true |
| 70 |
|
idx += 1 |
| 71 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 72 |
|
next |
| 73 |
|
elsif @actions[idx][2][0] == 'PROP_RM' |
| 74 |
|
ok = false |
| 75 |
|
if @actions[idx][0] + WAIT_RM_O <= CURDATE and !rm_o |
| 76 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned before removal (since #{@actions[idx][0] + 50})</a>" |
| 77 |
|
@act_todo = true |
| 78 |
|
ok = true |
| 79 |
|
end |
| 80 |
|
if @actions[idx][0] + WAIT_RM_RM <= CURDATE |
| 81 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (since #{@actions[idx][0] + 100})</a>" |
| 82 |
|
@act_todo = true |
| 83 |
|
ok = true |
| 84 |
|
end |
| 85 |
|
if !ok |
| 86 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (since #{@actions[idx][0]})</a>" |
| 87 |
|
end |
| 88 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 89 |
|
break |
| 90 |
|
elsif @actions[idx][2][0] == 'PROP_O' |
| 91 |
|
if @actions[idx][0] + WAIT_O_O <= CURDATE |
| 92 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be orphaned (since #{@actions[idx][0] + 50})</a>" |
| 93 |
|
@act_todo = true |
| 94 |
|
else |
| 95 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Orphaning suggested (since #{@actions[idx][0]})</a>" |
| 96 |
|
end |
| 97 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 98 |
|
break |
| 99 |
|
elsif @actions[idx][2][0] == 'O_PROP_RM' |
| 100 |
|
if @actions[idx][0] + WAIT_ORM_RM <= CURDATE |
| 101 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Should be removed (O pkg) (since #{@actions[idx][0] + 50})</a>" |
| 102 |
|
@act_todo = true |
| 103 |
|
else |
| 104 |
|
@act_status = "<a href=\"http://bugs.debian.org/#{@actions[idx][2][1]}\">Removal suggested (O pkg) (since #{@actions[idx][0]})</a>" |
| 105 |
|
end |
| 106 |
|
@act_comment = @actions[idx][3] if not @actions[idx][3].nil? |
| 107 |
|
break |
| 108 |
|
else |
| 109 |
|
puts "Unknown act: #{@actions[idx][2][0]}" |
| 110 |
|
end |
| 111 |
|
end |
| 112 |
|
end |
| 113 |
|
|
| 114 |
|
def Actions::fetch |
| 115 |
|
d = IO::popen("svn cat svn://svn.debian.org/collab-qa/bapase/package-actions.txt") |
| 116 |
|
f = d.read |
| 117 |
|
d.close |
| 118 |
|
return Actions::read(f) |
| 119 |
|
end |
| 120 |
|
|
| 121 |
|
def Actions::read(data) |
| 122 |
|
pkgs = {} |
| 123 |
|
data.each_line do |l| |
| 124 |
|
next if l =~/^\s*#/ or l =~/^\s*$/ |
| 125 |
|
pkg, rest = l.split(' ',2) |
| 126 |
|
if pkgs[pkg].nil? |
| 127 |
|
pkgs[pkg] = Actions::new |
| 128 |
|
end |
| 129 |
|
pkgs[pkg].add(rest) |
| 130 |
|
end |
| 131 |
|
pkgs.each_pair { |k, v| v.analyze_actions } |
| 132 |
|
end |
| 133 |
|
end |
| 134 |
|
|
| 135 |
puts "Content-type: text/html\n\n" |
puts "Content-type: text/html\n\n" |
| 136 |
|
|
| 152 |
|
|
| 153 |
if type == 'o' |
if type == 'o' |
| 154 |
orphaned = true |
orphaned = true |
| 155 |
query = "select * from bapase where type is not null order by orphaned_age desc" |
query = "select * from bapase where type is not null and type in ('O', 'ITA') order by orphaned_age desc" |
| 156 |
|
elsif type == 'rfa' |
| 157 |
|
orphaned = true |
| 158 |
|
query = "select * from bapase where type is not null and type in ('RFA') order by orphaned_age desc" |
| 159 |
elsif type == 'nmu' |
elsif type == 'nmu' |
| 160 |
orphaned = true |
orphaned = true |
| 161 |
query = "select * from bapase where nmu and nmus > 1 order by nmus desc" |
query = "select * from bapase where nmu and nmus > 1 order by nmus desc" |
| 162 |
elsif type == 'testing' |
elsif type == 'testing' |
| 163 |
orphaned = true |
orphaned = true |
| 164 |
query = "select * from bapase where testing_age > 1 order by testing_age desc" |
query = "select * from bapase where source not in (select source from sources where distribution='debian' and release='squeeze') order by testing_age desc, first_seen asc" |
| 165 |
|
elsif type == 'nodd' |
| 166 |
|
orphaned = true |
| 167 |
|
query = <<EOF |
| 168 |
|
WITH active_emails AS (SELECT email FROM carnivore_emails, active_dds WHERE active_dds.id = carnivore_emails.id) |
| 169 |
|
select * from bapase where source in ( |
| 170 |
|
SELECT source |
| 171 |
|
FROM sources |
| 172 |
|
WHERE distribution = 'debian' AND release = 'sid' |
| 173 |
|
AND sources.source NOT IN ( |
| 174 |
|
SELECT sources.source |
| 175 |
|
FROM sources |
| 176 |
|
LEFT OUTER JOIN uploaders ON (sources.source = uploaders.source AND sources.version = uploaders.version AND sources.distribution = uploaders.distribution AND sources.release = uploaders.release AND sources.component = uploaders.component) |
| 177 |
|
WHERE sources.distribution = 'debian' AND sources.release = 'sid' |
| 178 |
|
AND (maintainer_email in (select email from active_emails) |
| 179 |
|
OR email in (SELECT email FROM active_emails) |
| 180 |
|
OR maintainer_email ~ '.*@lists.(alioth.)?debian.org' |
| 181 |
|
OR email ~ '.*@lists.(alioth.)?debian.org')) |
| 182 |
|
) order by upload_age desc |
| 183 |
|
EOF |
| 184 |
|
elsif type == 'maintnmu' |
| 185 |
|
orphaned = true |
| 186 |
|
query = <<EOF |
| 187 |
|
select * from bapase where source in ( |
| 188 |
|
select source from sources where distribution='debian' and release='squeeze' and maintainer_email in ( |
| 189 |
|
select nmus.email from |
| 190 |
|
(select email, count(*) as tot from |
| 191 |
|
(select maintainer_email as email, source from sources_uniq |
| 192 |
|
where release = 'sid' |
| 193 |
|
and distribution = 'debian' |
| 194 |
|
and component = 'main' |
| 195 |
|
union |
| 196 |
|
select email, source from uploaders |
| 197 |
|
where release = 'sid' |
| 198 |
|
and distribution = 'debian' |
| 199 |
|
and component = 'main') as foo |
| 200 |
|
group by email) as tot, |
| 201 |
|
(select email, count(*) as nmus from |
| 202 |
|
(select sources.maintainer_email as email, sources.source from sources_uniq sources, upload_history uh |
| 203 |
|
where release = 'sid' |
| 204 |
|
and distribution = 'debian' |
| 205 |
|
and component = 'main' |
| 206 |
|
and sources.source = uh.source and sources.version = uh.version |
| 207 |
|
and uh.nmu |
| 208 |
|
union |
| 209 |
|
select email, uploaders.source from uploaders, upload_history uh |
| 210 |
|
where release = 'sid' |
| 211 |
|
and distribution = 'debian' |
| 212 |
|
and component = 'main' |
| 213 |
|
and uploaders.source = uh.source and uploaders.version = uh.version |
| 214 |
|
and uh.nmu |
| 215 |
|
) as foo |
| 216 |
|
group by email) as nmus |
| 217 |
|
where nmus * 100 / tot >= 100 |
| 218 |
|
and nmus.email = tot.email) |
| 219 |
|
union (select source from uploaders where distribution='debian' and release='squeeze' and email in ( |
| 220 |
|
select nmus.email from |
| 221 |
|
(select email, count(*) as tot from |
| 222 |
|
(select maintainer_email as email, source from sources_uniq sources |
| 223 |
|
where release = 'sid' |
| 224 |
|
and distribution = 'debian' |
| 225 |
|
and component = 'main' |
| 226 |
|
union |
| 227 |
|
select email, source from uploaders |
| 228 |
|
where release = 'sid' |
| 229 |
|
and distribution = 'debian' |
| 230 |
|
and component = 'main') as foo |
| 231 |
|
group by email) as tot, |
| 232 |
|
(select email, count(*) as nmus from |
| 233 |
|
(select sources.maintainer_email as email, sources.source from sources_uniq sources, upload_history uh |
| 234 |
|
where release = 'sid' |
| 235 |
|
and distribution = 'debian' |
| 236 |
|
and component = 'main' |
| 237 |
|
and sources.source = uh.source and sources.version = uh.version |
| 238 |
|
and uh.nmu |
| 239 |
|
union |
| 240 |
|
select email, uploaders.source from uploaders, upload_history uh |
| 241 |
|
where release = 'sid' |
| 242 |
|
and distribution = 'debian' |
| 243 |
|
and component = 'main' |
| 244 |
|
and uploaders.source = uh.source and uploaders.version = uh.version |
| 245 |
|
and uh.nmu |
| 246 |
|
) as foo |
| 247 |
|
group by email) as nmus |
| 248 |
|
where nmus * 100 / tot >= 100 |
| 249 |
|
and nmus.email = tot.email |
| 250 |
|
))) order by nmus |
| 251 |
|
EOF |
| 252 |
else |
else |
| 253 |
puts <<-EOF |
puts <<-EOF |
| 254 |
<a href="bapase.cgi?t=o">Orphaned packages</a><br/> |
<h1>Bapase</h1> |
| 255 |
<a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a><br/> |
<ul> |
| 256 |
<a href="bapase.cgi?t=testing">Packages not in testing</a><br/> |
<li><a href="bapase.cgi?t=o">Orphaned packages</a></li> |
| 257 |
|
<li><a href="bapase.cgi?t=rfa">RFAed packages</a></li> |
| 258 |
|
<li><a href="bapase.cgi?t=nmu">Packages maintained with NMUs</a></li> |
| 259 |
|
<li><a href="bapase.cgi?t=testing">Packages not in testing</a></li> |
| 260 |
|
<li><a href="bapase.cgi?t=nodd">Packages not maintained by DDs</a></li> |
| 261 |
|
<li><a href="bapase.cgi?t=maintnmu">Packages maintained or co-maintained by people with lots of NMUs</a></li> |
| 262 |
|
</ul> |
| 263 |
</body></html> |
</body></html> |
| 264 |
EOF |
EOF |
| 265 |
exit(0) |
exit(0) |
| 303 |
<th>Comments</th> |
<th>Comments</th> |
| 304 |
</tr> |
</tr> |
| 305 |
EOF |
EOF |
| 306 |
|
tqs = Time::now |
| 307 |
sth = dbh.prepare(query) |
sth = dbh.prepare(query) |
| 308 |
sth.execute |
sth.execute |
| 309 |
|
tqe = Time::now |
| 310 |
res = sth.fetch_all |
res = sth.fetch_all |
| 311 |
n = 0 |
n = 0 |
| 312 |
res.each do |r| |
res.each do |r| |
| 345 |
puts "<td><a href=\"http://bugs.debian.org/src:#{pkg}\">#{r['rc_bugs']} / #{r['all_bugs']}</a></td>" |
puts "<td><a href=\"http://bugs.debian.org/src:#{pkg}\">#{r['rc_bugs']} / #{r['all_bugs']}</a></td>" |
| 346 |
puts "<td>#{r['upload_age']}</td>" |
puts "<td>#{r['upload_age']}</td>" |
| 347 |
puts "<td>#{r['nmus']}</td>" |
puts "<td>#{r['nmus']}</td>" |
|
puts "<td></td>" |
|
| 348 |
if $actions[pkg] |
if $actions[pkg] |
| 349 |
comment = $actions[pkg].act_comment.gsub(/#\d+/) do |bug| |
comment = $actions[pkg].act_comment.gsub(/#\d+/) do |bug| |
| 350 |
bugn = bug.gsub(/^#/, '') |
bugn = bug.gsub(/^#/, '') |
| 358 |
end |
end |
| 359 |
puts "</table>" |
puts "</table>" |
| 360 |
|
|
| 361 |
puts " -- #{res.length} packages listed." |
tstop = Time::now |
| 362 |
|
puts " -- #{res.length} packages listed. Page generated in #{tstop - tstart} seconds. Query took #{tqe - tqs} seconds." |
| 363 |
puts "</body></html>" |
puts "</body></html>" |
| 364 |
|
|
| 365 |
|
|