~ubuntu-branches/ubuntu/intrepid/kdesdk/intrepid-updates

« back to all changes in this revision

Viewing changes to scripts/check_licenses

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2008-05-28 10:11:43 UTC
  • mto: This revision was merged to the branch mainline in revision 37.
  • Revision ID: james.westby@ubuntu.com-20080528101143-gzc3styjz1b70zxu
Tags: upstream-4.0.80
ImportĀ upstreamĀ versionĀ 4.0.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
unless (scalar(@ARGV) == 1)
4
 
{
5
 
  die "Usage: check_licenses directory";
6
 
}
7
 
 
8
 
my $gpl = 'General Public License';
9
 
my $gp2 = 'This is free software; it comes under the GNU';
10
 
my $gp3 = 'License: GPL with the following explicit clarification';
11
 
my $x11 = 'TORT OR OTHERWISE';
12
 
my $bsd = 'INCLUDING NEGLIGENCE OR OTHERWISE';
13
 
my $gen = 'generated';
14
 
 
15
 
sub nameok()
16
 
{
17
 
  my $f = shift;
18
 
 
19
 
  if ($f =~ /\.C$/ or $f =~ /\.cpp$/ or $f =~ /\.c$/ or $f =~ /\.h$/)
20
 
  {
21
 
    if ($f =~ /\.cpp$/)
22
 
    {
23
 
      if
24
 
        (
25
 
              $f !~ /meta_unload\.cpp$/
26
 
         and  $f !~ /_stub\.cpp/
27
 
         and  $f !~ /_skel.cpp/
28
 
         and  $f !~ /_closure\.cpp/
29
 
         and  $f !~ /moc\.cpp/
30
 
        )
31
 
      {
32
 
        return 1;
33
 
      }
34
 
      else
35
 
      {
36
 
        return 0;
37
 
      }
38
 
    }
39
 
    else
40
 
    {
41
 
      return 1;
42
 
    }
43
 
  }
44
 
  else
45
 
  {
46
 
    return 0;
47
 
  }
48
 
}
49
 
 
50
 
sub recursive_check()
51
 
{
52
 
  my $dir = shift;
53
 
 
54
 
  opendir (DIR, $dir) or die "Can't open $dir";
55
 
 
56
 
  my @filenames = grep { /^[^\.]/ } readdir(DIR);
57
 
 
58
 
  for my $f (@filenames)
59
 
  {
60
 
    my $filename = "$dir/$f";
61
 
 
62
 
    if (-d $filename)
63
 
    {
64
 
      &recursive_check($filename);
65
 
    }
66
 
    elsif (-f $filename and &nameok($filename))
67
 
    {
68
 
      open (IN, "<$filename") or die "Can't open $filename";
69
 
 
70
 
      my $license = "!";
71
 
 
72
 
      while (<IN>)
73
 
      {
74
 
        if (/$gpl/) { $license = "G"; last; }
75
 
        if (/$gp2/) { $license = "G"; last; }
76
 
        if (/$gp3/) { $license = "G"; last; }
77
 
        if (/$x11/) { $license = "X"; last; }
78
 
        if (/$bsd/) { $license = "B"; last; }
79
 
        if (/$gen/) { $license = "g"; last; }
80
 
      }
81
 
 
82
 
      print "$license $filename\n";
83
 
    }
84
 
  }
85
 
}
86
 
 
87
 
&recursive_check($ARGV[0]);
88