#! /usr/bin/perl # # update - Try to update a RPM list. # die "usage: update RPMS_dir rpm_list\n" unless ($#ARGV >= 1); # Validate the args $RPMS_dir = shift; die "bad RPMS_dir specified\n" unless (-d $RPMS_dir); $list = shift; die "bad rpm_list specified\n" unless (-f $list); # Get the newest RPMS open PIPE, "cd $RPMS_dir ; ww 2>/dev/null|"; while () { chomp $_; next unless(m/^NEW /); s/^NEW //; $nm = `rpm -qp --qf '%{NAME}\n' $RPMS_dir/$_`; chomp $nm; $newest{$nm} = $_; } close PIPE; # Process the list open LIST, "<$list"; while ($line = ) { chomp $line; # Output if comment and get another line if ($line =~ m/^\s*#/) { print "$line\n"; next; } # Output if blank line and get another line if ($line eq "") { print "\n"; next; } # Output if name contains "nw" and get another line # this should catch all customized packages # not perfect but useable #if ($line =~ m/nw/) { # print "$line\n"; # next; #} # Split up the line if ($line =~ m#^(.*\.rpm)(.*)#) { $rpm = $1; $options = $2; } else { die "Bad line: $line\n" } # # Look before you leap... # unless (-f "$RPMS_dir/$rpm") { # print "*$line\n"; # next; # } $rpmname = `rpm -qp --qf '%{NAME}\n' $RPMS_dir/$rpm`; chomp $rpmname; $newrpm = "$newest{$rpmname}"; die "missing new: $newrpm\n" unless (-f "$RPMS_dir/$newest{$rpmname}"); print "$newrpm$options\n"; } close LIST;