#!/usr/local/bin/perl # version 1.1 # by Shuhei Ohkado # # 説明: # CLUSTER_READMEにあってshowrev -pにないものを出力する。 # つまり、パッチが当られるかもしれないものを出力。 # # TODO: # Requires,Incompatiblesは考慮していない。 # # 使い方: # perl showrev_look.pl -f CLUSTER_README # $CLUSTER_README="./CLUSTER_README"; sub print_usage { print "usage: perl $0 [-f CLUSTER_README] -v -h\n"; exit; } use Getopt::Std; $result = getopts('dhf:'); do print_usage() if (defined $opt_h); $debug=defined $opt_d?1:0; $CLUSTER_README=$opt_f if (defined $opt_f); $CLUSTER_README=shift if (@ARGV); die "Can't open $CLUSTER_README\n" unless (-f $CLUSTER_README); open(SRP, "showrev -p |"); while () { ($pat, $ver, $obs, $req, $inc, $pac) = /^Patch:\s+(\d\d\d\d\d\d)-(\d\d+)\s+Obsoletes:\s+([---\d\s,]+)?Requires:\s+([---\d\s,]+)?Incompatibles:\s+([---\d\s,]+)?\s+Packages:\s+([\w,\s]+)\n/; $pat_hash{$pat}="$ver" if ($pat_hash{$pat} < $ver); if ($obs) { while ($obs=~s/^(\d\d\d\d\d\d)-(\d\d),?\s+//) { $obs_hash{"$1"}="$2" if ($obs_hash{"$1"} < "$2"); } } } #@pl=sort keys %pat_hash; #@ol=sort keys %obs_hash; open(CLUSTER, "< $CLUSTER_README"); while () { ($pid, $ver) = /^(\d\d\d\d\d\d)-(\d\d)+\s+[^:]+\s/; next unless $pid; if (exists $obs_hash{$pid}) { print "Debug: obs, next\n" if ($debug); next; } unless (exists $pat_hash{$pid}) { push @np, "$pid-$ver"; print "Debug: $pid-$ver not_found\n" if ($debug); } elsif ($pat_hash{$pid} < $ver) { push @np, "$pid-$ver" if ($debug); print "Debug: $pid-$ver found but newer than $pat_hash{$pid}\n" if ($debug) } } $np=join('|',@np); open(O,"/bin/egrep \"$np\" $CLUSTER_README|"); print ;