diff options
-rw-r--r-- | config_default | 1 | ||||
-rw-r--r-- | lib/MGA/Advisories.pm | 30 | ||||
-rwxr-xr-x | mgaadv | 21 |
3 files changed, 52 insertions, 0 deletions
diff --git a/config_default b/config_default index c3fb396..b4cf6bc 100644 --- a/config_default +++ b/config_default @@ -1,6 +1,7 @@ mode: dump send_adv_mail: no send_report_mail: no +move_pkg_cmd: dump_url: http://advisories.mageia.org/advisories.yaml advisories_dir: /var/lib/mga-advisories/advisories status_dir: /var/lib/mga-advisories/status diff --git a/lib/MGA/Advisories.pm b/lib/MGA/Advisories.pm index ac0aa9e..d408dc3 100644 --- a/lib/MGA/Advisories.pm +++ b/lib/MGA/Advisories.pm @@ -143,6 +143,36 @@ sub download_advisories { close $fh; } +sub move_packages { + my ($advdb) = @_; + return unless $config->{mode} eq 'site'; + return unless $config->{move_pkg_cmd}; + my @cmd = ( + $config->{move_pkg_cmd}, + '--sync', + '--no-confirm' + ); + foreach my $adv (keys %{$advdb->{advisories}}) { + next if $advdb->{advisories}{$adv}{status}{moved}; + foreach my $rel (keys %{$advdb->{advisories}{$adv}{src}}) { + foreach my $media (keys %{$advdb->{advisories}{$adv}{src}{$rel}}) { + foreach my $srpm (@{$advdb->{advisories}{$adv}{src}{$rel}{$media}}) { + push(@cmd, "$rel/$media/$srpm.src.rpm"); + } + } + } + } + + return if scalar(@cmd) < 4; + report_exit("Could not move packages") if (0 != system(@cmd)); + + foreach my $adv (keys %{$advdb->{advisories}}) { + next if $advdb->{advisories}{$adv}{status}{moved}; + $advdb->{advisories}{$adv}{status}{moved} = time(); + save_status($advdb, $adv); + } +} + sub publish_advisories { my ($advdb) = @_; foreach my $adv (sort keys %{$advdb->{advisories}}) { @@ -56,6 +56,15 @@ $0 mksite Generates the advisories web site END }, + process => { + run => \&process, + descr => 'Process advisories', + usage => <<END, +$0 process + +Process advisories i.e. move the [S]RPMs, update website, send emails +END + }, new => { run => \&newadv, descr => 'Create a new advisory file', @@ -139,6 +148,18 @@ sub mksite { MGA::Advisories::send_report(\%advdb); } +sub process { + my %advdb; + $advdb{advisories} = MGA::Advisories::get_advisories(); + MGA::Advisories::move_packages(\%advdb); + MGA::Advisories::publish_advisories(\%advdb); + MGA::Advisories::sort_advisories(\%advdb); + MGA::Advisories::output_pages(\%advdb); + MGA::Advisories::dumpdb(\%advdb); + MGA::Advisories::send_adv_mail(\%advdb); + MGA::Advisories::send_report(\%advdb); +} + sub editor { $ENV{EDITOR} || $ENV{VISUAL} || '/usr/bin/editor' } sub newadv { |