From: lace <> Date: Thu, 9 Nov 2006 08:21:38 +0000 (+0000) Subject: Check all '^Patch\d+' lines and '^%patch' lines are matching. X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=commitdiff_plain;h=1ecb5c8be9ca35d953cd0ad09a1c2e6bc792a626 Check all '^Patch\d+' lines and '^%patch' lines are matching. --- diff --git a/bin/checkspecpatch b/bin/checkspecpatch new file mode 100755 index 0000000..7f89ae9 --- /dev/null +++ b/bin/checkspecpatch @@ -0,0 +1,41 @@ +#! /usr/bin/perl +# $Id$ +# Check all '^Patch\d+' lines and '^%patch' lines are matching. + +use strict; +use warnings; + +@ARGV=<*.spec> if !@ARGV; + +my $rc=0; +for $ARGV (@ARGV) { + local *FILE; + open FILE,$ARGV or die "open $ARGV: $!"; + my $file=do { undef $/; ; } or die "read $ARGV: $!"; + close FILE or die "close $ARGV: $!"; + + my @source =sort { $a<=>$b; } ($file=~/^\s*patch(\d+)\s*:/mig); + my @apply =sort { $a<=>$b; } ($file=~/^\s*%patch(\d+)\b/mig); + my @applyno=sort { $a<=>$b; } ($file=~/^#+\s*%patch(\d+)\b/mig); + my %applyno=map(($_=>1),@applyno); + while (@source || @apply) { + my $source=(shift @source)||""; + my $apply =(shift @apply)||""; + next if $source eq $apply; + if ($source ne "" && $apply < $source) { + unshift @source,$source; + warn "$ARGV: excessive: ".'%'."patch$apply\n"; + $rc=1; + } + if ($apply ne "" && $source < $apply) { + unshift @apply,$apply; + if (!$applyno{$source}) { + warn "$ARGV: excessive: Patch$source\n"; + $rc=1; + } else { + warn "$ARGV: (commented ".'%'."patch$source: Patch$source)\n"; + } + } + } +} +exit $rc;