summaryrefslogtreecommitdiff
blob: 27064fd467960e86bf6a1695999aa18e0d5e039a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#!/usr/bin/ruby

require "rexml/document"

PORTAGE_DIR="/usr/portage/"
#PORTAGE_DIR="/home/bangert/gentoo/test-portage"

herdxml = REXML::Document.new File.new( "/home/bangert/gentoo/gentoo/xml/htdocs/proj/en/metastructure/herds/herds.xml" )

herds = Hash::new(false)
herdemail = Hash::new(false)

herdxml.elements.each("herds/herd") { |e|
        herds[e.elements["name"].text] = true
	email = e.elements["email"]
	if !email.nil?
        	herdemail[email.text.split("@")[0]] = true
	else
		puts "herd without email: #{e.elements["name"].text}"
	end
}

userxml = REXML::Document.new File.new( "/home/bangert/gentoo/gentoo/xml/htdocs/proj/en/devrel/roll-call/userinfo.xml" )

developers = Hash::new(false)
userxml.elements.each("userlist/user") { |e|  
	if e.elements["status"] && e.elements["status"].text == "retired"
		developers[e.attributes["username"]] = false
	else
		developers[e.attributes["username"]] = true 
	end

}
#developers.each{ |x,y|
#	puts "#{x} #{y}"
#}

#herdxml.each_element_with_text("rox") {|e| p e.text}
categories=`cat #{PORTAGE_DIR}/profiles/categories`.split()

ct_packages = 0
ct_retired_maint = 0
ct_unknown_maint = 0
ct_invalid_proxy_maint = 0
ct_missing_herd = 0
ct_missing_maint = 0
ct_empty_herd = 0
ct_unknown_herd = 0
ct_missing_metadata = 0
ct_unmaintained_package = 0
ct_maint_needed_no_no_herd = 0
ct_maint_herd = 0
ct_no_herd = 0
ct_ldesc_empty = 0
ct_ldesc_lang = 0


categories.map{ |x|
#	puts "Category: #{x}" 
	
	`ls -1 #{PORTAGE_DIR}/#{x}`.split().map{ |package|
		if package != "CVS" && package != "metadata.xml"
			ct_packages += 1
			metadatafile = "#{PORTAGE_DIR}/#{x}/#{package}/metadata.xml"
			if File::file? metadatafile
				metadata = REXML::Document.new File.new( metadatafile )
				proxy_maint = false
				gentoo_maint = false
				herds = Hash::new(false)
				if metadata.elements["pkgmetadata/herd"]
					metadata.elements.each("pkgmetadata/herd") { |herd|
						herd = herd.text
						if herd.nil?
							ct_empty_herd += 1
							puts "#{x}/#{package}".ljust(40) + "<herd> empty"
						else
							herd = herd.strip
							herds[herd] = true
							if herd == "no-herd"
								ct_no_herd += 1
							else
								if herds[herd]
									gentoo_maint = true
								else
									puts "#{x}/#{package}".ljust(40) + "<herd> unknown: <herd>#{herd}</herd>"
									ct_unknown_herd += 1
								end
							end
						end
					}
				elsif
					ct_missing_herd += 1
					puts "#{x}/#{package}".ljust(40) + "<herd> missing"
				end
				if metadata.elements["pkgmetadata/maintainer"]
					metadata.elements.each("pkgmetadata/maintainer/email") { |m| 
						email = m.text.downcase.strip.split("@")
						if email[1] != "gentoo.org"
							proxy_maint = true
							#puts "#{x}/#{package}".ljust(40) + "non-gentoo maintainer: #{m.text}"
						else
							if !developers.has_key?(email[0])
								if email[0] == "maintainer-needed" 
									ct_maint_needed_no_no_herd += 1
								elsif herdemail[email[0]]
									ct_maint_herd += 1
									puts "#{x}/#{package}".ljust(40) + "herd as maintainer: #{m.text}"
								else
									ct_unknown_maint+=1
									puts "#{x}/#{package}".ljust(40) + "unknown maintainer: #{m.text}"
								end
							elsif !developers[email[0]]
								ct_retired_maint+=1
								puts "#{x}/#{package}".ljust(40) + "retired maintainer: #{m.text}"
							else
								gentoo_maint = true
							end
						end
					}
				else
					ct_missing_maint += 1
			#		puts "#{x}/#{package}".ljust(40) + "missing <maintainer>"
				end
#				if metadata.elements["pkgmetadata/longdescription"]
#					metadata.elements.each("pkgmetadata/longdescription") { |d|
#						ldesc = d.text
#						if ldesc.nil?
#							ct_ldesc_empty += 1
#							puts "#{x}/#{package}".ljust(40) + "<longdescription> empty"
#						end
#						if !d.attributes["lang"]
#							ct_ldesc_lang += 1
#							puts "#{x}/#{package}".ljust(40) + "<longdescription> missing lang attribute"
#						end
#					}
#				end
				if !gentoo_maint
					if proxy_maint
						ct_invalid_proxy_maint += 1
						puts "#{x}/#{package}".ljust(40) + "has proxy maintainer but no gentoo association"
					else
						ct_unmaintained_package += 1
						puts "#{x}/#{package}".ljust(40) + "unmaintained"
					end
				end
				
			elsif
				ct_missing_metadata += 1
				puts "#{x}/#{package}".ljust(40) + "metadata.xml missing"
			end
		end
	}

}

puts "\nStatistics"
puts "=================================================================="
puts
puts "Total number of packages:".ljust(40) + "#{ct_packages}".rjust(10)
puts
puts "metadata.xml missing".ljust(40) + "#{ct_missing_metadata}".rjust(10)
puts "<herd> missing".ljust(40) + "#{ct_missing_herd}".rjust(10)
puts "<herd> empty".ljust(40) + "#{ct_empty_herd}".rjust(10)
puts "<herd> unknown".ljust(40) + "#{ct_unknown_herd}".rjust(10)
puts "<herd>=no-herd".ljust(40) + "#{ct_no_herd}".rjust(10)
puts
puts "<maintainer> missing".ljust(40) + "#{ct_missing_maint}".rjust(10)
puts "<maintainer> retired".ljust(40) + "#{ct_retired_maint}".rjust(10)
puts "<maintainer> is a herd".ljust(40) + "#{ct_maint_herd}".rjust(10)
puts "<maintainer> unknown".ljust(40) + "#{ct_unknown_maint}".rjust(10)
puts "<maintainer>=maintainer-needed".ljust(40) + " #{ct_maint_needed_no_no_herd}".rjust(10)
puts
puts "Proxy maintainer without gentoo association".ljust(40) + "#{ct_invalid_proxy_maint}".rjust(10)
puts "Unmaintained packages".ljust(40) +"#{ct_unmaintained_package}".rjust(10)
puts
#puts "<longdescription> empty".ljust(40) + "#{ct_ldesc_empty}".rjust(10)
#puts "<longdescription> missing lang attribute".ljust(40) + "#{ct_ldesc_lang}".rjust(10)