Print this page
6924 make libc copyright file contents deterministic
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libc/extract-copyright.pl
+++ new/usr/src/lib/libc/extract-copyright.pl
1 1 #! /usr/perl5/bin/perl
2 2 #
3 3 # This file and its contents are supplied under the terms of the
4 4 # Common Development and Distribution License ("CDDL"), version 1.0.
↓ open down ↓ |
4 lines elided |
↑ open up ↑ |
5 5 # You may only use this file in accordance with the terms version
6 6 # 1.0 of the CDDL.
7 7 #
8 8 # A full copy of the text of the CDDL should have accompanied this
9 9 # source. A copy is of the CDDL is also available via the Internet
10 10 # at http://www.illumos.org/license/CDDL.
11 11 #
12 12
13 13 #
14 14 # Copyright 2010 Nexenta Systems, Inc. All rights reserved.
15 +# Copyright 2016 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
15 16 #
16 17
17 18 #
18 19 # This extracts all the BSD copyrights (excluding the CDDL licenses)
19 20 # for use in a THIRDPARTYLICENSE file. It tries hard to avoid duplicates.
20 21 #
21 22
22 23 use strict;
23 24 use warnings;
24 25 use File::Find;
25 26
26 27 my %LICENSE = ();
27 28
28 29 sub dofile
29 30 {
30 31 my $file = shift;
31 32 my $comment = 0;
32 33 my @license = ();
33 34 my @block = ();;
34 35 my $copyr = 0;
35 36 open(FILE, $file);
36 37 while (<FILE>) {
37 38 if (/^\/\*$/) {
38 39 $comment = 1;
39 40 $copyr = 0;
40 41 @block = ();
41 42 next;
42 43 }
43 44 if (!$comment) {
44 45 next;
45 46 }
46 47 #
47 48 # We don't want to know about CDDL files. They don't
48 49 # require an explicit THIRDPARTYLICENSE file.
49 50 #
50 51 if (/CDDL/) {
51 52 #print "$file is CDDL.\n";
52 53 close(FILE);
53 54 return;
54 55 }
55 56 if (/Copyright/) {
56 57 $copyr = 1;
57 58 }
58 59 if (!/^ \*\//) {
59 60 push(@block, $_);
60 61 next;
61 62 }
62 63 #
63 64 # We have reached the end of the comment now.
64 65 #
65 66 $comment = 0;
66 67
67 68 # Check to see if we saw a copyright.
68 69 if (!$copyr) {
69 70 next;
70 71 }
71 72 my $line;
72 73 foreach $line (@block) {
73 74 chomp $line;
74 75 $line =~ s/^ \* //;
75 76 $line =~ s/^ \*//;
76 77 $line =~ s/^ \*$//;
77 78 push(@license, $line);
78 79 }
79 80 }
80 81
81 82 if ($#license > 0) {
82 83 my $lic = join "\n", @license;
83 84 push (@{$LICENSE{$lic}}, $file);
84 85 }
85 86
86 87 close(FILE);
87 88 }
88 89
89 90 my @FILES;
90 91
91 92 sub wanted {
92 93 my $path = $File::Find::name;
93 94
94 95 if (!-f $path) {
95 96 if ($path =~ /\.[chs]$/) {
96 97 push(@FILES, $path);
97 98 }
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
98 99 }
99 100
100 101 }
101 102 foreach $a (@ARGV) {
102 103 if (-d $a) {
103 104 find(\&wanted, $a);
104 105 } elsif (-f $a) {
105 106 push(@FILES, $a);
106 107 }
107 108 }
109 +
110 +# sort files to get a stable ordering to aid wsdiff(1onbld)
111 +@FILES = sort @FILES;
108 112
109 113 foreach $a (@FILES) {
110 114 dofile($a);
111 115 }
112 116
113 117 foreach my $lic (keys %LICENSE) {
114 118 my @files = @{$LICENSE{$lic}};
115 119 print "\nThe following files from the C library:\n";
116 120 foreach my $f (@files) {
117 121 print(" $f\n");
118 122 }
119 123 print "are provided under the following terms:\n\n";
120 124 print "$lic\n";
121 125 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX