Blame scripts/services/zypp

Packit Bot ea69bd
########################################################
Packit Bot ea69bd
## Copyright (c) 2013-2016 Stefan Jakobs <logwatch@localside.net>
Packit Bot ea69bd
## Covered under the included MIT/X-Consortium License:
Packit Bot ea69bd
##    http://www.opensource.org/licenses/mit-license.php
Packit Bot ea69bd
## All modifications and contributions by other persons to
Packit Bot ea69bd
## this script are assumed to have been donated to the
Packit Bot ea69bd
## Logwatch project and thus assume the above copyright
Packit Bot ea69bd
## and licensing terms.  If you want to make contributions
Packit Bot ea69bd
## under your own copyright or a different license this
Packit Bot ea69bd
## must be explicitly stated in the contribution an the
Packit Bot ea69bd
## Logwatch project reserves the right to not accept such
Packit Bot ea69bd
## contributions.  If you have made significant
Packit Bot ea69bd
## contributions to this script and want to claim
Packit Bot ea69bd
## copyright please contact logwatch-devel@lists.sourceforge.net.
Packit Bot ea69bd
#########################################################
Packit Bot ea69bd
Packit Bot ea69bd
use strict;
Packit Bot ea69bd
Packit Bot ea69bd
my @install;
Packit Bot ea69bd
my @remove;
Packit Bot ea69bd
my @rremove;
Packit Bot ea69bd
my @radd;
Packit Bot ea69bd
my %commands;
Packit Bot ea69bd
Packit Bot ea69bd
my @unknown;
Packit Bot ea69bd
Packit Bot ea69bd
while(my $line=<STDIN>) {
Packit Bot ea69bd
   chomp $line;
Packit Bot ea69bd
   if ( my ( $do, $pkg, $ver, $arch, $user, $repo, $hash) = 
Packit Bot ea69bd
      ( $line =~ /^\S+ \S+\|(?:(install|remove) ?)\|([^\|\s]+)\|([^\|\s]+)\|([^\|\s]+)\|([^\|\s]+)?(?:\|([^\|\s]+)\|([^\|\s]+))?/ )) {
Packit Bot ea69bd
      if ($do eq "remove") {
Packit Bot ea69bd
         push @remove, "$pkg $ver";
Packit Bot ea69bd
      } elsif ($do eq "install") {
Packit Bot ea69bd
         push @install, "$pkg $ver";
Packit Bot ea69bd
      }
Packit Bot ea69bd
   } elsif ( my ( $do, $repo, $url) = ( $line =~ /^\S+ \S+\|(?:(rremove|radd) {0,3})\|([^\|\s]+)(?:\|([^\|]+))?/) ) {
Packit Bot ea69bd
      if ($repo eq "_tmpRPMcache_") {
Packit Bot ea69bd
         # ignore
Packit Bot ea69bd
      } elsif ($do eq "radd") {
Packit Bot ea69bd
         push @radd, "$repo: $url";
Packit Bot ea69bd
      } elsif ($do eq "rremove") {
Packit Bot ea69bd
         push @rremove, "$repo";
Packit Bot ea69bd
      }
Packit Bot ea69bd
   } elsif ( my ( $do, $who, $cmd) = ( $line =~ /^\S+ \S+\|(?:(command)\|([^\|\s]+)\|([^\|]+)\|)/ )) {
Packit Bot ea69bd
      $cmd =~ tr/'//d;
Packit Bot ea69bd
      $commands{$who}{$cmd}++;
Packit Bot ea69bd
   } else {
Packit Bot ea69bd
      push @unknown, $line;
Packit Bot ea69bd
   }
Packit Bot ea69bd
}
Packit Bot ea69bd
Packit Bot ea69bd
if (keys %commands) {
Packit Bot ea69bd
   print "\nCommands:\n";
Packit Bot ea69bd
   foreach my $who (keys %commands) {
Packit Bot ea69bd
      print "   $who:\n";
Packit Bot ea69bd
      foreach my $cmd (keys %{$commands{$who}}) {
Packit Bot ea69bd
         printf "   %3d: %s\n", $commands{$who}{$cmd}, $cmd;
Packit Bot ea69bd
      }
Packit Bot ea69bd
   }
Packit Bot ea69bd
}
Packit Bot ea69bd
Packit Bot ea69bd
my @k = ( "Installed" , \@install,
Packit Bot ea69bd
          "Removed", \@remove,
Packit Bot ea69bd
          "Repository added", \@radd,
Packit Bot ea69bd
          "Repository removed", \@rremove,
Packit Bot ea69bd
          "Unknown lines", \@unknown);
Packit Bot ea69bd
Packit Bot ea69bd
while (@k > 0) {
Packit Bot ea69bd
   my $text = shift @k;
Packit Bot ea69bd
   my $array = shift @k;
Packit Bot ea69bd
   if(@$array) {
Packit Bot ea69bd
      print "\n$text:\n";
Packit Bot ea69bd
      foreach my $line (sort @$array) {
Packit Bot ea69bd
         print "   $line\n";
Packit Bot ea69bd
      }
Packit Bot ea69bd
Packit Bot ea69bd
   }
Packit Bot ea69bd
}
Packit Bot ea69bd
Packit Bot ea69bd
# vi: shiftwidth=3 tabstop=3 syntax=perl et
Packit Bot ea69bd