1*9780544fSAndrew Rist#************************************************************** 2*9780544fSAndrew Rist# 3*9780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 4*9780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 5*9780544fSAndrew Rist# distributed with this work for additional information 6*9780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 7*9780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 8*9780544fSAndrew Rist# "License"); you may not use this file except in compliance 9*9780544fSAndrew Rist# with the License. You may obtain a copy of the License at 10*9780544fSAndrew Rist# 11*9780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 12*9780544fSAndrew Rist# 13*9780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 14*9780544fSAndrew Rist# software distributed under the License is distributed on an 15*9780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*9780544fSAndrew Rist# KIND, either express or implied. See the License for the 17*9780544fSAndrew Rist# specific language governing permissions and limitations 18*9780544fSAndrew Rist# under the License. 19*9780544fSAndrew Rist# 20*9780544fSAndrew Rist#************************************************************** 21*9780544fSAndrew Rist 22*9780544fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweirpackage installer::archivefiles; 25cdf0e10cSrcweir 26cdf0e10cSrcweiruse Archive::Zip qw( :ERROR_CODES :CONSTANTS ); 27cdf0e10cSrcweiruse installer::converter; 28cdf0e10cSrcweiruse installer::existence; 29cdf0e10cSrcweiruse installer::exiter; 30cdf0e10cSrcweiruse installer::files; 31cdf0e10cSrcweiruse installer::globals; 32cdf0e10cSrcweiruse installer::logger; 33cdf0e10cSrcweiruse installer::pathanalyzer; 34cdf0e10cSrcweiruse installer::systemactions; 35cdf0e10cSrcweir 36cdf0e10cSrcweir################################################################# 37cdf0e10cSrcweir# Changing the name for files with flag RENAME_TO_LANGUAGE 38cdf0e10cSrcweir################################################################# 39cdf0e10cSrcweir 40cdf0e10cSrcweirsub put_language_into_name 41cdf0e10cSrcweir{ 42cdf0e10cSrcweir my ( $oldname, $onelanguage ) = @_; 43cdf0e10cSrcweir 44cdf0e10cSrcweir my $newname = ""; 45cdf0e10cSrcweir 46cdf0e10cSrcweir my $filename = ""; 47cdf0e10cSrcweir my $extension = ""; 48cdf0e10cSrcweir 49cdf0e10cSrcweir if ( $oldname =~ /en-US/ ) # files, that contain the language in the file name 50cdf0e10cSrcweir { 51cdf0e10cSrcweir $newname = $oldname; 52cdf0e10cSrcweir $newname =~ s/en-US/$onelanguage/; 53cdf0e10cSrcweir } 54cdf0e10cSrcweir else # files, that do not contain the language in the file name 55cdf0e10cSrcweir { 56cdf0e10cSrcweir if ( $oldname =~ /^\s*(.*)(\..*?)\s*$/ ) # files with extension 57cdf0e10cSrcweir { 58cdf0e10cSrcweir $filename = $1; 59cdf0e10cSrcweir $extension = $2; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir else 62cdf0e10cSrcweir { 63cdf0e10cSrcweir $filename = $oldname; 64cdf0e10cSrcweir $extension = ""; 65cdf0e10cSrcweir } 66cdf0e10cSrcweir 67cdf0e10cSrcweir $newname = $1 . "_" . $onelanguage . $2; 68cdf0e10cSrcweir } 69cdf0e10cSrcweir 70cdf0e10cSrcweir return $newname; 71cdf0e10cSrcweir} 72cdf0e10cSrcweir 73cdf0e10cSrcweir################################################################# 74cdf0e10cSrcweir# Converting patchfiles string into array 75cdf0e10cSrcweir################################################################# 76cdf0e10cSrcweir 77cdf0e10cSrcweirsub get_patch_file_list 78cdf0e10cSrcweir{ 79cdf0e10cSrcweir my ( $patchfilestring ) = @_; 80cdf0e10cSrcweir 81cdf0e10cSrcweir $patchfilestring =~ s/^\s*\(?//; 82cdf0e10cSrcweir $patchfilestring =~ s/\)?\s*$//; 83cdf0e10cSrcweir $patchfilestring =~ s/^\s*\///; 84cdf0e10cSrcweir $patchfilestring =~ s/^\s*\\//; 85cdf0e10cSrcweir 86cdf0e10cSrcweir my $patchfilesarray = installer::converter::convert_stringlist_into_array_without_linebreak_and_quotes(\$patchfilestring, ","); 87cdf0e10cSrcweir 88cdf0e10cSrcweir return $patchfilesarray; 89cdf0e10cSrcweir} 90cdf0e10cSrcweir 91cdf0e10cSrcweir################################################################# 92cdf0e10cSrcweir# Reading all executables in the "manifest.xml" 93cdf0e10cSrcweir################################################################# 94cdf0e10cSrcweir 95cdf0e10cSrcweirsub get_all_executables_from_manifest 96cdf0e10cSrcweir{ 97cdf0e10cSrcweir my ($unzipdir, $manifestfile, $executable_files_in_extensions) = @_; 98cdf0e10cSrcweir 99cdf0e10cSrcweir my $is_executable = 0; 100cdf0e10cSrcweir 101cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$manifestfile}; $i++ ) 102cdf0e10cSrcweir { 103cdf0e10cSrcweir my $line = ${$manifestfile}[$i]; 104cdf0e10cSrcweir 105cdf0e10cSrcweir if ( $line =~ /\"application\/vnd\.sun\.star\.executable\"/ ) { $is_executable = 1; } 106cdf0e10cSrcweir 107cdf0e10cSrcweir if (( $line =~ /manifest\:full\-path=\"(.*?)\"/ ) && ( $is_executable )) 108cdf0e10cSrcweir { 109cdf0e10cSrcweir my $filename = $unzipdir . $installer::globals::separator . $1; 110cdf0e10cSrcweir # making only slashes for comparison reasons 111cdf0e10cSrcweir $filename =~ s/\\/\//g; 112cdf0e10cSrcweir $executable_files_in_extensions->{$filename} = 1; 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir if ( $line =~ /\/\>/ ) { $is_executable = 0; } 116cdf0e10cSrcweir } 117cdf0e10cSrcweir} 118cdf0e10cSrcweir 119cdf0e10cSrcweir################################################################# 120cdf0e10cSrcweir# Reading the "manifest.xml" in extensions and determine, if 121cdf0e10cSrcweir# there are executable files 122cdf0e10cSrcweir################################################################# 123cdf0e10cSrcweir 124cdf0e10cSrcweirsub collect_all_executable_files_in_extensions 125cdf0e10cSrcweir{ 126cdf0e10cSrcweir my ($unzipdir, $executable_files_in_extensions) = @_; 127cdf0e10cSrcweir 128cdf0e10cSrcweir $unzipdir =~ s/\Q$installer::globals::separator\E\s*$//; 129cdf0e10cSrcweir 130cdf0e10cSrcweir my $manifestfilename = $unzipdir . $installer::globals::separator . "META-INF" . $installer::globals::separator . "manifest.xml"; 131cdf0e10cSrcweir 132cdf0e10cSrcweir if ( -f $manifestfilename ) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir my $manifestfile = installer::files::read_file($manifestfilename); 135cdf0e10cSrcweir get_all_executables_from_manifest($unzipdir, $manifestfile, $executable_files_in_extensions); 136cdf0e10cSrcweir } 137cdf0e10cSrcweir} 138cdf0e10cSrcweir 139cdf0e10cSrcweir################################################################# 140cdf0e10cSrcweir# Analyzing files with flag ARCHIVE 141cdf0e10cSrcweir################################################################# 142cdf0e10cSrcweir 143cdf0e10cSrcweirsub resolving_archive_flag 144cdf0e10cSrcweir{ 145cdf0e10cSrcweir my ($filesarrayref, $additionalpathsref, $languagestringref, $loggingdir) = @_; 146cdf0e10cSrcweir 147cdf0e10cSrcweir if ( $installer::globals::debug ) { installer::logger::debuginfo("installer::archivefiles::resolving_archive_flag : $#{$filesarrayref} : $#{$additionalpathsref} : $$languagestringref : $loggingdir"); } 148cdf0e10cSrcweir 149cdf0e10cSrcweir my @newallfilesarray = (); 150cdf0e10cSrcweir 151cdf0e10cSrcweir my ($systemcall, $returnvalue, $infoline); 152cdf0e10cSrcweir 153cdf0e10cSrcweir my $unziplistfile = $loggingdir . "unziplist_" . $installer::globals::build . "_" . $installer::globals::compiler . "_" . $$languagestringref . ".txt"; 154cdf0e10cSrcweir 155cdf0e10cSrcweir my $platformunzipdirbase = installer::systemactions::create_directories("zip", $languagestringref); 156cdf0e10cSrcweir push(@installer::globals::removedirs, $platformunzipdirbase); 157cdf0e10cSrcweir 158cdf0e10cSrcweir installer::logger::include_header_into_logfile("Files with flag ARCHIVE:"); 159cdf0e10cSrcweir 160cdf0e10cSrcweir my $repeat_unzip = 0; 161cdf0e10cSrcweir my $maxcounter = 0; 162cdf0e10cSrcweir 163cdf0e10cSrcweir for ( my $i = 0; $i <= $#{$filesarrayref}; $i++ ) 164cdf0e10cSrcweir { 165cdf0e10cSrcweir if ( $repeat_unzip ) { $i--; } # decreasing the counter 166cdf0e10cSrcweir 167cdf0e10cSrcweir my $onefile = ${$filesarrayref}[$i]; 168cdf0e10cSrcweir my $styles = ""; 169cdf0e10cSrcweir 170cdf0e10cSrcweir if ( $onefile->{'Styles'} ) { $styles = $onefile->{'Styles'}; } 171cdf0e10cSrcweir 172cdf0e10cSrcweir if ( $styles =~ /\bARCHIVE\b/ ) # copying, unzipping and changing the file list 173cdf0e10cSrcweir { 174cdf0e10cSrcweir my $iscommonfile = 0; 175cdf0e10cSrcweir my $sourcepath = $onefile->{'sourcepath'}; 176cdf0e10cSrcweir 177cdf0e10cSrcweir if ( $sourcepath =~ /\Q$installer::globals::separator\E\bcommon$installer::globals::productextension\Q$installer::globals::separator\E/ ) # /common/ or /common.pro/ 178cdf0e10cSrcweir { 179cdf0e10cSrcweir $iscommonfile = 1; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir 182cdf0e10cSrcweir my $use_internal_rights = 0; 183cdf0e10cSrcweir if ( $styles =~ /\bUSE_INTERNAL_RIGHTS\b/ ) { $use_internal_rights = 1; } # using the rights used inside the zip file 184cdf0e10cSrcweir 185cdf0e10cSrcweir my $rename_to_language = 0; 186cdf0e10cSrcweir if ( $styles =~ /\bRENAME_TO_LANGUAGE\b/ ) { $rename_to_language = 1; } # special handling for renamed files (scriptitems.pm) 187cdf0e10cSrcweir 188cdf0e10cSrcweir my %executable_files_in_extensions = (); 189cdf0e10cSrcweir my $set_executable_privileges = 0; # setting privileges for exectables is required for oxt files 190cdf0e10cSrcweir if ( $onefile->{'Name'} =~ /\.oxt\s*$/ ) { $set_executable_privileges = 1; } 191cdf0e10cSrcweir 192cdf0e10cSrcweir # mechanism to select files from an archive files 193cdf0e10cSrcweir my $select_files = 0; 194cdf0e10cSrcweir my $selectlistfiles = ""; 195cdf0e10cSrcweir my @keptfiles = (); 196cdf0e10cSrcweir if ( $onefile->{'Selectfiles'} ) 197cdf0e10cSrcweir { 198cdf0e10cSrcweir $select_files = 1; 199cdf0e10cSrcweir $selectlistfiles = get_patch_file_list( $onefile->{'Selectfiles'} ); 200cdf0e10cSrcweir $infoline = "Selected file list defined at file: $onefile->{'Name'} :\n"; 201cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 202cdf0e10cSrcweir for ( my $k = 0; $k <= $#{$selectlistfiles}; $k++ ) 203cdf0e10cSrcweir { 204cdf0e10cSrcweir $infoline = "\"${$selectlistfiles}[$k]\"\n"; 205cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 206cdf0e10cSrcweir } 207cdf0e10cSrcweir } 208cdf0e10cSrcweir 209cdf0e10cSrcweir if ( $onefile->{'Selectfiles'} ) { $onefile->{'Selectfiles'} = ""; } # Selected files list no longer required 210cdf0e10cSrcweir 211cdf0e10cSrcweir # mechanism to define patch files inside an archive files 212cdf0e10cSrcweir my $select_patch_files = 0; 213cdf0e10cSrcweir my $patchlistfiles = ""; 214cdf0e10cSrcweir my @keptpatchflags = (); 215cdf0e10cSrcweir if (( $styles =~ /\bPATCH\b/ ) && ( $onefile->{'Patchfiles'} ) && ( $installer::globals::patch )) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir $select_patch_files = 1; # special handling if a Patchlist is defined 218cdf0e10cSrcweir $patchlistfiles = get_patch_file_list( $onefile->{'Patchfiles'} ); 219cdf0e10cSrcweir $infoline = "Patch file list defined at file: $onefile->{'Name'} :\n"; 220cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 221cdf0e10cSrcweir for ( my $k = 0; $k <= $#{$patchlistfiles}; $k++ ) 222cdf0e10cSrcweir { 223cdf0e10cSrcweir $infoline = "\"${$patchlistfiles}[$k]\"\n"; 224cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir if ( $onefile->{'Patchfiles'} ) { $onefile->{'Patchfiles'} = ""; } # Patch file list no longer required 229cdf0e10cSrcweir 230cdf0e10cSrcweir # creating directories 231cdf0e10cSrcweir 232cdf0e10cSrcweir my $onelanguage = $onefile->{'specificlanguage'}; 233cdf0e10cSrcweir 234cdf0e10cSrcweir # files without language into directory "00" 235cdf0e10cSrcweir 236cdf0e10cSrcweir if ($onelanguage eq "") { $onelanguage = "00"; } 237cdf0e10cSrcweir 238cdf0e10cSrcweir my $unzipdir; 239cdf0e10cSrcweir 240cdf0e10cSrcweir # if ($iscommonfile) { $unzipdir = $commonunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; } 241cdf0e10cSrcweir # else { $unzipdir = $platformunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; } 242cdf0e10cSrcweir 243cdf0e10cSrcweir $unzipdir = $platformunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; 244cdf0e10cSrcweir 245cdf0e10cSrcweir installer::systemactions::create_directory($unzipdir); # creating language specific subdirectories 246cdf0e10cSrcweir 247cdf0e10cSrcweir my $onefilename = $onefile->{'Name'}; 248cdf0e10cSrcweir $onefilename =~ s/\./\_/g; # creating new directory name 249cdf0e10cSrcweir $onefilename =~ s/\//\_/g; # only because of /letter/fontunxpsprint.zip, the only zip file with path 250cdf0e10cSrcweir $unzipdir = $unzipdir . $onefilename . $installer::globals::separator; 251cdf0e10cSrcweir 252cdf0e10cSrcweir if ( $installer::globals::dounzip ) { installer::systemactions::create_directory($unzipdir); } # creating subdirectories with the names of the zipfiles 253cdf0e10cSrcweir 254cdf0e10cSrcweir my $zip = Archive::Zip->new(); 255cdf0e10cSrcweir if ( $zip->read($sourcepath) != AZ_OK ) 256cdf0e10cSrcweir { 257cdf0e10cSrcweir $infoline = "ERROR: Could not unzip $sourcepath\n"; 258cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 259cdf0e10cSrcweir } 260cdf0e10cSrcweir 261cdf0e10cSrcweir my $counter = 0; 262cdf0e10cSrcweir my $contains_dll = 0; 263cdf0e10cSrcweir foreach my $member ( $zip->memberNames() ) 264cdf0e10cSrcweir { 265cdf0e10cSrcweir $counter++; 266cdf0e10cSrcweir if ( $member =~ /.dll\s*$/ ) { $contains_dll = 1; } 267cdf0e10cSrcweir } 268cdf0e10cSrcweir 269cdf0e10cSrcweir if (! ( $counter > 0 )) # the zipfile is empty 270cdf0e10cSrcweir { 271cdf0e10cSrcweir $infoline = "ERROR: Could not unzip $sourcepath\n"; 272cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 273cdf0e10cSrcweir 274cdf0e10cSrcweir } 275cdf0e10cSrcweir else 276cdf0e10cSrcweir { 277cdf0e10cSrcweir if ( $installer::globals::dounzip ) # really unpacking the files 278cdf0e10cSrcweir { 279cdf0e10cSrcweir if ( $zip->extractTree("", $unzipdir) != AZ_OK ) { installer::exiter::exit_program("ERROR: $infoline", "resolving_archive_flag"); } 280cdf0e10cSrcweir 281cdf0e10cSrcweir if (( $^O =~ /cygwin/i ) && ( $contains_dll )) 282cdf0e10cSrcweir { 283cdf0e10cSrcweir # Make dll's executable 284cdf0e10cSrcweir $systemcall = "cd $unzipdir; find . -name \\*.dll -exec chmod 775 \{\} \\\;"; 285cdf0e10cSrcweir $returnvalue = system($systemcall); 286cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 287cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 288cdf0e10cSrcweir 289cdf0e10cSrcweir if ($returnvalue) 290cdf0e10cSrcweir { 291cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 292cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 293cdf0e10cSrcweir } 294cdf0e10cSrcweir } 295cdf0e10cSrcweir 296cdf0e10cSrcweir if ( ! $installer::globals::iswindowsbuild ) 297cdf0e10cSrcweir { 298cdf0e10cSrcweir # Setting unix rights to "775" for all created directories inside the package 299cdf0e10cSrcweir 300cdf0e10cSrcweir $systemcall = "cd $unzipdir; find . -type d -exec chmod 775 \{\} \\\;"; 301cdf0e10cSrcweir $returnvalue = system($systemcall); 302cdf0e10cSrcweir $infoline = "Systemcall: $systemcall\n"; 303cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 304cdf0e10cSrcweir 305cdf0e10cSrcweir if ($returnvalue) 306cdf0e10cSrcweir { 307cdf0e10cSrcweir $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; 308cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 309cdf0e10cSrcweir } 310cdf0e10cSrcweir } 311cdf0e10cSrcweir 312cdf0e10cSrcweir # Selecting names of executable files in extensions 313cdf0e10cSrcweir if ( $set_executable_privileges ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir collect_all_executable_files_in_extensions($unzipdir, \%executable_files_in_extensions); 316cdf0e10cSrcweir } 317cdf0e10cSrcweir } 318cdf0e10cSrcweir 319cdf0e10cSrcweir my $zipfileref = \@zipfile; 320cdf0e10cSrcweir my $unziperror = 0; 321cdf0e10cSrcweir 322cdf0e10cSrcweir foreach my $zipname ( $zip->memberNames() ) 323cdf0e10cSrcweir { 324cdf0e10cSrcweir # Format from Archive:::Zip : 325cdf0e10cSrcweir # dir1/ 326cdf0e10cSrcweir # dir1/so7drawing.desktop 327cdf0e10cSrcweir 328cdf0e10cSrcweir # some directories and files (from the help) start with "./simpress.idx" 329cdf0e10cSrcweir 330cdf0e10cSrcweir $zipname =~ s/^\s*\.\///; 331cdf0e10cSrcweir 332cdf0e10cSrcweir if ($installer::globals::iswin and $^O =~ /MSWin/i) { $zipname =~ s/\//\\/g; } 333cdf0e10cSrcweir 334cdf0e10cSrcweir if ( $zipname =~ /\Q$installer::globals::separator\E\s*$/ ) # slash or backslash at the end characterizes a directory 335cdf0e10cSrcweir { 336cdf0e10cSrcweir $zipname = $zipname . "\n"; 337cdf0e10cSrcweir push(@{$additionalpathsref}, $zipname); 338cdf0e10cSrcweir 339cdf0e10cSrcweir # Also needed here: 340cdf0e10cSrcweir # Name 341cdf0e10cSrcweir # Language 342cdf0e10cSrcweir # ismultilingual 343cdf0e10cSrcweir # Basedirectory 344cdf0e10cSrcweir 345cdf0e10cSrcweir # This is not needed, because the list of all directories for the 346cdf0e10cSrcweir # epm list file is generated from the destination directories of the 347cdf0e10cSrcweir # files included in the product! 348cdf0e10cSrcweir } 349cdf0e10cSrcweir else 350cdf0e10cSrcweir { 351cdf0e10cSrcweir my %newfile = (); 352cdf0e10cSrcweir %newfile = %{$onefile}; 353cdf0e10cSrcweir $newfile{'Name'} = $zipname; 354cdf0e10cSrcweir my $destination = $onefile->{'destination'}; 355cdf0e10cSrcweir installer::pathanalyzer::get_path_from_fullqualifiedname(\$destination); 356cdf0e10cSrcweir $newfile{'destination'} = $destination . $zipname; 357cdf0e10cSrcweir $newfile{'sourcepath'} = $unzipdir . $zipname; 358cdf0e10cSrcweir $newfile{'zipfilename'} = $onefile->{'Name'}; 359cdf0e10cSrcweir $newfile{'zipfilesource'} = $onefile->{'sourcepath'}; 360cdf0e10cSrcweir $newfile{'zipfiledestination'} = $onefile->{'destination'}; 361cdf0e10cSrcweir 362cdf0e10cSrcweir if (( $use_internal_rights ) && ( ! $installer::globals::iswin )) 363cdf0e10cSrcweir { 364cdf0e10cSrcweir my $value = sprintf("%o", (stat($newfile{'sourcepath'}))[2]); 365cdf0e10cSrcweir $newfile{'UnixRights'} = substr($value, 3); 366cdf0e10cSrcweir $infoline = "Setting unix rights for \"$newfile{'sourcepath'}\" to \"$newfile{'UnixRights'}\"\n"; 367cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 368cdf0e10cSrcweir } 369cdf0e10cSrcweir 370cdf0e10cSrcweir if ( $set_executable_privileges ) 371cdf0e10cSrcweir { 372cdf0e10cSrcweir # All pathes to executables are saved in the hash %executable_files_in_extensions 373cdf0e10cSrcweir my $compare_path = $newfile{'sourcepath'}; 374cdf0e10cSrcweir $compare_path =~ s/\\/\//g; # contains only slashes for comparison reasons 375cdf0e10cSrcweir if ( exists($executable_files_in_extensions{$compare_path}) ) 376cdf0e10cSrcweir { 377cdf0e10cSrcweir $newfile{'UnixRights'} = "775"; 378cdf0e10cSrcweir $infoline = "Executable in Extension: Setting unix rights for \"$newfile{'sourcepath'}\" to \"$newfile{'UnixRights'}\"\n"; 379cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 380cdf0e10cSrcweir } 381cdf0e10cSrcweir } 382cdf0e10cSrcweir 383cdf0e10cSrcweir if ( $select_files ) 384cdf0e10cSrcweir { 385cdf0e10cSrcweir if ( ! installer::existence::exists_in_array($zipname,$selectlistfiles) ) 386cdf0e10cSrcweir { 387cdf0e10cSrcweir $infoline = "Removing from ARCHIVE file $onefilename: $zipname\n"; 388cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 389cdf0e10cSrcweir next; # ignoring files, that are not included in $selectlistfiles 390cdf0e10cSrcweir } 391cdf0e10cSrcweir else 392cdf0e10cSrcweir { 393cdf0e10cSrcweir $infoline = "Keeping from ARCHIVE file $onefilename: $zipname\n"; 394cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 395cdf0e10cSrcweir push( @keptfiles, $zipname); # collecting all kept files 396cdf0e10cSrcweir } 397cdf0e10cSrcweir } 398cdf0e10cSrcweir 399cdf0e10cSrcweir if ( $select_patch_files ) 400cdf0e10cSrcweir { 401cdf0e10cSrcweir # Is this file listed in the Patchfile list? 402cdf0e10cSrcweir # $zipname (filename including path in zip file has to be listed in patchfile list 403cdf0e10cSrcweir 404cdf0e10cSrcweir if ( ! installer::existence::exists_in_array($zipname,$patchlistfiles) ) 405cdf0e10cSrcweir { 406cdf0e10cSrcweir $newfile{'Styles'} =~ s/\bPATCH\b//; # removing the flag PATCH 407cdf0e10cSrcweir $newfile{'Styles'} =~ s/\,\s*\,/\,/; 408cdf0e10cSrcweir $newfile{'Styles'} =~ s/\(\s*\,/\(/; 409cdf0e10cSrcweir $newfile{'Styles'} =~ s/\,\s*\)/\)/; 410cdf0e10cSrcweir # $infoline = "Removing PATCH flag from: $zipname\n"; 411cdf0e10cSrcweir # push( @installer::globals::logfileinfo, $infoline); 412cdf0e10cSrcweir } 413cdf0e10cSrcweir else 414cdf0e10cSrcweir { 415cdf0e10cSrcweir # $infoline = "Keeping PATCH flag at: $zipname\n"; 416cdf0e10cSrcweir # push( @installer::globals::logfileinfo, $infoline); 417cdf0e10cSrcweir push( @keptpatchflags, $zipname); # collecting all PATCH flags 418cdf0e10cSrcweir } 419cdf0e10cSrcweir } 420cdf0e10cSrcweir 421cdf0e10cSrcweir if ( $rename_to_language ) 422cdf0e10cSrcweir { 423cdf0e10cSrcweir my $newzipname = put_language_into_name($zipname, $onelanguage); 424cdf0e10cSrcweir my $oldfilename = $unzipdir . $zipname; 425cdf0e10cSrcweir my $newfilename = $unzipdir . $newzipname; 426cdf0e10cSrcweir 427cdf0e10cSrcweir installer::systemactions::copy_one_file($oldfilename, $newfilename); 428cdf0e10cSrcweir 429cdf0e10cSrcweir $newfile{'Name'} = $newzipname; 430cdf0e10cSrcweir $newfile{'destination'} = $destination . $newzipname; 431cdf0e10cSrcweir $newfile{'sourcepath'} = $unzipdir . $newzipname; 432cdf0e10cSrcweir 433cdf0e10cSrcweir $infoline = "RENAME_TO_LANGUAGE: Using $newzipname instead of $zipname!\n"; 434cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 435cdf0e10cSrcweir } 436cdf0e10cSrcweir 437cdf0e10cSrcweir my $sourcefiletest = $unzipdir . $zipname; 438cdf0e10cSrcweir if ( ! -f $sourcefiletest ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir $infoline = "ATTENTION: Unzip failed for $sourcefiletest!\n"; 441cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 442cdf0e10cSrcweir $unziperror = 1; 443cdf0e10cSrcweir } 444cdf0e10cSrcweir 445cdf0e10cSrcweir # only adding the new line into the files array, if not in repeat modus 446cdf0e10cSrcweir 447cdf0e10cSrcweir if ( ! $repeat_unzip ) { push(@newallfilesarray, \%newfile); } 448cdf0e10cSrcweir } 449cdf0e10cSrcweir } 450cdf0e10cSrcweir 451cdf0e10cSrcweir # Comparing the content of @keptfiles and $selectlistfiles 452cdf0e10cSrcweir # Do all files from the list of selected files are stored in @keptfiles ? 453cdf0e10cSrcweir # @keptfiles contains only files included in $selectlistfiles. But are all 454cdf0e10cSrcweir # files from $selectlistfiles included in @keptfiles? 455cdf0e10cSrcweir 456cdf0e10cSrcweir if ( $select_files ) 457cdf0e10cSrcweir { 458cdf0e10cSrcweir my $number = $#{$selectlistfiles} + 1; 459cdf0e10cSrcweir $infoline = "SELECTLIST: Number of files in file selection list: $number\n"; 460cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 461cdf0e10cSrcweir $number = $#keptfiles + 1; 462cdf0e10cSrcweir $infoline = "SELECTLIST: Number of kept files: $number\n"; 463cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 464cdf0e10cSrcweir 465cdf0e10cSrcweir for ( my $k = 0; $k <= $#keptfiles; $k++ ) 466cdf0e10cSrcweir { 467cdf0e10cSrcweir $infoline = "KEPT FILES: $keptfiles[$k]\n"; 468cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 469cdf0e10cSrcweir } 470cdf0e10cSrcweir 471cdf0e10cSrcweir my @warningfiles = (); 472cdf0e10cSrcweir 473cdf0e10cSrcweir for ( my $k = 0; $k <= $#{$selectlistfiles}; $k++ ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir if ( ! installer::existence::exists_in_array(${$selectlistfiles}[$k],\@keptfiles) ) 476cdf0e10cSrcweir { 477cdf0e10cSrcweir push(@warningfiles, ${$selectlistfiles}[$k]); 478cdf0e10cSrcweir } 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir for ( my $k = 0; $k <= $#warningfiles; $k++ ) 482cdf0e10cSrcweir { 483cdf0e10cSrcweir $infoline = "WARNING: $warningfiles[$k] not included in install set (does not exist in zip file)!\n"; 484cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 485cdf0e10cSrcweir } 486cdf0e10cSrcweir 487cdf0e10cSrcweir } 488cdf0e10cSrcweir 489cdf0e10cSrcweir # Comparing the content of @keptpatchflags and $patchlistfiles 490cdf0e10cSrcweir # Do all files from the patch list have a PATCH flag ? 491cdf0e10cSrcweir # @keptpatchflags contains only files included in $patchlistfiles. But are all 492cdf0e10cSrcweir # files from $patchlistfiles included in @keptpatchflags? 493cdf0e10cSrcweir 494cdf0e10cSrcweir if ( $select_patch_files ) 495cdf0e10cSrcweir { 496cdf0e10cSrcweir my $number = $#{$patchlistfiles} + 1; 497cdf0e10cSrcweir $infoline = "PATCHLIST: Number of files in patch list: $number\n"; 498cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 499cdf0e10cSrcweir $number = $#keptpatchflags + 1; 500cdf0e10cSrcweir $infoline = "PATCHLIST: Number of kept PATCH flags: $number\n"; 501cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 502cdf0e10cSrcweir 503cdf0e10cSrcweir for ( my $k = 0; $k <= $#keptpatchflags; $k++ ) 504cdf0e10cSrcweir { 505cdf0e10cSrcweir $infoline = "KEPT PATCH FLAGS: $keptpatchflags[$k]\n"; 506cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 507cdf0e10cSrcweir } 508cdf0e10cSrcweir 509cdf0e10cSrcweir my @warningfiles = (); 510cdf0e10cSrcweir 511cdf0e10cSrcweir for ( my $k = 0; $k <= $#{$patchlistfiles}; $k++ ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir if ( ! installer::existence::exists_in_array(${$patchlistfiles}[$k],\@keptpatchflags) ) 514cdf0e10cSrcweir { 515cdf0e10cSrcweir push(@warningfiles, ${$patchlistfiles}[$k]); 516cdf0e10cSrcweir } 517cdf0e10cSrcweir } 518cdf0e10cSrcweir 519cdf0e10cSrcweir for ( my $k = 0; $k <= $#warningfiles; $k++ ) 520cdf0e10cSrcweir { 521cdf0e10cSrcweir $infoline = "WARNING: $warningfiles[$k] did not keep PATCH flag (does not exist in zip file)!\n"; 522cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 523cdf0e10cSrcweir } 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir if ( $unziperror ) 527cdf0e10cSrcweir { 528cdf0e10cSrcweir installer::logger::print_warning( "Repeating to unpack $sourcepath! \n" ); 529cdf0e10cSrcweir $infoline = "ATTENTION: Repeating to unpack $sourcepath !\n"; 530cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 531cdf0e10cSrcweir $repeat_unzip = 1; 532cdf0e10cSrcweir $maxcounter++; 533cdf0e10cSrcweir 534cdf0e10cSrcweir if ( $maxcounter == 5 ) # exiting the program 535cdf0e10cSrcweir { 536cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Failed to unzip $sourcepath !", "resolving_archive_flag"); 537cdf0e10cSrcweir } 538cdf0e10cSrcweir } 539cdf0e10cSrcweir else 540cdf0e10cSrcweir { 541cdf0e10cSrcweir $infoline = "Info: $sourcepath unpacked without problems !\n"; 542cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 543cdf0e10cSrcweir $repeat_unzip = 0; 544cdf0e10cSrcweir $maxcounter = 0; 545cdf0e10cSrcweir } 546cdf0e10cSrcweir } 547cdf0e10cSrcweir } 548cdf0e10cSrcweir else # nothing to do here, no zipped file (no ARCHIVE flag) 549cdf0e10cSrcweir { 550cdf0e10cSrcweir push(@newallfilesarray, $onefile); 551cdf0e10cSrcweir } 552cdf0e10cSrcweir } 553cdf0e10cSrcweir 554cdf0e10cSrcweir $infoline = "\n"; 555cdf0e10cSrcweir push( @installer::globals::logfileinfo, $infoline); 556cdf0e10cSrcweir 557cdf0e10cSrcweir return \@newallfilesarray; 558cdf0e10cSrcweir} 559cdf0e10cSrcweir 560cdf0e10cSrcweir 561cdf0e10cSrcweir1; 562