security/nss/coreconf/import.pl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/coreconf/import.pl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,189 @@
     1.4 +#! /usr/local/bin/perl
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +print STDERR "import.pl\n";
    1.11 +
    1.12 +require('coreconf.pl');
    1.13 +
    1.14 +
    1.15 +$returncode =0;
    1.16 +
    1.17 +
    1.18 +#######-- read in variables on command line into %var
    1.19 +
    1.20 +$var{UNZIP} = "unzip -o";
    1.21 +
    1.22 +&parse_argv;
    1.23 +
    1.24 +if (! ($var{IMPORTS} =~ /\w/)) {
    1.25 +    print STDERR "nothing to import\n";
    1.26 +}
    1.27 +
    1.28 +######-- Do the import!
    1.29 +
    1.30 +foreach $import (split(/ /,$var{IMPORTS}) ) {
    1.31 +
    1.32 +    print STDERR "\n\nIMPORTING .... $import\n-----------------------------\n";
    1.33 +
    1.34 +
    1.35 +# if a specific version specified in IMPORT variable
    1.36 +# (if $import has a slash in it)
    1.37 +
    1.38 +    if ($import =~ /\//) {
    1.39 +        # $component=everything before the first slash of $import
    1.40 +
    1.41 +	$import =~ m|^([^/]*)/|; 
    1.42 +	$component = $1;
    1.43 +
    1.44 +	$import =~ m|^(.*)/([^/]*)$|;
    1.45 +
    1.46 +	# $path=everything before the last slash of $import
    1.47 +	$path = $1;
    1.48 +
    1.49 +	# $version=everything after the last slash of $import
    1.50 +	$version = $2;
    1.51 +
    1.52 +	if ($var{VERSION} ne "current") {
    1.53 +	    $version = $var{VERSION};
    1.54 +	}
    1.55 +    }
    1.56 +    else {
    1.57 +	$component = $import;
    1.58 +	$path = $import;
    1.59 +	$version = $var{VERSION};
    1.60 +    }
    1.61 +
    1.62 +    $releasejardir = "$var{RELEASE_TREE}/$path";
    1.63 +    if ($version eq "current") {
    1.64 +	print STDERR "Current version specified. Reading 'current' file ... \n";
    1.65 +	
    1.66 +	open(CURRENT,"$releasejardir/current") || die "NO CURRENT FILE\n";
    1.67 +	$version = <CURRENT>;
    1.68 +	$version =~ s/(\r?\n)*$//; # remove any trailing [CR/]LF's
    1.69 +	close(CURRENT);
    1.70 +	print STDERR "Using version $version\n";
    1.71 +	if ( $version eq "") {
    1.72 +	    die "Current version file empty. Stopping\n";
    1.73 +	}
    1.74 +    }
    1.75 +    
    1.76 +    $releasejardir = "$releasejardir/$version";
    1.77 +    if ( ! -d $releasejardir) {
    1.78 +	die "$releasejardir doesn't exist (Invalid Version?)\n";
    1.79 +    }
    1.80 +    foreach $jarfile (split(/ /,$var{FILES})) {
    1.81 +
    1.82 +	($relpath,$distpath,$options) = split(/\|/, $var{$jarfile});
    1.83 +
    1.84 +	if ($var{'OVERRIDE_IMPORT_CHECK'} eq 'YES') {
    1.85 +	    $options =~ s/v//g;
    1.86 +	}
    1.87 +
    1.88 +	if ( $relpath ne "") { $releasejarpathname = "$releasejardir/$relpath";}
    1.89 +	else { $releasejarpathname = $releasejardir; }
    1.90 +
    1.91 +# If a component doesn't have IDG versions, import the DBG ones
    1.92 +    if( ! -e "$releasejarpathname/$jarfile" ) {
    1.93 +        if( $relpath =~ /IDG\.OBJ$/ ) {
    1.94 +            $relpath =~ s/IDG.OBJ/DBG.OBJ/;
    1.95 +            $releasejarpathname = "$releasejardir/$relpath";
    1.96 +        } elsif( $relpath =~ /IDG\.OBJD$/ ) {
    1.97 +            $relpath =~ s/IDG.OBJD/DBG.OBJD/;
    1.98 +            $releasejarpathname = "$releasejardir/$relpath";
    1.99 +        }
   1.100 +    }
   1.101 +
   1.102 +	if (-e "$releasejarpathname/$jarfile") {
   1.103 +	    print STDERR "\nWorking on jarfile: $jarfile\n";
   1.104 +	    
   1.105 +	    if ($distpath =~ m|/$|) {
   1.106 +		$distpathname = "$distpath$component";
   1.107 +	    }
   1.108 +	    else {
   1.109 +		$distpathname = "$distpath"; 
   1.110 +	    }
   1.111 +	  
   1.112 +	  
   1.113 +#the block below is used to determine whether or not the xp headers have
   1.114 +#already been imported for this component
   1.115 +
   1.116 +	    $doimport = 1;
   1.117 +	  if ($options =~ /v/) {   # if we should check the imported version
   1.118 +	      print STDERR "Checking if version file exists $distpathname/version\n";
   1.119 +	      if (-e "$distpathname/version") {
   1.120 +		  open( VFILE, "<$distpathname/version") ||
   1.121 +		      die "Cannot open $distpathname/version for reading. Permissions?\n";
   1.122 +		  $importversion = <VFILE>;
   1.123 +		  close (VFILE);
   1.124 +		  $importversion =~ s/\r?\n$//;   # Strip off any trailing CR/LF
   1.125 +		  if ($version eq $importversion) {
   1.126 +		      print STDERR "$distpathname version '$importversion' already imported. Skipping...\n";
   1.127 +		      $doimport =0;
   1.128 +		  }
   1.129 +	      }
   1.130 +	  }
   1.131 +	  
   1.132 +	  if ($doimport == 1) {
   1.133 +	      if (! -d "$distpathname") {
   1.134 +		  &rec_mkdir("$distpathname");
   1.135 +	      }
   1.136 +	      # delete the stuff in there already.
   1.137 +	      # (this should really be recursive delete.)
   1.138 +	      
   1.139 +	      if ($options =~ /v/) {
   1.140 +		  $remheader = "\nREMOVING files in '$distpathname/' :";
   1.141 +		  opendir(DIR,"$distpathname") ||
   1.142 +		      die ("Cannot read directory $distpathname\n");
   1.143 +		  @filelist = readdir(DIR);
   1.144 +		  closedir(DIR);
   1.145 +		  foreach $file ( @filelist ) {
   1.146 +		      if (! ($file =~ m!/.?.$!) ) {
   1.147 +			  if (! (-d $file)) {
   1.148 +			      $file =~ m!([^/]*)$!;
   1.149 +			      print STDERR "$remheader $1";
   1.150 +			      $remheader = " ";
   1.151 +			      unlink "$distpathname/$file";
   1.152 +			  }
   1.153 +		      }
   1.154 +		  }
   1.155 +	      }
   1.156 +
   1.157 +
   1.158 +	      print STDERR "\n\n";
   1.159 +
   1.160 +	      print STDERR "\nExtracting jarfile '$jarfile' to local directory $distpathname/\n";
   1.161 +	      
   1.162 +	      print STDERR "$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname\n";
   1.163 +	      system("$var{UNZIP} $releasejarpathname/$jarfile -d $distpathname");
   1.164 +	      
   1.165 +	      $r = $?;
   1.166 +
   1.167 +	      if ($options =~ /v/) {
   1.168 +		  if ($r == 0) {
   1.169 +		      unlink ("$distpathname/version");
   1.170 +		      if (open(VFILE,">$distpathname/version")) {
   1.171 +			  print VFILE "$version\n";
   1.172 +			  close(VFILE);
   1.173 +		      }
   1.174 +		  }
   1.175 +		  else {
   1.176 +		      print STDERR "Could not create '$distpathname/version'. Permissions?\n";
   1.177 +		      $returncode ++;
   1.178 +		  }
   1.179 +	      }
   1.180 +	  }  # if (doimport)
   1.181 +	} # if (-e releasejarpathname/jarfile)
   1.182 +    } # foreach jarfile)
   1.183 +} # foreach IMPORT
   1.184 +
   1.185 +
   1.186 +
   1.187 +exit($returncode);
   1.188 +
   1.189 +
   1.190 +
   1.191 +
   1.192 +

mercurial