OpenPKG CVS Repository
  http://cvs.openpkg.org/
  ____________________________________________________________________________

  Server: cvs.openpkg.org                  Name:   Ralf S. Engelschall
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   24-Mar-2003 20:32:13
  Branch: HEAD                             Handle: 2003032419321300

  Modified files:
    openpkg-re              speclint.pl

  Log:
    add another check which makes sure that all sections are correctly
    ordered

  Summary:
    Revision    Changes     Path
    1.5         +66 -0      openpkg-re/speclint.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-re/speclint.pl
  ============================================================================
  $ cvs diff -u -r1.4 -r1.5 speclint.pl
  --- openpkg-re/speclint.pl    24 Mar 2003 15:04:01 -0000      1.4
  +++ openpkg-re/speclint.pl    24 Mar 2003 19:32:13 -0000      1.5
  @@ -101,6 +101,7 @@
       comment
       license
       header
  +    section
   ));
   my @checks = ();
   if ($check eq 'all') {
  @@ -350,6 +351,71 @@
                   &lint_warning($file, undef, undef, "mandatory RPM header \"$name\" 
not found");
               }
           }
  +    }
  +
  +}
  +
  +##  _________________________________________________________________
  +##
  +##  CHECK "section": RPM sections
  +##  _________________________________________________________________
  +##
  +
  +sub check_section {
  +    my ($file, $spec) = @_;
  +
  +    my $require = qq{
  +        (%define,)*
  +        Name:,
  +        Summary:,
  +        URL:,
  +        Vendor:,
  +        Packager:,
  +        Distribution:,
  +        Group:,
  +        License:,
  +        Version:,
  +        Release:,
  +        (%option,)*
  +        (%define,|%undefine,)*
  +        (Source\\d+:,)+
  +        (Patch\\d+:,)*
  +        (%NoSource,)*
  +        (%NoPatch,)*
  +        Prefix:,
  +        BuildRoot:,
  +        ((BuildPreReq:,)
  +         |(PreReq:,))*
  +        AutoReq:,
  +        AutoReqProv:,
  +        (Provides:,)*
  +        (Conflicts:,)*
  +        %description,
  +        %prep,
  +        %build,
  +        %install,
  +        %files,
  +        %clean,
  +        (%pre,)?
  +        (%post,)?
  +        (%preun,)?
  +        (%postun,)?
  +    };
  +
  +    #   check for order of headers
  +    my $sections = "";
  +    my $done = ''; my $this = ''; my $todo = $spec;
  +    while ($todo =~ m/^(\S+:|%\S+).*$/m) {
  +        $done .= $`; $this = $&; $todo = $';
  +        my $section = $1;
  +        next if ($section =~ m/^%(if|else|endif)/);
  +        $sections .= "$section,";
  +    }
  +    my $regex = $require;
  +    $regex =~ s|\s+||sg;
  +    if ($sections !~ m/^$regex$/s) {
  +        $regex =~ s|,| |sg;
  +        &lint_error($file, undef, undef, "invalid RPM section order (expected 
\"$regex\")"); 
       }
   }
   
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to