michael@0: #! /usr/local/bin/perl michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: require('coreconf.pl'); michael@0: michael@0: #######-- read in variables on command line into %var michael@0: michael@0: &parse_argv; michael@0: michael@0: ### do the copy michael@0: michael@0: print STDERR "RELEASE TREE / MODULE = $var{RELEASE_TREE} $var{MODULE}\n"; michael@0: michael@0: michael@0: michael@0: # 1 michael@0: if ($var{RELEASE} eq "") { exit; } # Can't do release here, so exit. michael@0: michael@0: # 2 michael@0: #if (! ($var{RELEASE} =~ /\//)) { # if no specific version is specified in RELEASE variable michael@0: # $component = $var{RELEASE}; michael@0: #} michael@0: #else { # if a subcomponent/version is given in the RELEASE variable michael@0: # $var{RELEASE} =~ m|^([^/]*)/|; michael@0: # $component = $1; # everything before the first slash; michael@0: # } michael@0: michael@0: # 3 michael@0: $path = $var{RELEASE}; michael@0: michael@0: michael@0: # 4 michael@0: # find out what directory we would create for 'today' michael@0: michael@0: $year = (localtime)[5] + 1900; michael@0: $month = (localtime)[4] + 1; michael@0: $day = (localtime)[3]; michael@0: $today = sprintf( "%d%02d%02d", $year, $month, $day ); michael@0: michael@0: # 5 michael@0: # if version is null, then set the version to today. michael@0: if ($var{"RELEASE_VERSION"} eq "") { michael@0: $var{"RELEASE_VERSION"} = $today; michael@0: } michael@0: michael@0: #6 michael@0: $version = $var{"RELEASE_VERSION"}; # set RELEASE_VERSION to passed in variable michael@0: michael@0: #7 michael@0: # if version is today, then we will want to make a 'current' link. michael@0: michael@0: if ($version eq $today) { michael@0: $create_current = 1; michael@0: } michael@0: michael@0: #8 michael@0: # version can be a) passed in value from command line, b) value in manifest.mn michael@0: # or c) computed value such as '19970909' michael@0: michael@0: michael@0: $dir = "$var{'RELEASE_TREE'}/$path"; michael@0: michael@0: #9 michael@0: if (! (-e "$dir/$version" && -d "$dir/$version")) { michael@0: print "making dir $dir \n"; michael@0: &rec_mkdir("$dir/$version"); michael@0: } michael@0: michael@0: michael@0: michael@0: print "version = $version\n"; michael@0: print "path = $path\n"; michael@0: print "var{release_tree} = $var{'RELEASE_TREE'}\n"; michael@0: print "dir = $dir = RELEASE_TREE/path\n"; michael@0: michael@0: michael@0: #10 michael@0: if ($create_current == 1) { michael@0: michael@0: # unlinking and linking always occurs, even if the link is correct michael@0: print "unlinking $dir/current\n"; michael@0: unlink("$dir/current"); michael@0: michael@0: print "putting version number $today into 'current' file.."; michael@0: michael@0: open(FILE,">$dir/current") || die " couldn't open current\n"; michael@0: print FILE "$today\n"; michael@0: close(FILE); michael@0: print " ..done\n" michael@0: michael@0: } michael@0: michael@0: &rec_mkdir("$dir/$version/$var{'RELEASE_MD_DIR'}"); michael@0: &rec_mkdir("$dir/$version/$var{'RELEASE_XP_DIR'}"); michael@0: michael@0: michael@0: michael@0: michael@0: foreach $jarfile (split(/ /,$var{FILES}) ) { michael@0: print STDERR "---------------------------------------------\n"; michael@0: michael@0: $jarinfo = $var{$jarfile}; michael@0: michael@0: ($jardir,$jaropts) = split(/\|/,$jarinfo); michael@0: michael@0: if ($jaropts =~ /f/) { michael@0: print STDERR "Copying files $jardir....\n"; michael@0: } michael@0: else { michael@0: print STDERR "Copying jar file $jarfile....\n"; michael@0: } michael@0: michael@0: print "jaropts = $jaropts\n"; michael@0: michael@0: if ($jaropts =~ /m/) { michael@0: $destdir = $var{"RELEASE_MD_DIR"}; michael@0: print "found m, using MD dir $destdir\n"; michael@0: } michael@0: elsif ($jaropts =~ /x/) { michael@0: $destdir = $var{"RELEASE_XP_DIR"}; michael@0: print "found x, using XP dir $destdir\n"; michael@0: } michael@0: else { michael@0: die "Error: must specify m or x in jar options in $jarinfo line\n"; michael@0: } michael@0: michael@0: michael@0: $distdir = "$dir/$version/$destdir"; michael@0: michael@0: michael@0: michael@0: if ($jaropts =~ /f/) { michael@0: michael@0: print "splitting: \"$jardir\"\n"; michael@0: for $srcfile (split(/ /,$jardir)) { michael@0: michael@0: #if srcfile has a slash michael@0: if ($srcfile =~ m|/|) { michael@0: #pull out everything before the last slash into $1 michael@0: $srcfile =~ m|(.*)/|; michael@0: $distsubdir = "/$1"; michael@0: print "making dir $distdir$distsubdir\n"; michael@0: &rec_mkdir("$distdir$distsubdir"); michael@0: } michael@0: print "copy: from $srcfile\n"; michael@0: print " to $distdir$distsubdir\n"; michael@0: $srcprefix = ""; michael@0: if ($jaropts =~/m/) { michael@0: $srcprefix = "$var{'PLATFORM'}/"; michael@0: } michael@0: system("cp $srcprefix$srcfile $distdir$distsubdir"); michael@0: } michael@0: } michael@0: else { michael@0: $srcfile = "$var{SOURCE_RELEASE_PREFIX}/$jardir/$jarfile"; michael@0: michael@0: print "copy: from $srcfile\n"; michael@0: print " to $distdir\n"; michael@0: michael@0: system("cp $srcfile $distdir"); michael@0: michael@0: } michael@0: michael@0: } michael@0: