RepomdParser
RPM repository metadata parser.
For tools that use RepomdParser
, see repo-tools repository.
This gem can parse repomd.xml
, primary.xml
and deltainfo.xml
metadata files of the RPM repository,
providing a way to get access to the list of packages in the repo and the details of each individual package (name, size, checksum, etc.)
Installation
- Add
gem 'repomd_parser'
line to your application's Gemfile; - Execute
bundle
.
Alternatively, install as gem install repomd_parser
.
Usage
RepomdParser::RepomdXmlParser
Parses repomd.xml
-- the main repository metadata file, which references other metadata files.
parse
method returns an array of RepomdParser::Reference
.
= RepomdParser::RepomdXmlParser.new('repomd.xml').parse
.each do ||
printf "type: %10s, location: %s\n", .type, .location
end
RepomdParser::PrimaryXmlParser
Parses primary.xml
, which contains information about RPM packages in the repository.
parse
method returns an array of RepomdParser::Reference
.
rpm_packages = RepomdParser::PrimaryXmlParser.new('primary.xml').parse
rpm_packages.each do |rpm|
printf "arch: %8s, location: %s\n", rpm.arch, rpm.location
end
RepomdParser::DeltainfoXmlParser
Parses deltainfo.xml
, which contains information about delta-RPM packages in the repository.
parse
method returns an array of RepomdParser::Reference
.
rpm_packages = RepomdParser::DeltainfoXmlParser.new('deltainfo.xml').parse
rpm_packages.each do |rpm|
printf "arch: %8s, location: %s\n", rpm.arch, rpm.location
end
RepomdParser::Reference
Represents a file referenced in the metadata file. Has the following accessors:
location
, relative to the root of the repository.checksum_type
, e.g. SHA1, SHA256, MD5.checksum
.type
, type of the file, e.g.:primary
,:deltainfo
,:rpm
,:drpm
.size
in bytes.arch
.
RPM and DRPM files additionally have the following attributes:
name
.version
.release
.build_time
.
Caveats
- Relies on the file extension to determine if the file is compressed (automatically decompresses
.gz
and.zst
files)
Development
After checking out the repo, run bundle install
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/ikapelyukhin/repomd-parser.