Backed out 3 changesets (bug 1898476) for causing build bustages @ MozContainerSurfac...
[gecko.git] / security / nss / coreconf / coreconf.pl
blob7cf3e57d04beca36eb522ea6b10b65a135c9f3b0
2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 sub recursive_copy {
6 local($fromdir);
7 local($todir);
8 local(@dirlist);
9 $fromdir = shift;
10 $todir = shift;
12 print STDERR "recursive copy called with $fromdir, $todir\n";
14 #remove any trailing slashes.
15 $fromdir =~ s/\/$//;
16 $todir =~ s/\/$//;
18 opendir(DIR, $fromdir);
19 @dirlist = readdir DIR;
20 close DIR;
23 foreach $file (@dirlist) {
24 if (! (($file eq "." ) || ($file eq "..") )) {
26 if (-d "$fromdir/$file") {
27 print STDERR "handling directory $todir/$file\n";
28 &rec_mkdir("$todir/$file");
29 &recursive_copy("$fromdir/$file","$todir/$file");
31 else {
32 print STDERR "handling file $fromdir/$file\n";
33 &my_copy("$fromdir/$file","$todir/$file");
39 sub parse_argv {
41 # print STDERR "Parsing Variables\n";
43 foreach $q ( @ARGV ) {
44 if (! ($q =~ /=/)) {
45 $var{$lastassigned} .= " $q";
47 else {
48 $q =~ /^([^=]*)=(.*)/;
49 $left = $1;
50 $right = $2;
52 $right =~ s/ *$//;
53 $var{$left} = $right;
55 $lastassigned = $left;
58 print STDERR "Assigned $lastassigned = $var{$lastassigned}\n";
63 # usage: &my_copy("dir/fromfile","dir2/tofile");
64 # do a 'copy' - files only, 'to' MUST be a filename, not a directory.
66 # fix this to be able to use copy on win nt.
68 sub my_copy {
69 local($from);
70 local($to);
71 local($cpcmd);
73 $from = shift;
74 $to = shift;
76 if ( ! defined $var{OS_ARCH}) {
77 die "OS_ARCH not defined!";
79 else {
80 if ($var{OS_ARCH} eq 'WINNT') {
81 $cpcmd = 'cp';
83 else {
84 $cpcmd = 'cp';
86 print STDERR "COPYING: $cpcmd $from $to\n";
87 system("$cpcmd $from $to");
92 sub old_my_copy {
93 local($from);
94 local($to);
96 $from = shift;
97 $to = shift;
98 open(FIN, "<$from") || die("Can't read from file $from\n");
99 if ( ! open(FOUT,">$to")) {
100 close FIN;
101 die "Can't write to file $to\n";
103 while (read(FIN, $buf, 100000)) {
104 print FOUT $buf;
106 close (FIN);
107 close (FOUT);
110 sub rec_mkdir {
111 local($arg);
112 local($t);
113 local($q);
115 $arg = shift;
116 $t = "";
117 foreach $q (split(/\//,$arg)) {
118 $t .= $q;
119 if (! ($t =~ /\.\.$/)) {
120 if ($t =~ /./) {
121 mkdir($t,0775);
124 $t.= '/';