4526 nightly contains a great deal of effectively dead code
[illumos-gate.git] / usr / src / tools / scripts / mktpl.pl
blob15787e2288cbd4e78d3f3aacac78b8929e854823
1 #! /usr/bin/perl -w
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
20 # CDDL HEADER END
24 # Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
28 # Create THIRDPARTYLICENSE files using the index file in $CODEMGR_WS.
31 use Cwd;
32 use Env;
33 use strict;
34 use vars qw($opt_c);
35 use Getopt::Std;
37 # -c: only generate crypto license file
38 my $usage = "mktpl [-c] license-list-file";
40 my $top = $ENV{"CODEMGR_WS"};
41 if (! $top) {
42 die "CODEMGR_WS must be set.\n";
45 if (! getopts('c')) {
46 die "usage: $usage\n";
48 if (@ARGV != 1) {
49 die "usage: $usage\n";
52 my $indexfile = $ARGV[0];
54 my $exitstatus = 0;
57 # Create a THIRDPARTYLICENSE file from the given license list and suffix.
59 sub maketpl {
60 my ($suffix, @tpllist) = @_;
61 my $licnum = 1;
62 my $tplname = "$top/THIRDPARTYLICENSE.$suffix";
64 if (! @tpllist) {
65 unlink $tplname;
66 return;
69 open(TPL, ">$tplname") or die "Can't create $tplname: $!\n";
71 print TPL "DO NOT TRANSLATE OR LOCALIZE.\n\n";
73 foreach my $licfile (@tpllist) {
74 my $descrip = `cat "$licfile.descrip"`;
75 if (! $descrip) {
76 warn "Missing description for $licfile\n";
77 $exitstatus = 1;
78 $descrip = "(MISSING DESCRIPTION for $licfile)\n";
80 print TPL "$licnum) The following software may be included ",
81 "in this product:\n\n";
82 print TPL "\t$descrip\n";
83 print TPL " Use of this software is governed by the ",
84 "terms of the following license:\n";
85 print TPL "\n";
86 if (open(LIC, "<$licfile")) {
87 while (<LIC>) {
88 print TPL " " . $_;
90 close LIC;
91 } else {
92 warn "Can't open $licfile: $!\n";
93 $exitstatus = 1;
94 print TPL " (MISSING LICENSE: $licfile)\n";
96 print TPL "\n";
97 $licnum++;
100 close TPL or die "I/O error on $tplname: $!\n";
104 # Return non-zero if we expect the crypto for the given
105 # third-party license file to be signed. Else, return zero.
107 my $hashes = qr"/(rng|md4|md5|sha1/sha2)/";
108 sub signedcrypto {
109 my ($licpath) = @_;
111 return 0 if $licpath =~ m#$hashes#;
112 return 1;
116 # Make file list for each TPL file.
119 chdir($top) or die "Can't chdir to $top: $!\n";
120 $top = getcwd();
122 my $isclosed = qr"^usr/closed";
123 my $iscrypto = qr"(^usr/src/common/crypto)|(^usr/src/lib/pkcs11)";
125 my @closedlist;
126 my @cryptolist;
128 open(IX, "<$indexfile") or die "Can't open $indexfile: $!\n";
129 while (<IX>) {
130 chomp;
131 my $lic = $_;
132 if (! $opt_c && $lic =~ /$isclosed/) {
133 push @closedlist, $lic;
135 if ($lic =~ /$iscrypto/ && signedcrypto($lic)) {
136 push @cryptolist, $lic;
139 close IX;
142 # Generate each TPL file.
145 maketpl("ON-BINARIES", @closedlist);
146 maketpl("ON-CRYPTO", @cryptolist);
148 exit $exitstatus;