[LON-CAPA-cvs] cvs: loncom /build CHECKRPMS
harris41
lon-capa-cvs@mail.lon-capa.org
Thu, 05 Sep 2002 17:36:39 -0000
harris41 Thu Sep 5 13:36:39 2002 EDT
Modified files:
/loncom/build CHECKRPMS
Log:
BUG 623, BUG 717 FIXED. CHECKRPMS --download now works; root user
issues are dealt with.
Index: loncom/build/CHECKRPMS
diff -u loncom/build/CHECKRPMS:1.3 loncom/build/CHECKRPMS:1.4
--- loncom/build/CHECKRPMS:1.3 Mon Aug 12 13:22:04 2002
+++ loncom/build/CHECKRPMS Thu Sep 5 13:36:39 2002
@@ -50,6 +50,24 @@
=cut
+# =================================================== READ IN COMMAND ARGUMENTS
+# ---------------------------------------------------- Process download option.
+my $download=shift(@ARGV);
+if ($download eq '--download')
+ {
+ if ($< != 0) # Download mode requires 'root'.
+ {
+ print('**** ERROR **** Download mode needs to be run as root'."\n");
+ exit(1); # Exit with error status.
+ }
+ `rm -Rf /tmp/loncapa_rpm_updates`;
+ $download='-v -dl -d /tmp/loncapa_rpm_updates'; # Part of check-rpms args.
+ }
+else
+ {
+ $download='';
+ }
+
# =================================================== GENERAL INITIAL VARIABLES
# ---------------- The FTP servers (and their directory paths) to check against
my @serverpaths_to_try=(
@@ -60,8 +78,11 @@
'opnsrc.support.compaq.com/linux/redhat/updates.redhat.com/',
);
+# --------------------------------------------------- Determine RedHat version.
my $RHversion = (split /\s/, `cat /etc/redhat-release`)[4]; # - 6.2 or 7.3 or ?
-my $checkcommand='check-rpms -ftp '; # -------- use check-rpms command this way
+
+ # ------------------------------------------- Use check-rpms command this way.
+my $checkcommand='check-rpms '.$download.' --rpmuser www -ftp';
my $FTPSERVER; # ------------------------- the server portion of the serverpath
my $FTPUPDATES; # ----------------------------- the actual update root location
@@ -92,14 +113,25 @@
$serverpath=~/^(.*?)\//;
$FTPSERVER=$1;
print "Trying $FTPSERVER...\n";
- `ping -q -c 1 $FTPSERVER 2>/dev/null`;
+ `ping -c 1 $FTPSERVER 2>/dev/null`;
if ($?==0) {
+ print "$FTPSERVER found...\n";
`ncftpls ftp://$FTPSERVER`;
if ($?==0) {
$FTPUPDATES="$serverpath$RHversion/en/os";
print "$checkcommand $FTPUPDATES\n";
- @rpms=`$checkcommand $FTPUPDATES`;
+ if ($download) {
+ $|=1;
+ print `$checkcommand $FTPUPDATES 2>\&1`;
+ exit(0);
+ }
+ @rpms=`$checkcommand $FTPUPDATES 2>\&1`;
my $rpmtext=join('',@rpms);
+ if ($rpmtext=~/You do not seem to have a/) {
+ print "You do not have a 'www' user on your system.\n".
+ "Please add this user and try this command again.\n";
+ exit(1);
+ }
if ($rpmtext=~/This account is currently not/) { # ---------- uh-oh
print "...strange error, moving on ($FTPSERVER)\n";
}
@@ -129,7 +161,7 @@
else {
my $rpmcount=scalar(@rpms);
print(<<END);
- **** WARNING **** You need to update at least $rpmcount RPMS shown in
+**** WARNING **** You need to update at least $rpmcount RPMS shown in
the list below. THIS IS IMPORTANT FOR SECURITY.
END
@@ -140,5 +172,7 @@
and download the RPMS you need.
For instructions on working with (and upgrading) RPMS, please
visit http://www.rpm.org/max-rpm/.
+To automatically download these RPMs to /tmp/loncapa_rpm_updates/,
+run the CHECKRPMS command as "./CHECKRPMS --download"
END
}