diff options
author | 2008-07-31 01:08:18 +0000 | |
---|---|---|
committer | 2008-07-31 01:08:18 +0000 | |
commit | 6787c8c63c37355c5b1d8904eb6f5a266b9bddc7 (patch) | |
tree | ca550d80ab36bbbe7cff5e73245f8658632a717a | |
parent | TODO is much shorter. (diff) | |
download | rbot-gentoo-6787c8c63c37355c5b1d8904eb6f5a266b9bddc7.tar.gz rbot-gentoo-6787c8c63c37355c5b1d8904eb6f5a266b9bddc7.tar.bz2 rbot-gentoo-6787c8c63c37355c5b1d8904eb6f5a266b9bddc7.zip |
Allow local lookups for GLSA.
-rw-r--r-- | gentoo-data.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gentoo-data.rb b/gentoo-data.rb index d929236..12bf6ea 100644 --- a/gentoo-data.rb +++ b/gentoo-data.rb @@ -28,7 +28,9 @@ #end #VALID_PACKAGE_SRC = "http://tinderbox.dev.gentoo.org/misc/qsearch.txt" +#GLSA_SRC = "http://www.gentoo.org/security/en/glsa/glsa-@GLSA_ID@.xml?passthru=1" VALID_PACKAGE_SRC = "/dev/shm/qsearch.txt" +GLSA_SRC = "#{ENV['PORTDIR']}/metadata/glsa/glsa-@GLSA_ID@.xml" class GentooPlugin < Plugin Config.register Config::StringValue.new('gentoo.scriptdir', @@ -178,7 +180,8 @@ class GentooPlugin < Plugin end def glsa(m, params) - res = @bot.httputil.get("http://www.gentoo.org/security/en/glsa/glsa-#{params[:glsa_id]}.xml?passthru=1") + source = GLSA_SRC.sub('@GLSA_ID@', params[:glsa_id]) + res = fetch_file_or_url(source) if res glsa_body = REXML::Document.new(res) refs = nil @@ -199,6 +202,14 @@ class GentooPlugin < Plugin def glsa_search(m, params) m.reply 'TODO' end + + def fetch_file_or_url(f) + if (f =~ /^http/) == 0 + return @bot.httputil.get(f) + else + return File.read(f) + end + end def get_pkgindex(m) now = Time.now.tv_sec @@ -206,11 +217,7 @@ class GentooPlugin < Plugin @@cached['pkgindex'] = [0, nil] unless unless @@cached.key?('pkgindex') and @@cached['pkgindex'][0] > now-600 #m.reply "Fetch #{@@cached['pkgindex'][0]} > #{now-600}" - if (VALID_PACKAGE_SRC =~ /^http/) == 0 - pkgindex_a = @bot.httputil.get(VALID_PACKAGE_SRC).split("\n") - else - pkgindex_a = File.readlines(VALID_PACKAGE_SRC) - end + pkgindex_a = fetch_file_or_url(VALID_PACKAGE_SRC).split("\n") pkgindex = {} pkgindex_a.each do |pkg| cp, desc = pkg.split(' ', 2) |