-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrss-changelog
executable file
·178 lines (144 loc) · 4.94 KB
/
rss-changelog
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
178
#!/usr/bin/ruby
## Setup paludis
file = ARGV[0]
unless file
$stderr.puts 'Target file needed'
exit 1
end
require 'Paludis'
Paludis::Log.instance.log_level = Paludis::LogLevel::Warning
PALUDIS_ENV = Paludis::NoConfigEnvironment.new('/usr/portage', '/var/cache/paludis/metadata/')
REPO_NAME = 'gentoo'
REPOSITORY = PALUDIS_ENV.package_database.fetch_repository(REPO_NAME)
REPO_LOCATION = REPOSITORY['location'].value
IN_REPOSITORY_GENTOO = Paludis::Generator::InRepository.new(REPO_NAME)
## Setup URI handling
# IMHO ruby standard library should provide this
require 'uri/https'
def build_uri(args)
params = []
h = args[:query]
h.each_pair { |k,v| params << "#{k}=#{URI.escape(v)}" }
args[:query] = params.join('&')
URI::HTTPS.build2(args)
end
## Setup bug amount parser
require 'rubygems'
require 'hpricot'
require 'open-uri'
require 'cgi'
$bug_titles = []
['UNCONFIRMED','CONFIRMED','IN_PROGRESS'].each { |status|
doc = open("http://bugs.gentoo.org/data/cached/buglist-#{status}.html") { |f| Hpricot(f) }
doc.search('//li/a/em').each { |b|
$bug_titles << CGI.unescapeHTML(b.inner_html)
}
}
def bug_count(atom)
$bug_titles.select { |b| b.include?(atom) }.length
end
## Setup rss maker
require 'rss/maker'
def populate_item(i, pid,d)
pn = pid.name.package
cat_pn = pid.name.category + '/' + pn
i.title = "#{cat_pn}-#{pid.version.to_s}"
# add month for the date
# To avoid loading activesupport having these manually here
#i.date = (d >> 1).to_datetime.to_formatted_s(:rfc822)
#i.guid.content = "#{pid}/#{d.to_formatted_s(:number)}"
#i.date = (d >> 1).strftime('%a, %d %b %Y %H:%M:%S %z')
i.date = Time.parse((d >> 1).to_s)
i.guid.content = "#{pid}/#{d.strftime('%Y%m%d')}"
i.guid.isPermaLink = "false"
cat_bugs = bug_count(cat_pn)
pn_bugs = bug_count(pn)
herds = pid['herds']
herds = "Herds: #{herds.value.join(', ') if herds}"
maintainers = pid['maintainers']
maintainers = "Maintainers: #{maintainers.value.join(', ') if maintainers}"
comment = <<EOF
This bug was filed via: http://gentoo.petteriraty.eu/stable.rss
How much have you used the package in question?
Have you had any problems with the package?
emerge --info:
Info for bug wranglers:
#{herds}
#{maintainers}
Open bugs for #{cat_pn}: #{cat_bugs}
Open bugs for #{pn}: #{pn_bugs}
Keywords: #{pid.keywords_key.value.join(' ')}
EOF
i.description = <<-EOF
Added to tree: #{d}<br/>
#{herds} <br />
#{maintainers}<br />
Open bugs for #{cat_pn}: #{cat_bugs} #{"<a href=\"https://bugs.gentoo.org/buglist.cgi?quicksearch=#{cat_pn}\">Show</a>" if cat_bugs > 0}<br />
Open bugs for #{pn}: #{pn_bugs} #{"<a href=\"https://bugs.gentoo.org/buglist.cgi?quicksearch=#{pn}\">Show</a>" if pn_bugs > 0}<br />
<a href="#{build_uri(
:host => 'bugs.gentoo.org',
:path => '/enter_bug.cgi',
:query => {
:product => 'Gentoo Linux',
:short_desc => "Stable request for #{i.title}",
:comment => comment,
:keywords => 'STABLEREQ'
})}">File bug </a>
EOF
end
# for example *ant-core-1.7.1-r1 (16 Jul 2008)
NEW_RE = /^\*([^\(]+) \((\d\d \w\w\w \d\d\d\d)\)\s*$/
## Setup dates
require 'date'
# Keep old entries around for a week
MONTH_AGO = Date.today << 1
LAST_DATE = MONTH_AGO - 7
def read_changelog(changelog, m, qpn)
for line in changelog do
if line =~ NEW_RE
d = Date.parse($~[2])
# presume chronological order
return if d < LAST_DATE
if d <= MONTH_AGO
ebuild_file = File.join(REPO_LOCATION, qpn, $~[1] + '.ebuild')
if FileTest.exists?(ebuild_file)
atom = "=#{qpn.category}/#{$~[1]}"
dep_spec = Paludis::parse_user_package_dep_spec(atom, PALUDIS_ENV,[])
to_match = IN_REPOSITORY_GENTOO & Paludis::Generator::Matches.new(dep_spec, [])
pkg_id = PALUDIS_ENV[Paludis::Selection::RequireExactlyOne.new(to_match)][0]
kws = pkg_id.keywords_key
# Unknown EAPI if null
if kws
stable = kws.value.delete_if { |kw| kw[0] == ?~ or kw[0] == ?- }
if stable.length == 0
populate_item(m.items.new_item,pkg_id,d)
puts "#{atom} #{d} #{pkg_id}"
end
end
end
end
end
end
end
content = RSS::Maker.make('2.0') { |m|
m.channel.title = "Unstable Ebuilds in Tree for a Month"
m.channel.link = "http://gentoo.petteriraty.eu"
m.channel.description = "Shows ebuilds that have been in the tree for a month and have no stable keywords yet."
#The writer should be fixed to not put this last in the page
#m.channel.ttl = 60*24
mail = '[email protected] (Petteri Räty)'
m.channel.webMaster = mail
m.channel.managingEditor = mail
m.channel.pubDate = Time.now
REPOSITORY.category_names { |category|
REPOSITORY.package_names(category) { |qpn|
File.open(File.join(REPO_LOCATION, qpn, 'ChangeLog')) { |c|
read_changelog(c, m, qpn)
}
}
}
}
File.open(file, 'w') { |f|
f.write(content)
}
# vim: et sw=2 ts=2: