security/nss/coreconf/import.pl

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:a231f1714efb
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
7 print STDERR "import.pl\n";
8
9 require('coreconf.pl');
10
11
12 $returncode =0;
13
14
15 #######-- read in variables on command line into %var
16
17 $var{UNZIP} = "unzip -o";
18
19 &parse_argv;
20
21 if (! ($var{IMPORTS} =~ /\w/)) {
22 print STDERR "nothing to import\n";
23 }
24
25 ######-- Do the import!
26
27 foreach $import (split(/ /,$var{IMPORTS}) ) {
28
29 print STDERR "\n\nIMPORTING .... $import\n-----------------------------\n";
30
31
32 # if a specific version specified in IMPORT variable
33 # (if $import has a slash in it)
34
35 if ($import =~ /\//) {
36 # $component=everything before the first slash of $import
37
38 $import =~ m|^([^/]*)/|;
39 $component = $1;
40
41 $import =~ m|^(.*)/([^/]*)$|;
42
43 # $path=everything before the last slash of $import
44 $path = $1;
45
46 # $version=everything after the last slash of $import
47 $version = $2;
48
49 if ($var{VERSION} ne "current") {
50 $version = $var{VERSION};
51 }
52 }
53 else {
54 $component = $import;
55 $path = $import;
56 $version = $var{VERSION};
57 }
58
59 $releasejardir = "$var{RELEASE_TREE}/$path";
60 if ($version eq "current") {
61 print STDERR "Current version specified. Reading 'current' file ... \n";
62
63 open(CURRENT,"$releasejardir/current") || die "NO CURRENT FILE\n";
64 $version = <CURRENT>;
65 $version =~ s/(\r?\n)*$//; # remove any trailing [CR/]LF's
66 close(CURRENT);
67 print STDERR "Using version $version\n";
68 if ( $version eq "") {
69 die "Current version file empty. Stopping\n";
70 }
71 }
72
73 $releasejardir = "$releasejardir/$version";
74 if ( ! -d $releasejardir) {
75 die "$releasejardir doesn't exist (Invalid Version?)\n";
76 }
77 foreach $jarfile (split(/ /,$var{FILES})) {
78
79 ($relpath,$distpath,$options) = split(/\|/, $var{$jarfile});
80
81 if ($var{'OVERRIDE_IMPORT_CHECK'} eq 'YES') {
82 $options =~ s/v//g;
83 }
84
85 if ( $relpath ne "") { $releasejarpathname = "$releasejardir/$relpath";}
86 else { $releasejarpathname = $releasejardir; }
87
88 # If a component doesn't have IDG versions, import the DBG ones
89 if( ! -e "$releasejarpathname/$jarfile" ) {
90 if( $relpath =~ /IDG\.OBJ$/ ) {
91 $relpath =~ s/IDG.OBJ/DBG.OBJ/;
92 $releasejarpathname = "$releasejardir/$relpath";
93 } elsif( $relpath =~ /IDG\.OBJD$/ ) {
94 $relpath =~ s/IDG.OBJD/DBG.OBJD/;
95 $releasejarpathname = "$releasejardir/$relpath";
96 }
97 }
98
99 if (-e "$releasejarpathname/$jarfile") {
100 print STDERR "\nWorking on jarfile: $jarfile\n";
101
102 if ($distpath =~ m|/$|) {
103 $distpathname = "$distpath$component";
104 }
105 else {
106 $distpathname = "$distpath";
107 }
108
109
110 #the block below is used to determine whether or not the xp headers have
111 #already been imported for this component
112
113 $doimport = 1;
114 if ($options =~ /v/) { # if we should check the imported version
115 print STDERR "Checking if version file exists $distpathname/version\n";
116 if (-e "$distpathname/version") {
117 open( VFILE, "<$distpathname/version") ||
118 die "Cannot open $distpathname/version for reading. Permissions?\n";
119 $importversion = <VFILE>;
120 close (VFILE);
121 $importversion =~ s/\r?\n$//; # Strip off any trailing CR/LF
122 if ($version eq $importversion) {
123 print STDERR "$distpathname version '$importversion' already imported. Skipping...\n";
124 $doimport =0;
125 }
126 }
127 }
128
129 if ($doimport == 1) {
130 if (! -d "$distpathname") {
131 &rec_mkdir("$distpathname");
132 }
133 # delete the stuff in there already.
134 # (this should really be recursive delete.)
135
136 if ($options =~ /v/) {
137 $remheader = "\nREMOVING files in '$distpathname/' :";
138 opendir(DIR,"$distpathname") ||
139 die ("Cannot read directory $distpathname\n");
140 @filelist = readdir(DIR);
141 closedir(DIR);
142 foreach $file ( @filelist ) {
143 if (! ($file =~ m!/.?.$!) ) {
144 if (! (-d $file)) {
145 $file =~ m!([^/]*)$!;
146 print STDERR "$remheader $1";
147 $remheader = " ";
148 unlink "$distpathname/$file";
149 }
150 }
151 }
152 }
153
154
155 print STDERR "\n\n";
156
157 print STDERR "\nExtracting jarfile '$jarfile' to local directory $distpathname/\n";
158
159 print STDERR "$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname\n";
160 system("$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname");
161
162 $r = $?;
163
164 if ($options =~ /v/) {
165 if ($r == 0) {
166 unlink ("$distpathname/version");
167 if (open(VFILE,">$distpathname/version")) {
168 print VFILE "$version\n";
169 close(VFILE);
170 }
171 }
172 else {
173 print STDERR "Could not create '$distpathname/version'. Permissions?\n";
174 $returncode ++;
175 }
176 }
177 } # if (doimport)
178 } # if (-e releasejarpathname/jarfile)
179 } # foreach jarfile)
180 } # foreach IMPORT
181
182
183
184 exit($returncode);
185
186
187
188
189

mercurial