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

  Server: cvs.openpkg.org                  Name:   Thomas Lotterer
  Root:   /e/openpkg/cvs                   Email:  [EMAIL PROTECTED]
  Module: openpkg-re                       Date:   09-Jul-2003 16:06:01
  Branch: HEAD                             Handle: 2003070915060000

  Modified files:
    openpkg-re              rclint.pl

  Log:
    rclint new checks: badly prefixed variable, opServiceEnabled, exit not
    allowed here

  Summary:
    Revision    Changes     Path
    1.4         +82 -3      openpkg-re/rclint.pl
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: openpkg-re/rclint.pl
  ============================================================================
  $ cvs diff -u -r1.3 -r1.4 rclint.pl
  --- openpkg-re/rclint.pl      8 Jul 2003 20:06:12 -0000       1.3
  +++ openpkg-re/rclint.pl      9 Jul 2003 14:06:00 -0000       1.4
  @@ -352,15 +352,94 @@
   
   sub check_script_section {
       my ($file, $outer_done, $outer_this, $section, $args, $script) = @_;
  +    my ($done, $this, $todo);
  +    my ($pkg, $pkgu);
   
  -    #   skip
  -    return if ($section =~ m/^%(config|info|common|env)$/);
  +    #   determine package name
  +    $pkg = $file;
  +    $pkg =~ s|^.+/||;
  +    $pkg =~ s|^rc\.||;
  +
  +    #   determine package name, dash becomes underscore
  +    $pkgu = $pkg;
  +    $pkgu =~ s|-|_|;
   
       #   remove comment contents
       $outer_this =~ s|^[ \t]*#[^\n]*||mg;
   
  +    #   check config
  +    if ($section =~ m/^%(config)$/) {
  +
  +        #   check for badly prefixed variables
  +        $done = $outer_done; $this = ''; $todo = $outer_this;
  +        while ($todo =~ m/    [^=]+=[^\n]+/s) {
  +            $done .= $`; $this = $&; $todo = $';
  +            if ($this !~ m/    ($pkgu|mta|pop|jre|jdk|java)[a-z_]+=/) { #FIXME 
replace mta|pop|j... with upper case in rc/spec !?
  +                &lint_warning($file, $done, $this, "section $section: badly 
prefixed variable");
  +            }
  +            $done .= $this;
  +        }
  +
  +        return;
  +    }
  +
  +    #   check env
  +    if ($section =~ m/^%(env)$/) {
  +
  +        if ($pkg !~ m/^openpkg$/) { #FIXME really special !?
  +
  +            #   check opServiceEnabled short circuit
  +            $done = $outer_done; $this = ''; $todo = $outer_this;
  +            if ( $todo =~ m/^[^\n]+\n    opServiceEnabled \w+ \|\| exit 0\n/s ) {
  +                &lint_warning($file, $done, $this, "section $section: 
opServiceEnabled short circuit not allowed here");
  +            }
  +
  +            #   check required if ... opServiceEnabled construct
  +            $done = $outer_done; $this = ''; $todo = $outer_this;
  +            if ( $todo !~ m/^[^\n]+\n    if opServiceEnabled \w+; then\n/s ) {
  +                &lint_warning($file, $done, $this, "section $section: required if 
... opServiceEnabled construct missing");
  +            }
  +            else {
  +                #   check required if ... opServiceEnabled package reference
  +                $done = $outer_done; $this = ''; $todo = $outer_this;
  +                if ( $todo !~ m/^[^\n]+\n    if opServiceEnabled $pkgu; then\n/s ) {
  +                    &lint_warning($file, $done, $this, "section $section: if ... 
opServiceEnabled referencing wrong package");
  +                }
  +            }
  +        }
  +
  +        #   exit not allowed here; lousy test ...
  +        $done = $outer_done; $this = ''; $todo = $outer_this;
  +        if ( $todo =~ m/exit/s ) {
  +            &lint_warning($file, $done, $this, "section $section: exit not allowed 
here");
  +        }
  +        return;
  +    }
  +
  +    #   skip
  +    return if ($section =~ m/^%(info|common)$/);
  +
  +    #   check obsolete if ... opServiceEnabled construct
  +    $done = $outer_done; $this = ''; $todo = $outer_this;
  +    if ( $todo =~ m/^[^\n]+\n\s+if\s+opServiceEnabled\s+.+then/s ) {
  +        &lint_warning($file, $done, $this, "section $section: obsolete if ... 
opServiceEnabled construct found");
  +    }
  +
  +    #   check opServiceEnabled short circuit
  +    $done = $outer_done; $this = ''; $todo = $outer_this;
  +    if ( $todo !~ m/^[^\n]+\n    opServiceEnabled \w+ \|\| exit 0\n/s ) {
  +        &lint_warning($file, $done, $this, "section $section: opServiceEnabled 
short circuit missing");
  +    }
  +    else {
  +        #   check opServiceEnabled package reference
  +        $done = $outer_done; $this = ''; $todo = $outer_this;
  +        if ( $todo !~ m/\sopServiceEnabled\s$pkgu\s+/s ) {
  +            &lint_warning($file, $done, $this, "section $section: opServiceEnabled 
referencing wrong package");
  +        }
  +    }
  +
       #   check shell redirections
  -    my $done = $outer_done; my $this = ''; my $todo = $outer_this;
  +    $done = $outer_done; $this = ''; $todo = $outer_this;
       while (   $todo =~ m/[ \t]+(\d+)?[><][ \t]+\S+/s
              or $todo =~ m/[ \t]+[><](\&\d+)?[ \t]+\S+/s) {
           $done .= $`; $this = $&; $todo = $';
  @@ .
______________________________________________________________________
The OpenPKG Project                                    www.openpkg.org
CVS Repository Commit List                     [EMAIL PROTECTED]

Reply via email to