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/.
7 print STDERR
"import.pl\n";
9 require('coreconf.pl');
15 #######-- read in variables on command line into %var
17 $var{UNZIP
} = "unzip -o";
21 if (! ($var{IMPORTS
} =~ /\w/)) {
22 print STDERR
"nothing to import\n";
25 ######-- Do the import!
27 foreach $import (split(/ /,$var{IMPORTS
}) ) {
29 print STDERR
"\n\nIMPORTING .... $import\n-----------------------------\n";
32 # if a specific version specified in IMPORT variable
33 # (if $import has a slash in it)
35 if ($import =~ /\//) {
36 # $component=everything before the first slash of $import
38 $import =~ m
|^([^/]*)/|;
41 $import =~ m
|^(.*)/([^/]*)$|;
43 # $path=everything before the last slash of $import
46 # $version=everything after the last slash of $import
49 if ($var{VERSION
} ne "current") {
50 $version = $var{VERSION
};
56 $version = $var{VERSION
};
59 $releasejardir = "$var{RELEASE_TREE}/$path";
60 if ($version eq "current") {
61 print STDERR
"Current version specified. Reading 'current' file ... \n";
63 open(CURRENT
,"$releasejardir/current") || die "NO CURRENT FILE\n";
65 $version =~ s/(\r?\n)*$//; # remove any trailing [CR/]LF's
67 print STDERR
"Using version $version\n";
68 if ( $version eq "") {
69 die "Current version file empty. Stopping\n";
73 $releasejardir = "$releasejardir/$version";
74 if ( ! -d
$releasejardir) {
75 die "$releasejardir doesn't exist (Invalid Version?)\n";
77 foreach $jarfile (split(/ /,$var{FILES
})) {
79 ($relpath,$distpath,$options) = split(/\|/, $var{$jarfile});
81 if ($var{'OVERRIDE_IMPORT_CHECK'} eq 'YES') {
85 if ( $relpath ne "") { $releasejarpathname = "$releasejardir/$relpath";}
86 else { $releasejarpathname = $releasejardir; }
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";
99 if (-e
"$releasejarpathname/$jarfile") {
100 print STDERR
"\nWorking on jarfile: $jarfile\n";
102 if ($distpath =~ m
|/$|) {
103 $distpathname = "$distpath$component";
106 $distpathname = "$distpath";
110 #the block below is used to determine whether or not the xp headers have
111 #already been imported for this component
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
>;
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";
129 if ($doimport == 1) {
130 if (! -d
"$distpathname") {
131 &rec_mkdir
("$distpathname");
133 # delete the stuff in there already.
134 # (this should really be recursive delete.)
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
);
142 foreach $file ( @filelist ) {
143 if (! ($file =~ m!/.?.$!) ) {
145 $file =~ m!([^/]*)$!;
146 print STDERR
"$remheader $1";
148 unlink "$distpathname/$file";
157 print STDERR
"\nExtracting jarfile '$jarfile' to local directory $distpathname/\n";
159 print STDERR
"$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname\n";
160 system("$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname");
164 if ($options =~ /v/) {
166 unlink ("$distpathname/version");
167 if (open(VFILE
,">$distpathname/version")) {
168 print VFILE
"$version\n";
173 print STDERR
"Could not create '$distpathname/version'. Permissions?\n";
178 } # if (-e releasejarpathname/jarfile)