release.pl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. $use_jar = 1;
  9. $ZIP = "$ENV{JAVA_HOME}/bin/jar";
  10. if ( $ENV{JAVA_HOME} eq "" ) {
  11. $ZIP = "zip";
  12. $use_jar = 0;
  13. }
  14. &parse_argv;
  15. ######-- Do the packaging of jars.
  16. foreach $jarfile (split(/ /,$var{FILES}) ) {
  17. print STDERR "---------------------------------------------\n";
  18. print STDERR "Packaging jar file $jarfile....\n";
  19. $jarinfo = $var{$jarfile};
  20. ($jardir,$jaropts) = split(/\|/,$jarinfo);
  21. if ( $use_jar ) {
  22. $zipoptions = "-cvf";
  23. } else {
  24. $zipoptions = "-T -r";
  25. if ($jaropts =~ /a/) {
  26. if ($var{OS_ARCH} eq 'WINNT') {
  27. $zipoptions .= ' -ll';
  28. }
  29. }
  30. }
  31. # just in case the directory ends in a /, remove it
  32. if ($jardir =~ /\/$/) {
  33. chop $jardir;
  34. }
  35. $dirdepth --;
  36. print STDERR "jardir = $jardir\n";
  37. system("ls $jardir");
  38. if (-d $jardir) {
  39. # count the number of slashes
  40. $slashes =0;
  41. foreach $i (split(//,$jardir)) {
  42. if ($i =~ /\//) {
  43. $slashes++;
  44. }
  45. }
  46. $dotdots =0;
  47. foreach $i (split(m|/|,$jardir)) {
  48. if ($i eq '..') {
  49. $dotdots ++;
  50. }
  51. }
  52. $dirdepth = ($slashes +1) - (2*$dotdots);
  53. print STDERR "changing dir $jardir\n";
  54. chdir($jardir);
  55. print STDERR "making dir META-INF\n";
  56. mkdir("META-INF",0755);
  57. $filelist = "";
  58. opendir(DIR,".");
  59. while ($_ = readdir(DIR)) {
  60. if (! ( ($_ eq '.') || ($_ eq '..'))) {
  61. if ( $jaropts =~ /i/) {
  62. if (! /^include$/) {
  63. $filelist .= "$_ ";
  64. }
  65. }
  66. else {
  67. $filelist .= "$_ ";
  68. }
  69. }
  70. }
  71. closedir(DIR);
  72. print STDERR "$ZIP $zipoptions $jarfile $filelist\n";
  73. system("$ZIP $zipoptions $jarfile $filelist");
  74. rmdir("META-INF");
  75. for $i (1 .. $dirdepth) {
  76. chdir("..");
  77. print STDERR "chdir ..\n";
  78. }
  79. }
  80. else {
  81. print STDERR "Directory $jardir doesn't exist\n";
  82. }
  83. }