22 lines
852 B
Ruby
Executable file
22 lines
852 B
Ruby
Executable file
#!/usr/bin/env ruby
|
|
# this program will lookup an rpm pkg and create a json of the changes
|
|
|
|
require 'pry'
|
|
require 'json'
|
|
require 'digest'
|
|
|
|
pkgname = ARGV[0]
|
|
|
|
# gives us an array of hashes where each element looks like [{:date => date, :name => name}]
|
|
rpm_name_and_date_query= `rpm -q --qf '[date:%{CHANGELOGTIME:day}\nname:%{CHANGELOGNAME}\n]' #{pkgname}`.split("\n").each_slice(2).map {|s| s.map {|r| r.split(":")}.to_h}
|
|
|
|
# we add in the ascii code for record separator in our query to split this afterwards so we get an array of each changelog item
|
|
split_char = ''
|
|
|
|
rpm_text_query = `rpm -q --qf '[%{CHANGELOGTEXT}#{split_char}]' #{pkgname}`.split(split_char)
|
|
|
|
hashed_changes = rpm_text_query.map {|changetext| hash = Digest::SHA2.hexdigest changetext; {"checksum" => hash} }
|
|
|
|
results = rpm_name_and_date_query.zip(hashed_changes)
|
|
|
|
binding.pry
|