Class: YumRepo::Repomd
- Inherits:
-
Object
- Object
- YumRepo::Repomd
- Defined in:
- lib/yumrepo.rb
Instance Method Summary collapse
- #filelists ⇒ Object
-
#initialize(url) ⇒ Repomd
constructor
Rasises exception if can’t retrieve repomd.xml.
- #other ⇒ Object
- #primary ⇒ Object
Constructor Details
#initialize(url) ⇒ Repomd
Rasises exception if can’t retrieve repomd.xml
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 |
# File 'lib/yumrepo.rb', line 78 def initialize(url) @settings = Settings.instance @settings.init @url = url if @url =~ /\/repodata\/?/ @url.gsub! '/repodata', '' end @url_digest = Digest::MD5.hexdigest(@url) @repomd_file = File.join(@settings.cache_path, @url_digest, 'repomd.xml') if @settings.cache_enabled and File.exist?(@repomd_file) @settings.log.debug "Using catched repomd.xml at #{@repomd_file}" f = open @repomd_file else @settings.log.debug "Fetching repomd.xml from #{@url}" f = open "#{@url}/repodata/repomd.xml" if @settings.cache_enabled FileUtils.mkdir_p File.join(@settings.cache_path, @url_digest) @settings.log.debug "Caching repomd.xml for #{@url} at #{@repomd_file}" File.open(File.join(@settings.cache_path, @url_digest, 'repomd.xml'), 'w') do |xml| xml.puts f.read end f = open(@repomd_file) end end @repomd = Nokogiri::XML(f) end |
Instance Method Details
#filelists ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/yumrepo.rb', line 106 def filelists fl = [] @repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"filelists\"]/xmlns:location").each do |f| fl << File.join(@url, f['href']) end fl end |
#other ⇒ Object
124 125 126 127 128 129 130 131 132 |
# File 'lib/yumrepo.rb', line 124 def other pl = [] @repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"other\"]/xmlns:location").each do |p| pl << File.join(@url, p['href']) end @other_xml ||= _open_file("other.xml.gz", @url_digest, pl.first) @other_xml end |
#primary ⇒ Object
114 115 116 117 118 119 120 121 122 |
# File 'lib/yumrepo.rb', line 114 def primary pl = [] @repomd.xpath("/xmlns:repomd/xmlns:data[@type=\"primary\"]/xmlns:location").each do |p| pl << File.join(@url, p['href']) end @primary_xml ||= _open_file("primary.xml.gz", @url_digest, pl.first) @primary_xml end |