Diff for /loncom/build/CHECKRPMS between versions 1.3 and 1.8

version 1.3, 2006/10/04 19:47:33 version 1.8, 2007/06/28 13:30:06
Line 39  to LON-CAPA systems. distprobe is used t Line 39  to LON-CAPA systems. distprobe is used t
   
 The utility which is used to complete the check depends on the distro:  The utility which is used to complete the check depends on the distro:
   
 fedora - yum  fedora, rhel 5/5+, centos, scientific - yum
 suse 9.X and sles9 - you  suse 9.X and sles9 - you
 suse 10.X and sles10 - rug  suse 10.X and sles10 - rug
 rhel 4 - up2date  rhel 4 - up2date
Line 80  if ($distro =~ /^fedora\d+$/) { Line 80  if ($distro =~ /^fedora\d+$/) {
     $cmd = 'yum update';      $cmd = 'yum update';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
     ($send,$addsubj) = &check_with_yum($tmpfile);      ($send,$addsubj) = &check_with_yum($tmpfile);
 } elsif ($distro =~ /^(suse|sles)9\.\d$/) {  } elsif ($distro =~ /^(suse|sles)9\.?\d?$/) {
     $cmd = 'you';      $cmd = 'you';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
     ($send,$addsubj) = &check_with_you($tmpfile);      ($send,$addsubj) = &check_with_you($tmpfile);
Line 88  if ($distro =~ /^fedora\d+$/) { Line 88  if ($distro =~ /^fedora\d+$/) {
     $cmd = 'rug up';      $cmd = 'rug up';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
     ($send,$addsubj) = &check_with_rug($tmpfile);      ($send,$addsubj) = &check_with_rug($tmpfile);
 } elsif ($distro =~ /^rhes4$/) {  } elsif ($distro =~ /^rhes(\d+)$/) {
     $cmd ='up2date -u --nox';      my $version = $1;
       if ($version == 4) {
           $cmd ='up2date -u --nox';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_up2date($tmpfile);
       } elsif ($version > 4) {
           $cmd = 'yum update';
           &prepare_msg($tmpfile,$cmd);
           ($send,$addsubj) = &check_with_yum($tmpfile);
       }
   } elsif ($distro =~ /^centos\d+$/) {
       $cmd = 'yum update';
       &prepare_msg($tmpfile,$cmd);
       ($send,$addsubj) = &check_with_yum($tmpfile);
   } elsif ($distro =~ /^scientific\d+\.\d$/) {
       $cmd = 'yum update';
     &prepare_msg($tmpfile,$cmd);      &prepare_msg($tmpfile,$cmd);
     ($send,$addsubj) = &check_with_up2date($tmpfile);      ($send,$addsubj) = &check_with_yum($tmpfile);
 } else {  } else {
     $cmd = '/usr/local/bin/check-rpms --update';      $cmd = '/usr/local/bin/check-rpms --update';
     ($send,$addsubj) = &check_with_checkrpms($tmpfile);      ($send,$addsubj) = &check_with_checkrpms($tmpfile);
Line 113  $cmd Line 128  $cmd
   
 to bring it up to date.  to bring it up to date.
   
 This is very important for the security of your server.  The table below lists the packages which need to be updated.  This is very important for the security of your server.  The packages which need to be updated are listed below.
   
 ENDHEADER  ENDHEADER
     close(TMPFILE);      close(TMPFILE);
Line 126  sub check_with_you { Line 141  sub check_with_you {
     my $sendflag = 0;      my $sendflag = 0;
     my $append_to_subj;      my $append_to_subj;
   
     if (open (PIPE, "$you -d -k -l en 2>&1 |")) {      if (open (PIPE, "$you -k -len 2>&1 |")) {
         my $output=<PIPE>;          my $output=<PIPE>;
         close(PIPE);          close(PIPE);
         chomp $output;          chomp $output;
         unless ($output eq 'No updates available.') {          unless ($output eq 'No updates available.') {
             my $command = $you.' -s  -k -l en |grep ^[^I]  >>'.$tmpfile;              if (open (PIPE, "$you -s -d -len |grep ^INSTALL |")) {
             system($command);                  my @updates = <PIPE>;
             $sendflag = 1;                  close(PIPE);
             $append_to_subj = ' RPMS to upgrade';                  my $allpackages;
                   foreach my $line (@updates) {
                       my $package = substr($line,rindex($line,'/')+1);
                       if ($package ne '') {
                           $allpackages .= $package;
                       }
                   }
                   if ($allpackages ne '') {
                       open(TMPFILE,">>$tmpfile");
                       print TMPFILE $allpackages;
                       close(TMPFILE);
                       $sendflag = 1;
                       $append_to_subj = ' RPMS to upgrade';
                   }
               } else {
                   $sendflag = 1;
                   $append_to_subj = ' Error running RPM update script';
               }
         }          }
     } else {      } else {
         $sendflag = 1;          $sendflag = 1;
Line 181  sub check_with_up2date { Line 213  sub check_with_up2date {
     if (open (PIPE, "$up2date -l 2>&1 |")) {      if (open (PIPE, "$up2date -l 2>&1 |")) {
         my @result=<PIPE>;          my @result=<PIPE>;
         close(PIPE);          close(PIPE);
           my $output; 
           foreach my $line (@result) {
               if ($line =~ /^The following Packages were marked to be skipped by your configuration:/) {
                   last;
               } else {
                   $output .= $line;
               }
           } 
         if (@result > 0) {          if (@result > 0) {
             my $output = join('',@result);  
             if ($output =~ /Fetching Obsoletes list/) {              if ($output =~ /Fetching Obsoletes list/) {
                 $up2date_error = 0;                  $up2date_error = 0;
                 if ($output =~ /Name\s+Version\s+Rel\s+[\n\r\f]+\-+[\n\r\f]+(.+)/s) {                  if ($output =~ /Name\s+Version\s+Rel\s+[\n\r\f]+\-+[\n\r\f]+(.+)/s) {
                     my $packagelist = $1;                      my $packagelist = $1;
                     unless (($packagelist =~ /^The following Packages were marked to be skipped by your configuration:/) || ($packagelist eq '')) {                      if ($packagelist ne '' && $packagelist !~ /^[\s\n\r\f]+$/) {
                         open(TMPFILE,">>$tmpfile");                          open(TMPFILE,">>$tmpfile");
                         print TMPFILE $packagelist;                          print TMPFILE $packagelist;
                         close(TMPFILE);                          close(TMPFILE);
Line 232  sub check_with_rug { Line 271  sub check_with_rug {
                 last;                  last;
             } elsif ($line eq 'No updates are available.') {              } elsif ($line eq 'No updates are available.') {
                 last;                  last;
               } elsif ($line eq 'Downloading Packages...') {
                   last;
             } else {              } else {
                 push(@clean_output,$line);                  push(@clean_output,$line);
             }              }

Removed from v.1.3  
changed lines
  Added in v.1.8


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>