Class: RightPublish::ZyppRepo::SuseMetadata
- Inherits:
-
Object
- Object
- RightPublish::ZyppRepo::SuseMetadata
- Defined in:
- lib/right_publish/repos/zypp.rb
Overview
Instance Method Summary collapse
- #add ⇒ Object
- #create ⇒ Object
- #href ⇒ Object
-
#initialize ⇒ SuseMetadata
constructor
A new instance of SuseMetadata.
- #suse_data ⇒ Object
- #update_repomd ⇒ Object
Constructor Details
#initialize ⇒ SuseMetadata
Returns a new instance of SuseMetadata.
35 36 37 |
# File 'lib/right_publish/repos/zypp.rb', line 35 def initialize @packages = Dir["*.rpm"].map { |rpmfile| Package.new(rpmfile) } end |
Instance Method Details
#add ⇒ Object
77 78 79 80 |
# File 'lib/right_publish/repos/zypp.rb', line 77 def add create update_repomd end |
#create ⇒ Object
56 57 58 59 60 61 |
# File 'lib/right_publish/repos/zypp.rb', line 56 def create susedata_file = File.join("repodata", "susedata.xml.gz") Zlib::GzipWriter.open(susedata_file) { |file| file.write(suse_data) } @checksum = Digest::SHA256.hexdigest(File.open(susedata_file).read) @open_checksum = Digest::SHA256.hexdigest(suse_data) end |
#href ⇒ Object
39 40 41 |
# File 'lib/right_publish/repos/zypp.rb', line 39 def href "repodata/susedata.xml.gz" end |
#suse_data ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/right_publish/repos/zypp.rb', line 43 def suse_data @suse_data ||= Nokogiri::XML::Builder.new do |xml| xml.susedata("packages" => @packages.length) do |susedata| @packages.each do |package| susedata.package('pkgid' => package.checksum, 'name' => package.name) do |pkg| pkg.version('ver' => package.ver, 'rel' => package.rel, 'arch' => package.arch, 'epoch' => 0) pkg.keyword("support_l3") end end end end.to_xml end |
#update_repomd ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/right_publish/repos/zypp.rb', line 63 def update_repomd repomd = File.join("repodata", "repomd.xml") doc = Nokogiri::XML(File.open(repomd)) Nokogiri::XML::Builder.with(doc.at_css("repomd")) do |xml| xml.data('type' => 'susedata') do |data| data.(File.ctime(href).to_i) data.checksum({ 'type' => 'sha256' }, @checksum) data.location('href' => href) data.send(:"open-checksum", { 'type' => 'sha256' }, @open_checksum) end end File.open(repomd, "w") { |f| doc.write_xml_to f } end |