security/nss/coreconf/release.pl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rwxr-xr-x

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/.
     8 require('coreconf.pl');
    10 #######-- read in variables on command line into %var
    12 $use_jar = 1;
    13 $ZIP     = "$ENV{JAVA_HOME}/bin/jar";
    15 if ( $ENV{JAVA_HOME} eq "" ) {
    16     $ZIP      = "zip";
    17     $use_jar  = 0;
    18 }
    21 &parse_argv;
    24 ######-- Do the packaging of jars.
    26 foreach $jarfile (split(/ /,$var{FILES}) ) {
    27     print STDERR "---------------------------------------------\n";
    28     print STDERR "Packaging jar file $jarfile....\n";
    30     $jarinfo = $var{$jarfile};
    32     ($jardir,$jaropts) = split(/\|/,$jarinfo);
    34     if ( $use_jar ) {
    35         $zipoptions = "-cvf";
    36     } else {
    37         $zipoptions = "-T -r";
    38         if ($jaropts =~ /a/) {
    39             if ($var{OS_ARCH} eq 'WINNT') {
    40                 $zipoptions .= ' -ll';
    41             }
    42         }
    43     }
    45 # just in case the directory ends in a /, remove it
    46     if ($jardir =~ /\/$/) {
    47 	chop $jardir;
    48     }
    50     $dirdepth --;
    52     print STDERR "jardir = $jardir\n";
    53     system("ls $jardir");
    55     if (-d $jardir) {
    58 # count the number of slashes
    60 	$slashes =0;
    62 	foreach $i (split(//,$jardir)) {
    63 	    if ($i =~ /\//) {
    64 		$slashes++;
    65 	    }
    66 	}
    68 	$dotdots =0;
    70 	foreach $i (split(m|/|,$jardir)) {
    71 	    if ($i eq '..') {
    72 		$dotdots ++;
    73 	    }
    74 	}
    76 	$dirdepth = ($slashes +1) - (2*$dotdots);
    78 	print STDERR "changing dir $jardir\n";
    79 	chdir($jardir);
    80 	print STDERR "making dir META-INF\n";
    81 	mkdir("META-INF",0755);
    83 	$filelist = "";
    84 	opendir(DIR,".");
    85 	while ($_ = readdir(DIR)) {
    86 	    if (! ( ($_ eq '.') || ($_ eq '..'))) {
    87 		if ( $jaropts =~ /i/) {
    88 		    if (! /^include$/) {
    89 			$filelist .= "$_ ";
    90 		    }
    91 		}
    92 		else {
    93 		    $filelist .= "$_ ";
    94 		}
    95 	    }
    96 	}
    97 	closedir(DIR);	
    99 	print STDERR "$ZIP $zipoptions $jarfile $filelist\n";
   100 	system("$ZIP $zipoptions $jarfile $filelist");
   101 	rmdir("META-INF");
   102 	    for $i (1 .. $dirdepth) {
   103 	    chdir("..");
   104 	    print STDERR "chdir ..\n";
   105 	}
   106     }
   107     else {
   108         print STDERR "Directory $jardir doesn't exist\n";
   109     }
   111 }

mercurial