security/nss/coreconf/coreconf.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/coreconf/coreconf.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,128 @@
     1.4 +#
     1.5 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.8 +sub recursive_copy {
     1.9 +    local($fromdir);
    1.10 +    local($todir);
    1.11 +    local(@dirlist);
    1.12 +    $fromdir = shift;
    1.13 +    $todir = shift;
    1.14 +  
    1.15 +    print STDERR "recursive copy called with $fromdir, $todir\n";
    1.16 +
    1.17 +#remove any trailing slashes.
    1.18 +    $fromdir =~ s/\/$//;
    1.19 +    $todir =~ s/\/$//;
    1.20 +    
    1.21 +    opendir(DIR, $fromdir);
    1.22 +    @dirlist = readdir DIR;
    1.23 +    close DIR;
    1.24 +
    1.25 +
    1.26 +    foreach $file (@dirlist) {
    1.27 +	if  (! (($file eq "." ) || ($file eq "..") )) {
    1.28 +	    
    1.29 +	    if (-d "$fromdir/$file") {
    1.30 +		print STDERR "handling directory $todir/$file\n";
    1.31 +		&rec_mkdir("$todir/$file");
    1.32 +		&recursive_copy("$fromdir/$file","$todir/$file");
    1.33 +	    }
    1.34 +	    else {
    1.35 +		print STDERR "handling file $fromdir/$file\n";
    1.36 +		&my_copy("$fromdir/$file","$todir/$file");
    1.37 +	    }
    1.38 +	}
    1.39 +    }
    1.40 +}
    1.41 +
    1.42 +sub parse_argv {
    1.43 +
    1.44 +#    print STDERR "Parsing Variables\n";
    1.45 +
    1.46 +    foreach $q ( @ARGV ) {
    1.47 +	if (! ($q =~ /=/)) {
    1.48 +	    $var{$lastassigned} .= " $q";
    1.49 +	}
    1.50 +	else {
    1.51 +	   $q =~ /^([^=]*)=(.*)/;
    1.52 +	   $left = $1;
    1.53 +	   $right = $2;
    1.54 +	
    1.55 +	   $right =~ s/ *$//;
    1.56 +	   $var{$left} = $right;
    1.57 +
    1.58 +	   $lastassigned = $left;
    1.59 +	
    1.60 +	   }
    1.61 +	print STDERR "Assigned $lastassigned = $var{$lastassigned}\n";
    1.62 +    }
    1.63 +}
    1.64 +
    1.65 +
    1.66 +# usage: &my_copy("dir/fromfile","dir2/tofile");
    1.67 +# do a 'copy' - files only, 'to' MUST be a filename, not a directory.
    1.68 +
    1.69 +# fix this to be able to use copy on win nt.
    1.70 +
    1.71 +sub my_copy {
    1.72 +    local($from);
    1.73 +    local($to);
    1.74 +    local($cpcmd);
    1.75 +
    1.76 +    $from = shift;
    1.77 +    $to = shift;
    1.78 +
    1.79 +    if ( ! defined $var{OS_ARCH}) {
    1.80 +	die "OS_ARCH not defined!";
    1.81 +    }
    1.82 +    else {
    1.83 +	if ($var{OS_ARCH} eq 'WINNT') {
    1.84 +	    $cpcmd = 'cp';
    1.85 +	    	}
    1.86 +	else {
    1.87 +	    $cpcmd = 'cp';
    1.88 +	    }
    1.89 +	print STDERR "COPYING: $cpcmd $from $to\n";
    1.90 +	system("$cpcmd $from $to");
    1.91 +    }
    1.92 +}
    1.93 +
    1.94 +
    1.95 +sub old_my_copy {
    1.96 +    local($from);
    1.97 +    local($to);
    1.98 +
    1.99 +    $from = shift;
   1.100 +    $to = shift;
   1.101 +    open(FIN, "<$from") || die("Can't read from file $from\n");
   1.102 +    if ( ! open(FOUT,">$to")) {
   1.103 +	close FIN;
   1.104 +	die "Can't write to file $to\n";
   1.105 +    }
   1.106 +    while (read(FIN, $buf, 100000)) {
   1.107 +	print FOUT $buf;
   1.108 +    }
   1.109 +    close (FIN);
   1.110 +    close (FOUT);
   1.111 +}
   1.112 +
   1.113 +sub rec_mkdir {
   1.114 +    local($arg);
   1.115 +    local($t);
   1.116 +    local($q);
   1.117 +
   1.118 +    $arg = shift;
   1.119 +    $t = "";
   1.120 +    foreach $q (split(/\//,$arg)) {
   1.121 +	$t .= $q;
   1.122 +	if (! ($t =~ /\.\.$/)) {
   1.123 +	    if ($t =~ /./) {
   1.124 +		mkdir($t,0775);
   1.125 +	    }
   1.126 +	}
   1.127 +	$t.= '/';
   1.128 +    }
   1.129 +}
   1.130 +
   1.131 +1;

mercurial