19780544fSAndrew Rist#************************************************************** 29780544fSAndrew Rist# 39780544fSAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 49780544fSAndrew Rist# or more contributor license agreements. See the NOTICE file 59780544fSAndrew Rist# distributed with this work for additional information 69780544fSAndrew Rist# regarding copyright ownership. The ASF licenses this file 79780544fSAndrew Rist# to you under the Apache License, Version 2.0 (the 89780544fSAndrew Rist# "License"); you may not use this file except in compliance 99780544fSAndrew Rist# with the License. You may obtain a copy of the License at 109780544fSAndrew Rist# 119780544fSAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 129780544fSAndrew Rist# 139780544fSAndrew Rist# Unless required by applicable law or agreed to in writing, 149780544fSAndrew Rist# software distributed under the License is distributed on an 159780544fSAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169780544fSAndrew Rist# KIND, either express or implied. See the License for the 179780544fSAndrew Rist# specific language governing permissions and limitations 189780544fSAndrew Rist# under the License. 199780544fSAndrew Rist# 209780544fSAndrew Rist#************************************************************** 219780544fSAndrew Rist 229780544fSAndrew 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'} ); 200b274bc22SAndre Fischer $installer::logging::Lang->printf("Selected file list defined at file: %s :\n", $onefile->{'Name'}); 201b274bc22SAndre Fischer foreach my $line (@$selectlistfiles) 202cdf0e10cSrcweir { 203b274bc22SAndre Fischer $installer::logging::Lang->printf("\"%s\"\n", $line); 204cdf0e10cSrcweir } 205cdf0e10cSrcweir } 206cdf0e10cSrcweir 207cdf0e10cSrcweir if ( $onefile->{'Selectfiles'} ) { $onefile->{'Selectfiles'} = ""; } # Selected files list no longer required 208cdf0e10cSrcweir 209cdf0e10cSrcweir # mechanism to define patch files inside an archive files 210cdf0e10cSrcweir my $select_patch_files = 0; 211cdf0e10cSrcweir my $patchlistfiles = ""; 212cdf0e10cSrcweir my @keptpatchflags = (); 213cdf0e10cSrcweir if (( $styles =~ /\bPATCH\b/ ) && ( $onefile->{'Patchfiles'} ) && ( $installer::globals::patch )) 214cdf0e10cSrcweir { 215cdf0e10cSrcweir $select_patch_files = 1; # special handling if a Patchlist is defined 216cdf0e10cSrcweir $patchlistfiles = get_patch_file_list( $onefile->{'Patchfiles'} ); 217b274bc22SAndre Fischer $installer::logger::Lang->printf("Patch file list defined at file: %s :\n", $onefile->{'Name'}); 218b274bc22SAndre Fischer foreach my $line (@$patchlistfiles) 219cdf0e10cSrcweir { 220b274bc22SAndre Fischer $installer::logger::Lang->printf("\"%s\"\n", $line); 221cdf0e10cSrcweir } 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir if ( $onefile->{'Patchfiles'} ) { $onefile->{'Patchfiles'} = ""; } # Patch file list no longer required 225cdf0e10cSrcweir 226cdf0e10cSrcweir # creating directories 227cdf0e10cSrcweir 228cdf0e10cSrcweir my $onelanguage = $onefile->{'specificlanguage'}; 229cdf0e10cSrcweir 230cdf0e10cSrcweir # files without language into directory "00" 231cdf0e10cSrcweir 232cdf0e10cSrcweir if ($onelanguage eq "") { $onelanguage = "00"; } 233cdf0e10cSrcweir 234cdf0e10cSrcweir my $unzipdir; 235cdf0e10cSrcweir 236cdf0e10cSrcweir # if ($iscommonfile) { $unzipdir = $commonunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; } 237cdf0e10cSrcweir # else { $unzipdir = $platformunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; } 238cdf0e10cSrcweir 239cdf0e10cSrcweir $unzipdir = $platformunzipdirbase . $installer::globals::separator . $onelanguage . $installer::globals::separator; 240cdf0e10cSrcweir 241cdf0e10cSrcweir installer::systemactions::create_directory($unzipdir); # creating language specific subdirectories 242cdf0e10cSrcweir 243cdf0e10cSrcweir my $onefilename = $onefile->{'Name'}; 244cdf0e10cSrcweir $onefilename =~ s/\./\_/g; # creating new directory name 245cdf0e10cSrcweir $onefilename =~ s/\//\_/g; # only because of /letter/fontunxpsprint.zip, the only zip file with path 246cdf0e10cSrcweir $unzipdir = $unzipdir . $onefilename . $installer::globals::separator; 247cdf0e10cSrcweir 248cdf0e10cSrcweir if ( $installer::globals::dounzip ) { installer::systemactions::create_directory($unzipdir); } # creating subdirectories with the names of the zipfiles 249cdf0e10cSrcweir 250cdf0e10cSrcweir my $zip = Archive::Zip->new(); 251cdf0e10cSrcweir if ( $zip->read($sourcepath) != AZ_OK ) 252cdf0e10cSrcweir { 253b274bc22SAndre Fischer $installer::logger::Lang->printf("ERROR: Could not unzip %s\n", $sourcepath); 254cdf0e10cSrcweir } 255cdf0e10cSrcweir 256cdf0e10cSrcweir my $counter = 0; 257cdf0e10cSrcweir my $contains_dll = 0; 258cdf0e10cSrcweir foreach my $member ( $zip->memberNames() ) 259cdf0e10cSrcweir { 260cdf0e10cSrcweir $counter++; 261cdf0e10cSrcweir if ( $member =~ /.dll\s*$/ ) { $contains_dll = 1; } 262cdf0e10cSrcweir } 263cdf0e10cSrcweir 264cdf0e10cSrcweir if (! ( $counter > 0 )) # the zipfile is empty 265cdf0e10cSrcweir { 266b274bc22SAndre Fischer $installer::logger::Lang->printf("ERROR: Could not unzip %s\n", $sourcepath); 267cdf0e10cSrcweir } 268cdf0e10cSrcweir else 269cdf0e10cSrcweir { 270cdf0e10cSrcweir if ( $installer::globals::dounzip ) # really unpacking the files 271cdf0e10cSrcweir { 272b274bc22SAndre Fischer if ( $zip->extractTree("", $unzipdir) != AZ_OK ) 273b274bc22SAndre Fischer { 274b274bc22SAndre Fischer installer::exiter::exit_program("ERROR: can not unzip ".$sourcepath, "resolving_archive_flag"); 275b274bc22SAndre Fischer } 276cdf0e10cSrcweir 277cdf0e10cSrcweir if (( $^O =~ /cygwin/i ) && ( $contains_dll )) 278cdf0e10cSrcweir { 279cdf0e10cSrcweir # Make dll's executable 280cdf0e10cSrcweir $systemcall = "cd $unzipdir; find . -name \\*.dll -exec chmod 775 \{\} \\\;"; 281cdf0e10cSrcweir $returnvalue = system($systemcall); 282b274bc22SAndre Fischer $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 283cdf0e10cSrcweir 284cdf0e10cSrcweir if ($returnvalue) 285cdf0e10cSrcweir { 286b274bc22SAndre Fischer $installer::logger::Lang->printf("ERROR: Could not execute \"\"!\n", $systemcall); 287cdf0e10cSrcweir } 288cdf0e10cSrcweir } 289cdf0e10cSrcweir 290cdf0e10cSrcweir if ( ! $installer::globals::iswindowsbuild ) 291cdf0e10cSrcweir { 292cdf0e10cSrcweir # Setting unix rights to "775" for all created directories inside the package 293cdf0e10cSrcweir 294cdf0e10cSrcweir $systemcall = "cd $unzipdir; find . -type d -exec chmod 775 \{\} \\\;"; 295cdf0e10cSrcweir $returnvalue = system($systemcall); 296b274bc22SAndre Fischer $installer::logger::Lang->printf("Systemcall: %s\n", $systemcall); 297cdf0e10cSrcweir if ($returnvalue) 298cdf0e10cSrcweir { 299b274bc22SAndre Fischer $installer::logger::Lang->printf("ERROR: Could not execute \"\"!\n", $systemcall); 300cdf0e10cSrcweir } 301cdf0e10cSrcweir } 302cdf0e10cSrcweir 303cdf0e10cSrcweir # Selecting names of executable files in extensions 304cdf0e10cSrcweir if ( $set_executable_privileges ) 305cdf0e10cSrcweir { 306cdf0e10cSrcweir collect_all_executable_files_in_extensions($unzipdir, \%executable_files_in_extensions); 307cdf0e10cSrcweir } 308cdf0e10cSrcweir } 309cdf0e10cSrcweir 310cdf0e10cSrcweir my $zipfileref = \@zipfile; 311cdf0e10cSrcweir my $unziperror = 0; 312cdf0e10cSrcweir 313cdf0e10cSrcweir foreach my $zipname ( $zip->memberNames() ) 314cdf0e10cSrcweir { 315cdf0e10cSrcweir # Format from Archive:::Zip : 316cdf0e10cSrcweir # dir1/ 317cdf0e10cSrcweir # dir1/so7drawing.desktop 318cdf0e10cSrcweir 319cdf0e10cSrcweir # some directories and files (from the help) start with "./simpress.idx" 320cdf0e10cSrcweir 321cdf0e10cSrcweir $zipname =~ s/^\s*\.\///; 322cdf0e10cSrcweir 323cdf0e10cSrcweir if ($installer::globals::iswin and $^O =~ /MSWin/i) { $zipname =~ s/\//\\/g; } 324cdf0e10cSrcweir 325cdf0e10cSrcweir if ( $zipname =~ /\Q$installer::globals::separator\E\s*$/ ) # slash or backslash at the end characterizes a directory 326cdf0e10cSrcweir { 327cdf0e10cSrcweir $zipname = $zipname . "\n"; 328cdf0e10cSrcweir push(@{$additionalpathsref}, $zipname); 329cdf0e10cSrcweir 330cdf0e10cSrcweir # Also needed here: 331cdf0e10cSrcweir # Name 332cdf0e10cSrcweir # Language 333cdf0e10cSrcweir # ismultilingual 334cdf0e10cSrcweir # Basedirectory 335cdf0e10cSrcweir 336cdf0e10cSrcweir # This is not needed, because the list of all directories for the 337cdf0e10cSrcweir # epm list file is generated from the destination directories of the 338cdf0e10cSrcweir # files included in the product! 339cdf0e10cSrcweir } 340cdf0e10cSrcweir else 341cdf0e10cSrcweir { 342cdf0e10cSrcweir my %newfile = (); 343cdf0e10cSrcweir %newfile = %{$onefile}; 344cdf0e10cSrcweir $newfile{'Name'} = $zipname; 345cdf0e10cSrcweir my $destination = $onefile->{'destination'}; 346cdf0e10cSrcweir installer::pathanalyzer::get_path_from_fullqualifiedname(\$destination); 347cdf0e10cSrcweir $newfile{'destination'} = $destination . $zipname; 348cdf0e10cSrcweir $newfile{'sourcepath'} = $unzipdir . $zipname; 349cdf0e10cSrcweir $newfile{'zipfilename'} = $onefile->{'Name'}; 350cdf0e10cSrcweir $newfile{'zipfilesource'} = $onefile->{'sourcepath'}; 351cdf0e10cSrcweir $newfile{'zipfiledestination'} = $onefile->{'destination'}; 352cdf0e10cSrcweir 353cdf0e10cSrcweir if (( $use_internal_rights ) && ( ! $installer::globals::iswin )) 354cdf0e10cSrcweir { 355cdf0e10cSrcweir my $value = sprintf("%o", (stat($newfile{'sourcepath'}))[2]); 356cdf0e10cSrcweir $newfile{'UnixRights'} = substr($value, 3); 357b274bc22SAndre Fischer $installer::logger::Lang->printf( 358b274bc22SAndre Fischer "Setting unix rights for \"%s\" to \"%s\"\n", 359b274bc22SAndre Fischer $newfile{'sourcepath'}, 360b274bc22SAndre Fischer $newfile{'UnixRights'}); 361cdf0e10cSrcweir } 362cdf0e10cSrcweir 363cdf0e10cSrcweir if ( $set_executable_privileges ) 364cdf0e10cSrcweir { 365*86e1cf34SPedro Giffuni # All paths to executables are saved in the hash %executable_files_in_extensions 366cdf0e10cSrcweir my $compare_path = $newfile{'sourcepath'}; 367cdf0e10cSrcweir $compare_path =~ s/\\/\//g; # contains only slashes for comparison reasons 368cdf0e10cSrcweir if ( exists($executable_files_in_extensions{$compare_path}) ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir $newfile{'UnixRights'} = "775"; 371b274bc22SAndre Fischer $installer::logger::Lang->printf( 372b274bc22SAndre Fischer "Executable in Extension: Setting unix rights for \"%s\" to \"%s\"\n", 373b274bc22SAndre Fischer $newfile{'sourcepath'}, 374b274bc22SAndre Fischer $newfile{'UnixRights'}); 375cdf0e10cSrcweir } 376cdf0e10cSrcweir } 377cdf0e10cSrcweir 378cdf0e10cSrcweir if ( $select_files ) 379cdf0e10cSrcweir { 380cdf0e10cSrcweir if ( ! installer::existence::exists_in_array($zipname,$selectlistfiles) ) 381cdf0e10cSrcweir { 382b274bc22SAndre Fischer $installer::logger::Lang->printf("Removing from ARCHIVE file %s: %s\n", 383b274bc22SAndre Fischer $onefilename, 384b274bc22SAndre Fischer $zipname); 385cdf0e10cSrcweir next; # ignoring files, that are not included in $selectlistfiles 386cdf0e10cSrcweir } 387cdf0e10cSrcweir else 388cdf0e10cSrcweir { 389b274bc22SAndre Fischer $installer::logger::Lang->printf("Keeping from ARCHIVE file %s: \n", 390b274bc22SAndre Fischer $onefilename, 391b274bc22SAndre Fischer $zipname); 392cdf0e10cSrcweir push( @keptfiles, $zipname); # collecting all kept files 393cdf0e10cSrcweir } 394cdf0e10cSrcweir } 395cdf0e10cSrcweir 396cdf0e10cSrcweir if ( $select_patch_files ) 397cdf0e10cSrcweir { 398cdf0e10cSrcweir # Is this file listed in the Patchfile list? 399cdf0e10cSrcweir # $zipname (filename including path in zip file has to be listed in patchfile list 400cdf0e10cSrcweir 401cdf0e10cSrcweir if ( ! installer::existence::exists_in_array($zipname,$patchlistfiles) ) 402cdf0e10cSrcweir { 403cdf0e10cSrcweir $newfile{'Styles'} =~ s/\bPATCH\b//; # removing the flag PATCH 404cdf0e10cSrcweir $newfile{'Styles'} =~ s/\,\s*\,/\,/; 405cdf0e10cSrcweir $newfile{'Styles'} =~ s/\(\s*\,/\(/; 406cdf0e10cSrcweir $newfile{'Styles'} =~ s/\,\s*\)/\)/; 407cdf0e10cSrcweir } 408cdf0e10cSrcweir else 409cdf0e10cSrcweir { 410cdf0e10cSrcweir push( @keptpatchflags, $zipname); # collecting all PATCH flags 411cdf0e10cSrcweir } 412cdf0e10cSrcweir } 413cdf0e10cSrcweir 414cdf0e10cSrcweir if ( $rename_to_language ) 415cdf0e10cSrcweir { 416cdf0e10cSrcweir my $newzipname = put_language_into_name($zipname, $onelanguage); 417cdf0e10cSrcweir my $oldfilename = $unzipdir . $zipname; 418cdf0e10cSrcweir my $newfilename = $unzipdir . $newzipname; 419cdf0e10cSrcweir 420cdf0e10cSrcweir installer::systemactions::copy_one_file($oldfilename, $newfilename); 421cdf0e10cSrcweir 422cdf0e10cSrcweir $newfile{'Name'} = $newzipname; 423cdf0e10cSrcweir $newfile{'destination'} = $destination . $newzipname; 424cdf0e10cSrcweir $newfile{'sourcepath'} = $unzipdir . $newzipname; 425cdf0e10cSrcweir 426b274bc22SAndre Fischer $installer::logger::Lang->printf("RENAME_TO_LANGUAGE: Using %s instead of %s!\n", 427b274bc22SAndre Fischer $newzipname, 428b274bc22SAndre Fischer $zipname); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir my $sourcefiletest = $unzipdir . $zipname; 432cdf0e10cSrcweir if ( ! -f $sourcefiletest ) 433cdf0e10cSrcweir { 434b274bc22SAndre Fischer $installer::logger::Lang->printf("ATTENTION: Unzip failed for %s!\n", $sourcefiletest); 435cdf0e10cSrcweir $unziperror = 1; 436cdf0e10cSrcweir } 437cdf0e10cSrcweir 438cdf0e10cSrcweir # only adding the new line into the files array, if not in repeat modus 439cdf0e10cSrcweir 440cdf0e10cSrcweir if ( ! $repeat_unzip ) { push(@newallfilesarray, \%newfile); } 441cdf0e10cSrcweir } 442cdf0e10cSrcweir } 443cdf0e10cSrcweir 444cdf0e10cSrcweir # Comparing the content of @keptfiles and $selectlistfiles 445cdf0e10cSrcweir # Do all files from the list of selected files are stored in @keptfiles ? 446cdf0e10cSrcweir # @keptfiles contains only files included in $selectlistfiles. But are all 447cdf0e10cSrcweir # files from $selectlistfiles included in @keptfiles? 448cdf0e10cSrcweir 449cdf0e10cSrcweir if ( $select_files ) 450cdf0e10cSrcweir { 451b274bc22SAndre Fischer $installer::logger::Lang->printf("SELECTLIST: Number of files in file selection list: %d\n", 452b274bc22SAndre Fischer scalar @$selectlistfiles); 453b274bc22SAndre Fischer $installer::logger::Lang->printf("SELECTLIST: Number of kept files: %d\n", 454b274bc22SAndre Fischer scalar @keptfiles); 455b274bc22SAndre Fischer 456b274bc22SAndre Fischer foreach my $name (@keptfiles) 457cdf0e10cSrcweir { 458b274bc22SAndre Fischer $installer::logger::Lang->printf("KEPT FILES: %s\n", $name); 459cdf0e10cSrcweir } 460cdf0e10cSrcweir 461b274bc22SAndre Fischer foreach my $name (@$selectlistfiles) 462cdf0e10cSrcweir { 463b274bc22SAndre Fischer if ( ! installer::existence::exists_in_array($name,\@keptfiles) ) 464cdf0e10cSrcweir { 465b274bc22SAndre Fischer $installer::logger::Lang->printf( 466b274bc22SAndre Fischer "WARNING: %s not included in install set (does not exist in zip file)!\n", 467b274bc22SAndre Fischer $name);; 468cdf0e10cSrcweir } 469cdf0e10cSrcweir } 470cdf0e10cSrcweir } 471cdf0e10cSrcweir 472cdf0e10cSrcweir # Comparing the content of @keptpatchflags and $patchlistfiles 473cdf0e10cSrcweir # Do all files from the patch list have a PATCH flag ? 474cdf0e10cSrcweir # @keptpatchflags contains only files included in $patchlistfiles. But are all 475cdf0e10cSrcweir # files from $patchlistfiles included in @keptpatchflags? 476cdf0e10cSrcweir 477cdf0e10cSrcweir if ( $select_patch_files ) 478cdf0e10cSrcweir { 479b274bc22SAndre Fischer $installer::logger::Lang->printf("PATCHLIST: Number of files in patch list: %d\n", 480b274bc22SAndre Fischer scalar @$patchlistfiles); 481b274bc22SAndre Fischer $installer::logger::Lang->printf("PATCHLIST: Number of kept PATCH flags: %d\n", 482b274bc22SAndre Fischer scalar @keptpatchflags); 483cdf0e10cSrcweir 484b274bc22SAndre Fischer foreach my $flag (@keptpatchflags) 485cdf0e10cSrcweir { 486b274bc22SAndre Fischer $installer::logger::Lang->printf("KEPT PATCH FLAGS: %s\n", 487b274bc22SAndre Fischer $flag); 488cdf0e10cSrcweir } 489cdf0e10cSrcweir 490b274bc22SAndre Fischer foreach my $name (@$patchlistfiles) 491cdf0e10cSrcweir { 492b274bc22SAndre Fischer if ( ! installer::existence::exists_in_array($name,\@keptpatchflags) ) 493b274bc22SAndre Fischer { 494b274bc22SAndre Fischer $installer::logger::Lang->printf( 495b274bc22SAndre Fischer "WARNING: %s did not keep PATCH flag (does not exist in zip file)!\n", 496b274bc22SAndre Fischer $name); 497b274bc22SAndre Fischer } 498cdf0e10cSrcweir } 499cdf0e10cSrcweir } 500cdf0e10cSrcweir 501cdf0e10cSrcweir if ( $unziperror ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir installer::logger::print_warning( "Repeating to unpack $sourcepath! \n" ); 504b274bc22SAndre Fischer $installer::logger::Lang->printf("ATTENTION: Repeating to unpack %s!\n", $sourcepath); 505cdf0e10cSrcweir $repeat_unzip = 1; 506cdf0e10cSrcweir $maxcounter++; 507cdf0e10cSrcweir 508cdf0e10cSrcweir if ( $maxcounter == 5 ) # exiting the program 509cdf0e10cSrcweir { 510cdf0e10cSrcweir installer::exiter::exit_program("ERROR: Failed to unzip $sourcepath !", "resolving_archive_flag"); 511cdf0e10cSrcweir } 512cdf0e10cSrcweir } 513cdf0e10cSrcweir else 514cdf0e10cSrcweir { 515b274bc22SAndre Fischer $installer::logger::Lang->printf("Info: %s unpacked without problems !\n", $sourcepath); 516cdf0e10cSrcweir $repeat_unzip = 0; 517cdf0e10cSrcweir $maxcounter = 0; 518cdf0e10cSrcweir } 519cdf0e10cSrcweir } 520cdf0e10cSrcweir } 521cdf0e10cSrcweir else # nothing to do here, no zipped file (no ARCHIVE flag) 522cdf0e10cSrcweir { 523cdf0e10cSrcweir push(@newallfilesarray, $onefile); 524cdf0e10cSrcweir } 525cdf0e10cSrcweir } 526cdf0e10cSrcweir 527b274bc22SAndre Fischer $installer::logger::Lang->print("\n"); 528cdf0e10cSrcweir 529cdf0e10cSrcweir return \@newallfilesarray; 530cdf0e10cSrcweir} 531cdf0e10cSrcweir 532cdf0e10cSrcweir 533cdf0e10cSrcweir1; 534