--- loncom/build/CHECKRPMS 2006/10/05 17:44:38 1.4 +++ loncom/build/CHECKRPMS 2007/04/23 20:04:52 1.7 @@ -39,7 +39,7 @@ to LON-CAPA systems. distprobe is used t The utility which is used to complete the check depends on the distro: -fedora - yum +fedora, rhel 5/5+ - yum suse 9.X and sles9 - you suse 10.X and sles10 - rug rhel 4 - up2date @@ -80,7 +80,7 @@ if ($distro =~ /^fedora\d+$/) { $cmd = 'yum update'; &prepare_msg($tmpfile,$cmd); ($send,$addsubj) = &check_with_yum($tmpfile); -} elsif ($distro =~ /^(suse|sles)9\.\d$/) { +} elsif ($distro =~ /^(suse|sles)9\.?\d?$/) { $cmd = 'you'; &prepare_msg($tmpfile,$cmd); ($send,$addsubj) = &check_with_you($tmpfile); @@ -88,10 +88,17 @@ if ($distro =~ /^fedora\d+$/) { $cmd = 'rug up'; &prepare_msg($tmpfile,$cmd); ($send,$addsubj) = &check_with_rug($tmpfile); -} elsif ($distro =~ /^rhes4$/) { - $cmd ='up2date -u --nox'; - &prepare_msg($tmpfile,$cmd); - ($send,$addsubj) = &check_with_up2date($tmpfile); +} elsif ($distro =~ /^rhes(\d+)$/) { + 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); + } } else { $cmd = '/usr/local/bin/check-rpms --update'; ($send,$addsubj) = &check_with_checkrpms($tmpfile); @@ -113,7 +120,7 @@ $cmd 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 close(TMPFILE); @@ -126,15 +133,32 @@ sub check_with_you { my $sendflag = 0; my $append_to_subj; - if (open (PIPE, "$you -d -k -l en 2>&1 |")) { + if (open (PIPE, "$you -k -len 2>&1 |")) { my $output=; close(PIPE); chomp $output; unless ($output eq 'No updates available.') { - my $command = $you.' -s -k -l en |grep ^[^I] >>'.$tmpfile; - system($command); - $sendflag = 1; - $append_to_subj = ' RPMS to upgrade'; + if (open (PIPE, "$you -s -d -len |grep ^INSTALL |")) { + my @updates = ; + close(PIPE); + 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 { $sendflag = 1; @@ -239,6 +263,8 @@ sub check_with_rug { last; } elsif ($line eq 'No updates are available.') { last; + } elsif ($line eq 'Downloading Packages...') { + last; } else { push(@clean_output,$line); }