From 78920e937bd7a7a73551d924bcaaed09e7923b76 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Sun, 15 Mar 2015 18:13:05 +0000 Subject: Add functions useful to generate update descriptions --- lib/MGA/Advisories.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index d03a632..3a446e5 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -516,6 +516,33 @@ sub move_packages { } } +sub generate_description { + my ($adv, $rpm) = @_; + my $desc = "%package $rpm\n"; + $desc .= "Importance: " . %$adv{type} ."\n"; + $desc .= "ID: " . %$adv{ID} . "\n"; + $desc .= "%pre\n"; + $desc .= %$adv{description} . "\n"; + $desc .= "References:\n"; + for my $ref (@{%$adv{references}}) { + $desc .= "- $ref\n"; + } + $desc; +} + +sub get_srpm_to_advisory_map { + my ($advdb, $rel, $media) = @_; + my %srpm2advisory; + foreach my $adv (keys %{$advdb->{advisories}}) { + next unless exists $advdb->{advisories}{$adv}{src}{$rel}; + next unless exists $advdb->{advisories}{$adv}{src}{$rel}{$media}; + foreach my $src (@{$advdb->{advisories}{$adv}{src}{$rel}{$media}}) { + $srpm2advisory{$src} = $adv; + } + } + return \%srpm2advisory; +} + sub publish_advisories { my ($advdb) = @_; foreach my $adv (sort keys %{$advdb->{advisories}}) { -- cgit v1.2.1