Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 #! /usr/local/bin/perl
2 #
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 require('coreconf.pl');
8 #######-- read in variables on command line into %var
10 &parse_argv;
12 ### do the copy
14 print STDERR "RELEASE TREE / MODULE = $var{RELEASE_TREE} $var{MODULE}\n";
18 # 1
19 if ($var{RELEASE} eq "") { exit; } # Can't do release here, so exit.
21 # 2
22 #if (! ($var{RELEASE} =~ /\//)) { # if no specific version is specified in RELEASE variable
23 # $component = $var{RELEASE};
24 #}
25 #else { # if a subcomponent/version is given in the RELEASE variable
26 # $var{RELEASE} =~ m|^([^/]*)/|;
27 # $component = $1; # everything before the first slash;
28 # }
30 # 3
31 $path = $var{RELEASE};
34 # 4
35 # find out what directory we would create for 'today'
37 $year = (localtime)[5] + 1900;
38 $month = (localtime)[4] + 1;
39 $day = (localtime)[3];
40 $today = sprintf( "%d%02d%02d", $year, $month, $day );
42 # 5
43 # if version is null, then set the version to today.
44 if ($var{"RELEASE_VERSION"} eq "") {
45 $var{"RELEASE_VERSION"} = $today;
46 }
48 #6
49 $version = $var{"RELEASE_VERSION"}; # set RELEASE_VERSION to passed in variable
51 #7
52 # if version is today, then we will want to make a 'current' link.
54 if ($version eq $today) {
55 $create_current = 1;
56 }
58 #8
59 # version can be a) passed in value from command line, b) value in manifest.mn
60 # or c) computed value such as '19970909'
63 $dir = "$var{'RELEASE_TREE'}/$path";
65 #9
66 if (! (-e "$dir/$version" && -d "$dir/$version")) {
67 print "making dir $dir \n";
68 &rec_mkdir("$dir/$version");
69 }
73 print "version = $version\n";
74 print "path = $path\n";
75 print "var{release_tree} = $var{'RELEASE_TREE'}\n";
76 print "dir = $dir = RELEASE_TREE/path\n";
79 #10
80 if ($create_current == 1) {
82 # unlinking and linking always occurs, even if the link is correct
83 print "unlinking $dir/current\n";
84 unlink("$dir/current");
86 print "putting version number $today into 'current' file..";
88 open(FILE,">$dir/current") || die " couldn't open current\n";
89 print FILE "$today\n";
90 close(FILE);
91 print " ..done\n"
93 }
95 &rec_mkdir("$dir/$version/$var{'RELEASE_MD_DIR'}");
96 &rec_mkdir("$dir/$version/$var{'RELEASE_XP_DIR'}");
101 foreach $jarfile (split(/ /,$var{FILES}) ) {
102 print STDERR "---------------------------------------------\n";
104 $jarinfo = $var{$jarfile};
106 ($jardir,$jaropts) = split(/\|/,$jarinfo);
108 if ($jaropts =~ /f/) {
109 print STDERR "Copying files $jardir....\n";
110 }
111 else {
112 print STDERR "Copying jar file $jarfile....\n";
113 }
115 print "jaropts = $jaropts\n";
117 if ($jaropts =~ /m/) {
118 $destdir = $var{"RELEASE_MD_DIR"};
119 print "found m, using MD dir $destdir\n";
120 }
121 elsif ($jaropts =~ /x/) {
122 $destdir = $var{"RELEASE_XP_DIR"};
123 print "found x, using XP dir $destdir\n";
124 }
125 else {
126 die "Error: must specify m or x in jar options in $jarinfo line\n";
127 }
130 $distdir = "$dir/$version/$destdir";
134 if ($jaropts =~ /f/) {
136 print "splitting: \"$jardir\"\n";
137 for $srcfile (split(/ /,$jardir)) {
139 #if srcfile has a slash
140 if ($srcfile =~ m|/|) {
141 #pull out everything before the last slash into $1
142 $srcfile =~ m|(.*)/|;
143 $distsubdir = "/$1";
144 print "making dir $distdir$distsubdir\n";
145 &rec_mkdir("$distdir$distsubdir");
146 }
147 print "copy: from $srcfile\n";
148 print " to $distdir$distsubdir\n";
149 $srcprefix = "";
150 if ($jaropts =~/m/) {
151 $srcprefix = "$var{'PLATFORM'}/";
152 }
153 system("cp $srcprefix$srcfile $distdir$distsubdir");
154 }
155 }
156 else {
157 $srcfile = "$var{SOURCE_RELEASE_PREFIX}/$jardir/$jarfile";
159 print "copy: from $srcfile\n";
160 print " to $distdir\n";
162 system("cp $srcfile $distdir");
164 }
166 }