Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 98 lines (79 sloc) 2.65 kb
35984ed Partial commit of build system.
Matthew Hancher authored
1 #!/usr/bin/perl
6339150 @novas0x2a final love for relicense
novas0x2a authored
2 # __BEGIN_LICENSE__
4f0ea7b @novas0x2a update copyright headers
novas0x2a authored
3 # Copyright (C) 2006-2011 United States Government as represented by
6339150 @novas0x2a final love for relicense
novas0x2a authored
4 # the Administrator of the National Aeronautics and Space Administration.
5 # All Rights Reserved.
6 # __END_LICENSE__
7
8
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
9 use strict;
10 use warnings;
35984ed Partial commit of build system.
Matthew Hancher authored
11
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
12 use File::Slurp;
13 use File::Basename;
35984ed Partial commit of build system.
Matthew Hancher authored
14
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
15 my %comment = (
16 ".ac" => "dnl",
17 ".am" => "#",
ee66d9b @novas0x2a add c and protobuf code to the relicense list
novas0x2a authored
18 ".c" => "//",
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
19 ".cc" => "//",
ea86aa9 @novas0x2a relicense VW files
novas0x2a authored
20 ".cpp" => "//",
21 ".cxx" => "//",
0ae8a55 @novas0x2a add oldtest to the license file whitelist, and year++
novas0x2a authored
22 ".oldtest" => "//",
ea86aa9 @novas0x2a relicense VW files
novas0x2a authored
23 ".hpp" => "//",
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
24 ".cg" => "//",
25 ".glsl" => "//",
26 ".h" => "//",
6339150 @novas0x2a final love for relicense
novas0x2a authored
27 ".hh" => "//",
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
28 ".i" => "//",
29 ".m4" => "dnl",
30 ".mak" => "#",
31 ".pl" => "#",
ee66d9b @novas0x2a add c and protobuf code to the relicense list
novas0x2a authored
32 ".proto" => "//",
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
33 ".py" => "#",
6339150 @novas0x2a final love for relicense
novas0x2a authored
34 ".sh" => "#",
35 ".js" => "//",
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
36 ".tcc" => "//",
37 );
35984ed Partial commit of build system.
Matthew Hancher authored
38
c303447 @novas0x2a fix relicensing
novas0x2a authored
39 # Read the license text from __DATA__ by default
40 my $f = \*DATA;
41 $f = $ARGV[0] if @ARGV > 0;
42
43 my @license = read_file($f);
6339150 @novas0x2a final love for relicense
novas0x2a authored
44 my $shebang = '';
35984ed Partial commit of build system.
Matthew Hancher authored
45
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
46 # process each line given on stdin
47 foreach my $filename (<>) {
48 chomp $filename;
49
50 # get the extension, and skip it if we don't know about it
51 my (undef, undef, $ext) = fileparse($filename, qr/\.[^.]*/);
6339150 @novas0x2a final love for relicense
novas0x2a authored
52
53 unless (exists $comment{$ext}) {
54 warn "Skipped $filename\n";
55 next;
56 }
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
57
58 my $file = read_file($filename);
59
6339150 @novas0x2a final love for relicense
novas0x2a authored
60 $shebang = '';
61 # Protect a shebang line
62 if ($file =~ s/^(#!.*\n)//) {
63 if (defined($1)) {
64 $shebang = $1;
65 }
66 }
67
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
68 # Remove a license header if it exists
6339150 @novas0x2a final love for relicense
novas0x2a authored
69 $file =~ s/^[^\n]*__BEGIN_LICENSE__.*?__END_LICENSE__[^\n]*$//ms;
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
70
71 # Remove all blank files from the top of the file
72 while ($file =~ s/^\s*\n//) {};
73
74 # prepend the license text, prepending the comment string to each line.
75 # Also, separate the license header from content by two blank lines
6339150 @novas0x2a final love for relicense
novas0x2a authored
76 $file = $shebang . $comment{$ext} . join($comment{$ext}, @license) . "\n\n" . $file;
35984ed Partial commit of build system.
Matthew Hancher authored
77
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
78 write_file($filename, $file);
35984ed Partial commit of build system.
Matthew Hancher authored
79 }
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
80
81 __DATA__
82 __BEGIN_LICENSE__
426c2c3 @zmoratto all: Relicense VW as Apache 2
zmoratto authored
83 Copyright (c) 2006-2012, United States Government as represented by the
84 Administrator of the National Aeronautics and Space Administration. All
85 rights reserved.
86
87 The NASA Vision Workbench is licensed under the Apache License,
88 Version 2.0 (the "License"); you may not use this file except in
89 compliance with the License. You may obtain a copy of the License at
90 http://www.apache.org/licenses/LICENSE-2.0
91
92 Unless required by applicable law or agreed to in writing, software
93 distributed under the License is distributed on an "AS IS" BASIS,
94 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95 See the License for the specific language governing permissions and
96 limitations under the License.
8823597 @novas0x2a give the relicense script some love. it's all ready to go when we figure
novas0x2a authored
97 __END_LICENSE__
Something went wrong with that request. Please try again.