Imported Upstream version 3.13.6
[platform/upstream/nss.git] / mozilla / security / coreconf / cpdist.pl
1 #! /usr/local/bin/perl
2 #
3 # ***** BEGIN LICENSE BLOCK *****
4 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 #
6 # The contents of this file are subject to the Mozilla Public License Version
7 # 1.1 (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 # http://www.mozilla.org/MPL/
10 #
11 # Software distributed under the License is distributed on an "AS IS" basis,
12 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 # for the specific language governing rights and limitations under the
14 # License.
15 #
16 # The Original Code is the Netscape security libraries.
17 #
18 # The Initial Developer of the Original Code is
19 # Netscape Communications Corporation.
20 # Portions created by the Initial Developer are Copyright (C) 1994-2000
21 # the Initial Developer. All Rights Reserved.
22 #
23 # Contributor(s):
24 #
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
36 #
37 # ***** END LICENSE BLOCK *****
38 require('coreconf.pl');
39
40 #######-- read in variables on command line into %var
41
42 &parse_argv;
43  
44 ### do the copy
45
46 print STDERR "RELEASE TREE / MODULE =  $var{RELEASE_TREE} $var{MODULE}\n";
47
48
49
50 # 1
51 if ($var{RELEASE} eq "") { exit; } # Can't do release here, so exit.
52
53 # 2
54 #if (! ($var{RELEASE} =~ /\//)) {   # if no specific version is specified in RELEASE variable
55 #    $component = $var{RELEASE};
56 #}
57 #else {  # if a subcomponent/version is given in the RELEASE variable
58 #        $var{RELEASE} =~ m|^([^/]*)/|;  
59 #       $component = $1;           # everything before the first slash;
60 #    }
61
62 # 3
63 $path = $var{RELEASE};
64
65
66 # 4
67 # find out what directory we would create for 'today'
68
69 $year = (localtime)[5] + 1900;
70 $month = (localtime)[4] + 1;
71 $day = (localtime)[3];
72 $today = sprintf( "%d%02d%02d", $year, $month, $day );
73
74 # 5
75 # if version is null, then set the version to today.
76 if ($var{"RELEASE_VERSION"} eq "") {
77     $var{"RELEASE_VERSION"} = $today;
78 }
79
80 #6
81 $version = $var{"RELEASE_VERSION"};  # set RELEASE_VERSION to passed in variable
82
83 #7
84 # if version is today, then we will want to make a 'current' link.
85
86 if ($version eq $today) {
87     $create_current = 1;
88 }
89
90 #8
91 # version can be a) passed in value from command line, b) value in manifest.mn
92 # or c) computed value such as '19970909'
93
94
95 $dir = "$var{'RELEASE_TREE'}/$path";
96
97 #9
98 if (! (-e "$dir/$version" && -d "$dir/$version")) {
99     print "making dir $dir \n";
100     &rec_mkdir("$dir/$version");
101 }
102
103
104
105 print "version = $version\n";
106 print "path = $path\n";
107 print "var{release_tree} = $var{'RELEASE_TREE'}\n";
108 print "dir = $dir   = RELEASE_TREE/path\n";
109
110
111 #10
112 if ($create_current == 1) {
113
114 # unlinking and linking always occurs, even if the link is correct
115     print "unlinking $dir/current\n";
116     unlink("$dir/current");
117     
118     print "putting version number $today into 'current' file..";
119
120     open(FILE,">$dir/current") || die " couldn't open current\n";
121     print FILE "$today\n";
122     close(FILE);
123     print " ..done\n"
124     
125 }
126
127 &rec_mkdir("$dir/$version/$var{'RELEASE_MD_DIR'}");
128 &rec_mkdir("$dir/$version/$var{'RELEASE_XP_DIR'}");
129
130
131
132
133 foreach $jarfile (split(/ /,$var{FILES}) ) {
134     print STDERR "---------------------------------------------\n";
135     
136     $jarinfo = $var{$jarfile};
137  
138     ($jardir,$jaropts) = split(/\|/,$jarinfo);
139  
140     if ($jaropts =~ /f/) {
141       print STDERR "Copying files $jardir....\n";
142     }
143     else {
144       print STDERR "Copying jar file $jarfile....\n";
145     }
146     
147     print "jaropts = $jaropts\n";
148     
149     if ($jaropts =~ /m/) {
150       $destdir = $var{"RELEASE_MD_DIR"};
151       print "found m, using MD dir $destdir\n";
152     }
153     elsif ($jaropts =~ /x/) {
154       $destdir = $var{"RELEASE_XP_DIR"};
155       print "found x, using XP dir $destdir\n";
156     }
157     else {
158       die "Error: must specify m or x in jar options in $jarinfo line\n";
159     }
160     
161     
162     $distdir = "$dir/$version/$destdir";
163     
164
165
166     if ($jaropts =~ /f/) {
167
168       print "splitting: \"$jardir\"\n";
169       for $srcfile (split(/ /,$jardir)) {
170
171 #if srcfile has a slash
172         if ($srcfile =~ m|/|) {
173 #pull out everything before the last slash into $1
174           $srcfile =~ m|(.*)/|;
175           $distsubdir = "/$1";
176           print "making dir $distdir$distsubdir\n";
177           &rec_mkdir("$distdir$distsubdir");
178         }
179         print "copy: from $srcfile\n";
180         print "      to   $distdir$distsubdir\n";
181         $srcprefix = "";
182         if ($jaropts =~/m/) {
183           $srcprefix = "$var{'PLATFORM'}/";
184         }
185         system("cp $srcprefix$srcfile $distdir$distsubdir");
186       }
187     }
188     else {
189       $srcfile = "$var{SOURCE_RELEASE_PREFIX}/$jardir/$jarfile";
190       
191       print "copy: from $srcfile\n";
192       print "      to   $distdir\n";
193       
194       system("cp $srcfile $distdir");
195       
196     }
197     
198   }
199