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