[LON-CAPA-cvs] cvs: loncom /build check-rpms
harris41
lon-capa-cvs@mail.lon-capa.org
Sat, 13 Apr 2002 19:13:06 -0000
harris41 Sat Apr 13 15:13:06 2002 EDT
Modified files:
/loncom/build check-rpms
Log:
submitting new version with Martin's approval;
handles scenario when rpms with same name
but different version are in the same directory
on an RPM server
Index: loncom/build/check-rpms
diff -u loncom/build/check-rpms:1.2 loncom/build/check-rpms:1.3
--- loncom/build/check-rpms:1.2 Tue Feb 26 20:47:31 2002
+++ loncom/build/check-rpms Sat Apr 13 15:13:06 2002
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
-# check-rpms, version 2.1.0
+# check-rpms, version 2.1.1
# Martin Siegert, SFU, siegert@sfu.ca, Feb 02
#
=pod
@@ -371,7 +371,12 @@
if ($download || $recheck) {
if ( ! -d $RPMDIR) {
- $retval = system("mkdir -p $RPMDIR; chmod 700 $RPMDIR");
+ if ($verbose) { print "Creating $RPMDIR ...\n"; }
+ if ($< == 0) {
+ $retval = system("su $RPMUSER -c \'mkdir -p $RPMDIR\'; chmod 700 $RPMDIR");
+ } else {
+ $retval = system("mkdir -p $RPMDIR; chmod 700 $RPMDIR");
+ }
if ($retval) { die "error: could not create $RPMDIR\n"; }
}
}
@@ -458,6 +463,7 @@
$giveup = 0;
for (@templist) {
($rpm, $pkg, $pver, $arch) = m/(([^ ]*)-([^- ]+-[^-]+\.(\w+)\.rpm))/;
+ if (! defined $local_rpm{$pkg}) { next; }
if ($remote_rpm{$pkg}) {
# problem: there are several versions of the same package.
# this means that the package exists for different architectures
@@ -540,11 +546,7 @@
push(@q_updates, $rpm);
} elsif ( $vcmp < 0 ) {
# local version is lower
- if ( $qflag ) {
- push(@q_updates, $rpm);
- } else {
- push(@updates, $rpm);
- }
+ push(@updates, $rpm);
}
} elsif ($list_missing) {
print "Package '$pkg' missing from remote repository\n";
@@ -698,7 +700,25 @@
}
my $serial1 = `rpm -qp --queryformat '%{SERIAL}' $RPMDIR/$pkg1`;
my $serial2 = `rpm -qp --queryformat '%{SERIAL}' $RPMDIR/$pkg2`;
- ($serial2 > $serial1) ? return 1 : return 0;
+ if ($serial2 > $serial1) {
+ remove_pkg("$RPMDIR/$pkg1");
+ return 1;
+ } else {
+ remove_pkg("$RPMDIR/$pkg2");
+ return 0;
+ }
+}
+
+sub remove_pkg($) {
+ my ($pkg) = @_;
+ if ($verbose) {
+ print "Removing $pkg ...\n";
+ }
+ my $status = system("rm -f $pkg");
+ if ($status) {
+ printf STDERR "error: could not remove $pkg. You must remove this file before updating.\n";
+ if ($update) { $giveup = 1; }
+ }
}
sub mulpkg_msg($$$) {