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: 17-Jul-2003 23:38:43 Branch: HEAD Handle: 2003071722384300 Modified files: openpkg-re rclint.pl Log: migrate opServiceEnabled to "opService ... enable yes"; deny use of return/exit in %config, %info, %common and %status Summary: Revision Changes Path 1.13 +34 -49 openpkg-re/rclint.pl ____________________________________________________________________________ patch -p0 <<'@@ .' Index: openpkg-re/rclint.pl ============================================================================ $ cvs diff -u -r1.12 -r1.13 rclint.pl --- openpkg-re/rclint.pl 17 Jul 2003 09:48:42 -0000 1.12 +++ openpkg-re/rclint.pl 17 Jul 2003 21:38:43 -0000 1.13 @@ -102,6 +102,7 @@ comment section script + global )); my @checks = (); if ($check eq 'all') { @@ -130,6 +131,7 @@ my $spec; { local $/ = undef; $spec = <$io>; } $io->close; foreach my $check (@checks) { + &msg_verbose("$check in $filename"); eval "\&check_$check(\$filename, \$spec);"; } } @@ -264,14 +266,15 @@ # check "shebang" header my $re = ""; - $re .= '[EMAIL PROTECTED]@/lib/openpkg/bash @l_prefix@/etc/rc\\n'; - if ($spec !~ m|^$re|os) { + $re .= "[EMAIL PROTECTED]@/lib/openpkg/bash [EMAIL PROTECTED]@/etc/rc\\n"; + if ($spec !~ m|^$re|s) { &lint_warning($file, "", "", "invalid shebang header (expected $re)"); } # check comment header - $re .= "##\\n## rc.$pkg -- Run-Commands\\n##\\n\\n"; - if ($spec !~ m|^$re|os) { + my $re = ""; + $re .= ".*?\\n##\\n## rc.$pkg -- Run-Commands\\n##\\n\\n"; + if ($spec !~ m|^$re|s) { &lint_warning($file, "", "", "invalid comment header (expected $re)"); } @@ -412,64 +415,29 @@ &lint_warning($file, $done, $this, "section $section: ${pkgu}_enable must be the first lowercase variable"); } } - return; } - # check env - if ($section =~ m/^%(env)$/) { - - if (0) { #FIXME temporary disabled while migrating from opServiceEnabled to opService enable - # 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 ... + if ($section =~ m/^%(config|info|common|status)$/) { + # check illegal use of return/exit $done = $outer_done; $this = ''; $todo = $outer_this; - if ( $todo =~ m/exit/s ) { - &lint_warning($file, $done, $this, "section $section: exit not allowed here"); + if ( $todo =~ m/[^a-zA-Z0-9_](return|exit)\s/s ) { + &lint_warning($file, $done, $this, "section $section: return or exit not allowed here"); } return; } - # skip - return if ($section =~ m/^%(info|common)$/); - - if (0) { #FIXME temporary disabled while migrating from opServiceEnabled to opService enable - # check obsolete if ... opServiceEnabled construct + # check opService short circuit $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"); + if ( $todo !~ m/^[^\n]+\n opService \w+ enable yes \|\| exit 0\n/s ) { + &lint_warning($file, $done, $this, "section $section: \"opService ... enable yes\" short circuit missing"); } else { - # check opServiceEnabled package reference + # check opService 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"); + if ( $todo !~ m/\bopService\s+$pkgu\s+/s ) { + &lint_warning($file, $done, $this, "section $section: opService referencing wrong package"); } } - } # check shell redirections $done = $outer_done; $this = ''; $todo = $outer_this; @@ -481,3 +449,20 @@ } } +## _________________________________________________________________ +## +## CHECK "global": globals +## _________________________________________________________________ +## + +sub check_global { + my ($file, $spec) = @_; + + # check for deprecated use of opServiceEnabled function + my $done = ''; my $this = ''; my $todo = $spec; + while ($todo =~ m/\bopServiceEnabled\b/s) { + $done .= $`; $this = $&; $todo = $'; + &lint_warning($file, $done, $this, "deprecated usage of opServiceEnabled macro (expected opService ... enable yes)"); + $done .= $this; + } +} @@ . ______________________________________________________________________ The OpenPKG Project www.openpkg.org CVS Repository Commit List [EMAIL PROTECTED]