From 1ecb5c8be9ca35d953cd0ad09a1c2e6bc792a626 Mon Sep 17 00:00:00 2001 From: lace <> Date: Thu, 9 Nov 2006 08:21:38 +0000 Subject: [PATCH] Check all '^Patch\d+' lines and '^%patch' lines are matching. --- bin/checkspecpatch | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 bin/checkspecpatch 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; -- 1.8.3.1