12
12
my %text_files = ('txt' => 1, 'spec' => 1, 'in' => 1);
14
14
# files which don't get the license added
15
my %no_license = (); # 'filename' => 1
15
# my %file_license = (); # 'filename' => 'GPL', 'DUAL' or 'none'
17
17
# ----------------------------------------------
19
19
# filled in from the manifest file
20
my %no_license_dir = ();
20
# my %dir_license = (); # 'dir' => 'GPL', 'DUAL' or 'none'
22
# most recently specified LICENSE become default until overridden
23
my $current_license; # 'GPL', 'DUAL' or 'none'
22
25
# distribution name
23
26
my $distribution = $ARGV[0];
68
71
system "rm $base_name.tgz";
69
72
mkdir $base_name,0755;
72
open LICENSE,"$dist_root/LICENSE.txt" or die "Can't open $dist_root/LICENSE.txt";
74
read LICENSE,$license_f,100000;
76
my @license = ('distribution '.$base_name.' (svn version: '.$svnversion.')',split(/\n/,$license_f));
75
my %license_text; # name of license => array of lines of license text
76
foreach my $license ("GPL", "DUAL")
78
my $file = "./LICENSE-$license.txt";
79
open LICENSE, $file or die "Can't open $file: $!";
80
my @lines = <LICENSE>;
82
unshift @lines, "distribution $base_name (svn version: $svnversion)\n";
83
$license_text{$license} = \@lines;
78
86
# copy files, make a note of all the modules included
79
87
my %modules_included;
89
97
next unless $line =~ m/\S/;
91
my ($src,$dst,$other) = split /\s+/, $line;
99
my @words = split /\s+/, $line;
100
my ($src,$dst,$other) = @words;
92
101
$dst = $src if $dst eq '';
93
102
if($src eq 'MKDIR')
95
104
# actually we just need to make a directory here
96
105
mkdir "$base_name/$dst",0755;
98
elsif($src eq 'NO-LICENSE-IN-DIR')
107
elsif($src eq 'LICENSE')
100
my ($junk,$spec) = split /\s+/, $line;
101
# record that this directory shouldn't have the license added
102
$no_license_dir{$dst} = 1;
104
# actually copy it, to remove redundancy in manifests
107
$dst = $src if $dst eq '';
108
$modules_included{$spec} = 1;
109
$current_license = $dst;
111
111
elsif($src eq 'REPLACE-VERSION-IN')
113
113
replace_version_in($dst);
115
elsif($src eq 'NO-LICENSE')
117
$no_license{$dst} = 1;
119
# actually copy it, to remove redundancy in manifests
122
$dst = $src if $dst eq '';
124
copy_file($src,$dst);
126
115
elsif($src eq 'RUN')
128
117
my ($junk,$cmd) = split /\s+/, $line, 2;
191
180
$ext = $1 if $fn =~ m/\.(\w+)\Z/;
193
# licenses not used in this directory?
194
my $license_in_dir = 1;
195
181
$dst_fn =~ m~\A(.+)/[^/]+?\Z~;
196
$license_in_dir = 0 if exists $no_license_dir{$1};
198
183
# licensed or not?
199
if(exists $comment_chars{$ext} && !exists $no_license{$fn} && $license_in_dir)
184
if(exists $comment_chars{$ext} && $current_license ne "none")
201
186
# copy as text, inserting license
202
187
# print "source copy $fn to $base_name/$dst_fn\n";