cpdist.pl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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');
  7. #######-- read in variables on command line into %var
  8. &parse_argv;
  9. ### do the copy
  10. print STDERR "RELEASE TREE / MODULE = $var{RELEASE_TREE} $var{MODULE}\n";
  11. # 1
  12. if ($var{RELEASE} eq "") { exit; } # Can't do release here, so exit.
  13. # 2
  14. #if (! ($var{RELEASE} =~ /\//)) { # if no specific version is specified in RELEASE variable
  15. # $component = $var{RELEASE};
  16. #}
  17. #else { # if a subcomponent/version is given in the RELEASE variable
  18. # $var{RELEASE} =~ m|^([^/]*)/|;
  19. # $component = $1; # everything before the first slash;
  20. # }
  21. # 3
  22. $path = $var{RELEASE};
  23. # 4
  24. # find out what directory we would create for 'today'
  25. $year = (localtime)[5] + 1900;
  26. $month = (localtime)[4] + 1;
  27. $day = (localtime)[3];
  28. $today = sprintf( "%d%02d%02d", $year, $month, $day );
  29. # 5
  30. # if version is null, then set the version to today.
  31. if ($var{"RELEASE_VERSION"} eq "") {
  32. $var{"RELEASE_VERSION"} = $today;
  33. }
  34. #6
  35. $version = $var{"RELEASE_VERSION"}; # set RELEASE_VERSION to passed in variable
  36. #7
  37. # if version is today, then we will want to make a 'current' link.
  38. if ($version eq $today) {
  39. $create_current = 1;
  40. }
  41. #8
  42. # version can be a) passed in value from command line, b) value in manifest.mn
  43. # or c) computed value such as '19970909'
  44. $dir = "$var{'RELEASE_TREE'}/$path";
  45. #9
  46. if (! (-e "$dir/$version" && -d "$dir/$version")) {
  47. print "making dir $dir \n";
  48. &rec_mkdir("$dir/$version");
  49. }
  50. print "version = $version\n";
  51. print "path = $path\n";
  52. print "var{release_tree} = $var{'RELEASE_TREE'}\n";
  53. print "dir = $dir = RELEASE_TREE/path\n";
  54. #10
  55. if ($create_current == 1) {
  56. # unlinking and linking always occurs, even if the link is correct
  57. print "unlinking $dir/current\n";
  58. unlink("$dir/current");
  59. print "putting version number $today into 'current' file..";
  60. open(FILE,">$dir/current") || die " couldn't open current\n";
  61. print FILE "$today\n";
  62. close(FILE);
  63. print " ..done\n"
  64. }
  65. &rec_mkdir("$dir/$version/$var{'RELEASE_MD_DIR'}");
  66. &rec_mkdir("$dir/$version/$var{'RELEASE_XP_DIR'}");
  67. foreach $jarfile (split(/ /,$var{FILES}) ) {
  68. print STDERR "---------------------------------------------\n";
  69. $jarinfo = $var{$jarfile};
  70. ($jardir,$jaropts) = split(/\|/,$jarinfo);
  71. if ($jaropts =~ /f/) {
  72. print STDERR "Copying files $jardir....\n";
  73. }
  74. else {
  75. print STDERR "Copying jar file $jarfile....\n";
  76. }
  77. print "jaropts = $jaropts\n";
  78. if ($jaropts =~ /m/) {
  79. $destdir = $var{"RELEASE_MD_DIR"};
  80. print "found m, using MD dir $destdir\n";
  81. }
  82. elsif ($jaropts =~ /x/) {
  83. $destdir = $var{"RELEASE_XP_DIR"};
  84. print "found x, using XP dir $destdir\n";
  85. }
  86. else {
  87. die "Error: must specify m or x in jar options in $jarinfo line\n";
  88. }
  89. $distdir = "$dir/$version/$destdir";
  90. if ($jaropts =~ /f/) {
  91. print "splitting: \"$jardir\"\n";
  92. for $srcfile (split(/ /,$jardir)) {
  93. #if srcfile has a slash
  94. if ($srcfile =~ m|/|) {
  95. #pull out everything before the last slash into $1
  96. $srcfile =~ m|(.*)/|;
  97. $distsubdir = "/$1";
  98. print "making dir $distdir$distsubdir\n";
  99. &rec_mkdir("$distdir$distsubdir");
  100. }
  101. print "copy: from $srcfile\n";
  102. print " to $distdir$distsubdir\n";
  103. $srcprefix = "";
  104. if ($jaropts =~/m/) {
  105. $srcprefix = "$var{'PLATFORM'}/";
  106. }
  107. system("cp $srcprefix$srcfile $distdir$distsubdir");
  108. }
  109. }
  110. else {
  111. $srcfile = "$var{SOURCE_RELEASE_PREFIX}/$jardir/$jarfile";
  112. print "copy: from $srcfile\n";
  113. print " to $distdir\n";
  114. system("cp $srcfile $distdir");
  115. }
  116. }