From cbddae3c1f4ebe856e72c7f317004fae313ea6da Mon Sep 17 00:00:00 2001 From: Natnael Getahun Date: Tue, 11 Nov 2025 12:03:45 +0000 Subject: [PATCH 1/2] Add support for XZ compression in repomd-parser - Updated Gemfile.lock to include ruby-xz dependency. - Modified repomd_parser.rb to handle .xz file decompression. - Added XZ compressed XML test case in primary_xml_parser_spec.rb. - Included a sample XZ file in the fixtures for testing. --- Gemfile.lock | 106 ++++++++++++++++++ lib/repomd_parser.rb | 2 + repomd_parser.gemspec | 1 + ...b5ca3b07c86cb948fc1abfa675e-primary.xml.xz | Bin 0 -> 960 bytes .../repomd_parser/primary_xml_parser_spec.rb | 13 +++ 5 files changed, 122 insertions(+) create mode 100644 Gemfile.lock create mode 100644 spec/fixtures/files/dummy_repo/repodata/abf421e45af5cd686f050bab3d2a98e0a60d1b5ca3b07c86cb948fc1abfa675e-primary.xml.xz diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e5b552c --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,106 @@ +PATH + remote: . + specs: + repomd_parser (1.1.0) + bzip2-ffi (~> 1.1.1) + nokogiri (~> 1.8) + ruby-xz (~> 1.0, >= 1.0.3) + zstd-ruby (~> 1.3, >= 1.3.5.0) + +GEM + remote: https://rubygems.org/ + specs: + ast (2.4.3) + bzip2-ffi (1.1.1) + ffi (~> 1.0) + diff-lcs (1.6.2) + docile (1.4.1) + ffi (1.17.2-aarch64-linux-gnu) + ffi (1.17.2-aarch64-linux-musl) + ffi (1.17.2-arm-linux-gnu) + ffi (1.17.2-arm-linux-musl) + ffi (1.17.2-arm64-darwin) + ffi (1.17.2-x86_64-darwin) + ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.2-x86_64-linux-musl) + json (2.16.0) + nokogiri (1.18.10-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.18.10-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.18.10-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-musl) + racc (~> 1.4) + parallel (1.27.0) + parser (3.3.10.0) + ast (~> 2.4.1) + racc + racc (1.8.1) + rainbow (3.1.1) + rake (13.3.1) + regexp_parser (2.11.3) + rexml (3.4.4) + rspec (3.13.2) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.7) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-support (3.13.6) + rubocop (1.25.0) + parallel (~> 1.10) + parser (>= 3.1.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.15.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.17.0) + parser (>= 3.1.1.0) + ruby-progressbar (1.13.0) + ruby-xz (1.0.3) + simplecov (0.16.1) + docile (~> 1.1) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + unicode-display_width (2.6.0) + zstd-ruby (1.5.7.1) + +PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + bundler (>= 1.16) + rake (~> 13.0) + repomd_parser! + rspec (~> 3.0) + rubocop (<= 1.25) + rubocop-ast (<= 1.17.0) + simplecov (~> 0.16.1) + +BUNDLED WITH + 2.6.2 diff --git a/lib/repomd_parser.rb b/lib/repomd_parser.rb index ef232df..1357cd1 100644 --- a/lib/repomd_parser.rb +++ b/lib/repomd_parser.rb @@ -25,6 +25,7 @@ require 'zlib' require 'bzip2/ffi' +require 'xz' module RepomdParser def self.decompress_io(io_object, filename) @@ -32,6 +33,7 @@ def self.decompress_io(io_object, filename) when '.gz' then Zlib::GzipReader.new(io_object) when '.zst' then RepomdParser::ZstdReader.new(io_object) when '.bz2' then Bzip2::FFI::Reader.open(io_object) + when '.xz' then XZ::StreamReader.open(io_object) else io_object end end diff --git a/repomd_parser.gemspec b/repomd_parser.gemspec index 506a6d2..35c0b11 100644 --- a/repomd_parser.gemspec +++ b/repomd_parser.gemspec @@ -36,4 +36,5 @@ Gem::Specification.new do |spec| spec.add_dependency 'bzip2-ffi', '~> 1.1.1' spec.add_dependency 'nokogiri', '~> 1.8' spec.add_dependency 'zstd-ruby', '~> 1.3', '>= 1.3.5.0' + spec.add_dependency 'ruby-xz', ' ~>1.0', '>= 1.0.3' end diff --git a/spec/fixtures/files/dummy_repo/repodata/abf421e45af5cd686f050bab3d2a98e0a60d1b5ca3b07c86cb948fc1abfa675e-primary.xml.xz b/spec/fixtures/files/dummy_repo/repodata/abf421e45af5cd686f050bab3d2a98e0a60d1b5ca3b07c86cb948fc1abfa675e-primary.xml.xz new file mode 100644 index 0000000000000000000000000000000000000000..808f1dd93a26ceba9671865656b6639696d75cca GIT binary patch literal 960 zcmV;x13&!zH+ooF000E$*0e?h!2JfVA|U}5000000000>CRZEa5iSFDT>u^r%ZCxz z&SsGhgC5HLdo$F3>9^V_F?JZEE)^a5ymM%pF!2BFRpseW9)Q-LPt=oq?6E zi%hf}V|v*8KFEb8V2>;!T2M|wb=CuL_>0yL-;rNFyQi{Q{dAJ?v;?rT3MNGb!XnIJ zUl9lSa}R0mFt8=5<7g{qlQp#GEaD7)OOvBbeI$ll0sVvG0Rd3kZ41(+%VIH<5y!(= zuJJLX(hs0QQ{e%%dM98cMGSW=JALK-#6MlAZw_;m-lUQ&l$+ZN&7kKYk@kv(f;?u# zJovI!r|65*4hW|@8pq`Z=_u)YEfTQaz3#WuKHYBv_&i5*zsNp7D3i)EO8GOrHDbLy zWA^o9*|Rwxg_2!G(6Eryi>`JW2*2DZhIe@k#*p1N$W@SA+>G7S16?(J#qoa|+-fQ~ z?|T$I(=K}t)_Fib@aNj1Bf{?R6uL7TML)o2@xU^ zG(U|BOyWdk2RgsYL^3s|x6i_=J#?i87X2_NASHRx9zY(uE5aR$OH!3UND4CYnTiJZ zIOuH2;nhhmpq(X*IAt4r09^;a%}wX$>%s14e*SewT>0=(CklBS(aohFejE#i0V?a@ zae<0{2{qI2T9|)%^vs);Z9taXqhQT2Z$fL2219H`1Hb$yFri|xALxGy<9hF6yJ`^4<`6x>eJp67m$_E8ahj=ISDqy{ zMLBqp&a$qY5y9@ag03P3Tm_#@E?F$3$QK-4%;#Y{XSo;N;q3$%b#%AFl>8-6ejKwi zvt=r1^fJP{fH3SEs^r;~EKZT%M$VR!36gcOZUDW8IiN9%egfvnYDZTOR!}}gC0Uve zJvmM6q(uXmH3hGgbJ3_zOc{6NPgR@65e}FqL{z{^7D6~;lNc^Lrj#Z?%fU(j0001~ i1S5`mbyULu0htG{A^-rJ)ZJyV#Ao{g000001X)^^H@=nt literal 0 HcmV?d00001 diff --git a/spec/lib/repomd_parser/primary_xml_parser_spec.rb b/spec/lib/repomd_parser/primary_xml_parser_spec.rb index 94daecb..01c0807 100644 --- a/spec/lib/repomd_parser/primary_xml_parser_spec.rb +++ b/spec/lib/repomd_parser/primary_xml_parser_spec.rb @@ -108,6 +108,19 @@ expect(parsed_files).to eq(expected_result) end end + context 'XML compressed with XZ' do + let(:parsed_files) do + described_class.new.parse_file( + file_fixture( + 'dummy_repo/repodata/abf421e45af5cd686f050bab3d2a98e0a60d1b5ca3b07c86cb948fc1abfa675e-primary.xml.xz' + ) + ) + end + + it 'references rpm files' do + expect(parsed_files).to eq(expected_result) + end + end context 'plain XML' do let(:parsed_files) do From dd60ed59b8cef6ad336267b300c28a5775651b21 Mon Sep 17 00:00:00 2001 From: Natnael Getahun Date: Tue, 11 Nov 2025 12:56:07 +0000 Subject: [PATCH 2/2] Bump version to 1.2.0 and update Gemfile.lock --- Gemfile.lock | 2 +- lib/repomd_parser/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e5b552c..a19e9f0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - repomd_parser (1.1.0) + repomd_parser (1.2.0) bzip2-ffi (~> 1.1.1) nokogiri (~> 1.8) ruby-xz (~> 1.0, >= 1.0.3) diff --git a/lib/repomd_parser/version.rb b/lib/repomd_parser/version.rb index e16c59d..9755c08 100644 --- a/lib/repomd_parser/version.rb +++ b/lib/repomd_parser/version.rb @@ -16,5 +16,5 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. module RepomdParser - VERSION = '1.1.0'.freeze + VERSION = '1.2.0'.freeze end