From acf1bc223f63c0d6c33acd1ddc73025ff6dc1081 Mon Sep 17 00:00:00 2001 From: kenna-bmcdevitt Date: Fri, 9 Oct 2020 14:44:03 -0500 Subject: [PATCH] added rpm changelog puller --- command_line/rpm_package_changelog_pull.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 command_line/rpm_package_changelog_pull.rb diff --git a/command_line/rpm_package_changelog_pull.rb b/command_line/rpm_package_changelog_pull.rb new file mode 100755 index 0000000..feb5db6 --- /dev/null +++ b/command_line/rpm_package_changelog_pull.rb @@ -0,0 +1,22 @@ +#!/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