Skip to content

RPM `primary.xml` updater

bohdan-barylo requested to merge 372733-update-primary-xml-service into master

What does this MR do and why?

Extends RepositoryMetadata builder services with update_xml_document function to update existed xml files with metadata from new packages and update_package_count function to update packages attribute in root tag.

Screenshots or screen recordings

Screenshot_2022-09-18_at_13.59.50 Screenshot_2022-09-18_at_14.00.52

How to set up and validate locally

  1. Generate empty xml
empty = Packages::Rpm::RepositoryMetadata::BuildPrimaryXml.new.execute
  1. Set variable with parsed RPM package metadata
data = {:files=>["/usr/bin/hello.sh"],
 :changelogs=>[{:changelogtext=>"- First build", :changelogtime=>1662552000}],
 :requirements=>
  [{:requirename=>"bash", :requireversion=>"", :requireflags=>0},
   {:requirename=>"rpmlib(CompressedFileNames)", :requireversion=>"3.0.4-1", :requireflags=>16777226},
   {:requirename=>"rpmlib(FileDigests)", :requireversion=>"4.6.0-1", :requireflags=>16777226},
   {:requirename=>"rpmlib(PayloadFilesHavePrefix)", :requireversion=>"4.0-1", :requireflags=>16777226},
   {:requirename=>"rpmlib(PayloadIsXz)", :requireversion=>"5.2-1", :requireflags=>16777226}],
 :provides=>
  [{:providename=>"hello", :provideflags=>8, :provideversion=>"0.0.1-1.fc29"},
   {:providename=>"hello(x86-64)", :provideflags=>8, :provideversion=>"0.0.1-1.fc29"}],
 :name=>"hello",
 :version=>"0.0.1",
 :release=>"1.fc29",
 :summary=>"Simple RPM package",
 :description=>"Fake rpm package",
 :arch=>"x86_64",
 :license=>"MIT",
 :sourcerpm=>"hello-0.0.1-1.fc29.src.rpm",
 :group=>"Unspecified",
 :buildhost=>"localhost",
 :packager=>nil,
 :vendor=>nil}
  1. Call service again passing empty xml and data
new_xml = Packages::Rpm::RepositoryMetadata::BuildPrimaryXml.new(xml: empty, data: data).execute

Empty xml gets new child and packages attribute incremented by 1
4) You can call it again with new_xml and same data and it will append new child

Packages::Rpm::RepositoryMetadata::BuildPrimaryXml.new(xml: new_xml, data: data).execute

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #372733 (closed)

Edited by bohdan-barylo

Merge request reports