solenv/bin/modules/installer.pm | 41 +++ solenv/bin/modules/installer/epmfile.pm | 200 +++++++++++++++++- solenv/bin/modules/installer/exiter.pm | 72 ------ solenv/bin/modules/installer/scriptitems.pm | 28 ++ solenv/bin/modules/installer/worker.pm | 307 ---------------------------- 5 files changed, 266 insertions(+), 382 deletions(-)
New commits: commit 43ac04763d60ae651dc8f1a592cc2f0d41387a7d Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 22:06:11 2012 +0100 installer: Add extra failure warning. Change-Id: I387ee22ce59606b9680e1df70b8076ec474427a6 diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm index 2c2ef22..2c1f855 100644 --- a/solenv/bin/modules/installer.pm +++ b/solenv/bin/modules/installer.pm @@ -98,6 +98,7 @@ sub main { if ($@) { my $message = "ERROR: $@"; + warn "ERROR: Failure in installer.pm\n"; warn "$message\n"; $exit_code = -1; commit 247d1899e3fb69af30094d388c97ce074a2da26c Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 21:58:45 2012 +0100 installer::worker: Remove unused tar_package Change-Id: I58e9efdda8fac5b65e259b63a5150c44fa00feb6 diff --git a/solenv/bin/modules/installer/worker.pm b/solenv/bin/modules/installer/worker.pm index 017f2ab..cb205b4 100644 --- a/solenv/bin/modules/installer/worker.pm +++ b/solenv/bin/modules/installer/worker.pm @@ -1387,43 +1387,6 @@ sub put_license_into_setup } ######################################################### -# Create a tar file from the binary package -######################################################### - -sub tar_package -{ - my ( $installdir, $packagename, $tarfilename, $getuidlibrary) = @_; - - my $ldpreloadstring = ""; - if ( $getuidlibrary ne "" ) { $ldpreloadstring = "LD_PRELOAD=" . $getuidlibrary; } - - my $systemcall = "cd $installdir; $ldpreloadstring tar -cf - $packagename > $tarfilename"; - - my $returnvalue = system($systemcall); - - my $infoline = "Systemcall: $systemcall\n"; - push( @installer::globals::logfileinfo, $infoline); - - if ($returnvalue) - { - $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - else - { - $infoline = "Success: Executed \"$systemcall\" successfully!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - - chmod 0775, $tarfilename; - - my $fulltarfile = $installdir . $installer::globals::separator . $tarfilename; - my $filesize = ( -s $fulltarfile ); - - return $filesize; -} - -######################################################### # Collecting all pkgmap files from an installation set ######################################################### commit acaaf6c72162566e896421e03ee4c966936c7917 Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 21:56:28 2012 +0100 installer: Move key_in_a_is_also_key_in_b into scriptfiles.pm Change-Id: I466b285ddc9f3ac53978acefe76c27fa212d812c diff --git a/solenv/bin/modules/installer/scriptitems.pm b/solenv/bin/modules/installer/scriptitems.pm index 42ee98d..9ce5bd6 100644 --- a/solenv/bin/modules/installer/scriptitems.pm +++ b/solenv/bin/modules/installer/scriptitems.pm @@ -2146,7 +2146,7 @@ sub get_string_of_modulegids_for_itemgid # Check: All modules or no module must have flag LANGUAGEMODULE if ( $haslanguagemodule ) { - my $isreallylanguagemodule = installer::worker::key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules); + my $isreallylanguagemodule = _key_in_a_is_also_key_in_b(\%foundmodules, \%installer::globals::alllangmodules); if ( ! $isreallylanguagemodule ) { installer::exiter::exit_program("ERROR: \"$itemgid\" is assigned to modules with flag \"LANGUAGEMODULE\" and also to modules without this flag! Modules: $allmodules", "get_string_of_modulegids_for_itemgid"); } } @@ -2498,4 +2498,30 @@ sub select_required_language_strings } } +################################################ +# Controlling that all keys in hash A are +# also key in hash B. +################################################ + +sub _key_in_a_is_also_key_in_b +{ + my ( $hashref_a, $hashref_b) = @_; + + my $returnvalue = 1; + + my $key; + foreach $key ( keys %{$hashref_a} ) + { + if ( ! exists($hashref_b->{$key}) ) + { + print "*****\n"; + foreach $keyb ( keys %{$hashref_b} ) { print "$keyb : $hashref_b->{$keyb}\n"; } + print "*****\n"; + $returnvalue = 0; + } + } + + return $returnvalue; +} + 1; diff --git a/solenv/bin/modules/installer/worker.pm b/solenv/bin/modules/installer/worker.pm index e895f54..017f2ab 100644 --- a/solenv/bin/modules/installer/worker.pm +++ b/solenv/bin/modules/installer/worker.pm @@ -1252,32 +1252,6 @@ sub resolving_hidden_flag push( @installer::globals::logfileinfo, $infoline); } -################################################ -# Controlling that all keys in hash A are -# also key in hash B. -################################################ - -sub key_in_a_is_also_key_in_b -{ - my ( $hashref_a, $hashref_b) = @_; - - my $returnvalue = 1; - - my $key; - foreach $key ( keys %{$hashref_a} ) - { - if ( ! exists($hashref_b->{$key}) ) - { - print "*****\n"; - foreach $keyb ( keys %{$hashref_b} ) { print "$keyb : $hashref_b->{$keyb}\n"; } - print "*****\n"; - $returnvalue = 0; - } - } - - return $returnvalue; -} - ###################################################### # Getting the first entry from a list of languages ###################################################### commit c003a803868a0faaae0f5b6949ffcaab54f7ef32 Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 21:38:36 2012 +0100 installer: Move various functions from worker.pm to epmfile.pm Change-Id: I3ff5ce804eb348f91f1cf46b38475c4224d68978 diff --git a/solenv/bin/modules/installer/epmfile.pm b/solenv/bin/modules/installer/epmfile.pm index 8045536..58bca0b 100644 --- a/solenv/bin/modules/installer/epmfile.pm +++ b/solenv/bin/modules/installer/epmfile.pm @@ -36,9 +36,9 @@ use installer::logger; use installer::packagelist; use installer::pathanalyzer; use installer::remover; +use installer::scpzipfiles; use installer::scriptitems; use installer::systemactions; -use installer::worker; use POSIX; ############################################################################ @@ -413,7 +413,7 @@ sub create_epm_header if (( $installer::globals::issolarispkgbuild ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { - if ( ! $installer::globals::englishlicenseset ) { installer::worker::set_english_license() } + if ( ! $installer::globals::englishlicenseset ) { _set_english_license() } # The location for the new file my $languagestring = ""; @@ -2797,7 +2797,7 @@ sub put_systemintegration_into_installset if ( ! $installer::globals::issolarispkgbuild ) { ($newcontent, $subdir) = control_subdirectories($newcontent); } # Adding license content into Solaris packages - if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { installer::worker::add_license_into_systemintegrationpackages($destdir, $newcontent); } + if (( $installer::globals::issolarispkgbuild ) && ( $installer::globals::englishlicenseset ) && ( ! $variableshashref->{'NO_LICENSE_INTO_COPYRIGHT'} )) { _add_license_into_systemintegrationpackages($destdir, $newcontent); } } } @@ -3002,4 +3002,198 @@ sub finalize_linux_patch chmod 0755, $newscriptfilename; } +################################################ +# Defining the English license text to add +# it into Solaris packages. +################################################ + +sub _set_english_license +{ + my $additional_license_name = $installer::globals::englishsolarislicensename; # always the English file + my $licensefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$additional_license_name, "" , 0); + if ( $$licensefileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $additional_license_name!", "set_english_license"); } + $installer::globals::englishlicenseset = 1; + $installer::globals::englishlicense = installer::files::read_file($$licensefileref); + installer::scpzipfiles::replace_all_ziplistvariables_in_file($installer::globals::englishlicense, $variableshashref); +} + +################################################ +# Adding the content of the English license +# file into the system integration packages. +################################################ + +sub _add_license_into_systemintegrationpackages +{ + my ($destdir, $packages) = @_; + + for ( my $i = 0; $i <= $#{$packages}; $i++ ) + { + my $copyrightfilename = ${$packages}[$i] . $installer::globals::separator . "install" . $installer::globals::separator . "copyright"; + if ( ! -f $copyrightfilename ) { installer::exiter::exit_program("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); } + my $copyrightfile = installer::files::read_file($copyrightfilename); + + # Saving time stamp of old copyrightfile + my $savcopyrightfilename = $copyrightfilename . ".sav"; + installer::systemactions::copy_one_file($copyrightfilename, $savcopyrightfilename); + _set_time_stamp_for_file($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile + + # Adding license content to copyright file + push(@{$copyrightfile}, "\n"); + for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); } + installer::files::save_file($copyrightfilename, $copyrightfile); + + # Setting the old time stamp saved with $savcopyrightfilename + _set_time_stamp_for_file($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile + unlink($savcopyrightfilename); + + # Changing content of copyright file in pkgmap + my $pkgmapfilename = ${$packages}[$i] . $installer::globals::separator . "pkgmap"; + if ( ! -f $pkgmapfilename ) { installer::exiter::exit_program("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); } + my $pkgmap = installer::files::read_file($pkgmapfilename); + _change_onefile_in_pkgmap($pkgmap, $copyrightfilename, "copyright"); + installer::files::save_file($pkgmapfilename, $pkgmap); + } +} + +############################################## +# Setting time stamp of copied files to avoid +# errors from pkgchk. +############################################## + +sub _set_time_stamp_for_file +{ + my ($sourcefile, $destfile) = @_; + + my $systemcall = "touch -r $sourcefile $destfile"; + + my $returnvalue = system($systemcall); + + my $infoline = "Systemcall: $systemcall\n"; + push( @installer::globals::logfileinfo, $infoline); + + if ($returnvalue) + { + $infoline = "ERROR: \"$systemcall\" failed!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + else + { + $infoline = "Success: \"$systemcall\" !\n"; + push( @installer::globals::logfileinfo, $infoline); + } +} + +############################################## +# Setting checksum and wordcount for changed +# pkginfo file into pkgmap. +############################################## + +sub _change_onefile_in_pkgmap +{ + my ($pkgmapfile, $fullfilename, $shortfilename) = @_; + + # 1 i pkginfo 442 34577 1166716297 + # -> + # 1 i pkginfo 443 34737 1166716297 + # + # wc -c pkginfo | cut -f6 -d' ' -> 442 (variable) + # sum pkginfo | cut -f1 -d' ' -> 34577 (variable) + # grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix) + + my $checksum = _call_sum($fullfilename); + if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; } + + my $wordcount = _call_wc($fullfilename); + if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; } + + for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ ) + { + if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ ) + { + my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7; + ${$pkgmapfile}[$i] = $newline; + last; + } + } +} + +######################################################### +# Calling sum +######################################################### + +sub _call_sum +{ + my ($filename) = @_; + + $sumfile = "/usr/bin/sum"; + + if ( ! -f $sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/sum", "call_sum"); } + + my $systemcall = "$sumfile $filename |"; + + my $sumoutput = ""; + + open (SUM, "$systemcall"); + $sumoutput = <SUM>; + close (SUM); + + my $returnvalue = $?; # $? contains the return value of the systemcall + + my $infoline = "Systemcall: $systemcall\n"; + push( @installer::globals::logfileinfo, $infoline); + + if ($returnvalue) + { + $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + else + { + $infoline = "Success: Executed \"$systemcall\" successfully!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + + return $sumoutput; +} + +######################################################### +# Calling wc +# wc -c pkginfo | cut -f6 -d' ' +######################################################### + +sub _call_wc +{ + my ($filename) = @_; + + $wcfile = "/usr/bin/wc"; + + if ( ! -f $wcfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/wc", "call_wc"); } + + my $systemcall = "$wcfile -c $filename |"; + + my $wcoutput = ""; + + open (WC, "$systemcall"); + $wcoutput = <WC>; + close (WC); + + my $returnvalue = $?; # $? contains the return value of the systemcall + + my $infoline = "Systemcall: $systemcall\n"; + push( @installer::globals::logfileinfo, $infoline); + + if ($returnvalue) + { + $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + else + { + $infoline = "Success: Executed \"$systemcall\" successfully!\n"; + push( @installer::globals::logfileinfo, $infoline); + } + + return $wcoutput; +} + 1; diff --git a/solenv/bin/modules/installer/worker.pm b/solenv/bin/modules/installer/worker.pm index 4912b4a..e895f54 100644 --- a/solenv/bin/modules/installer/worker.pm +++ b/solenv/bin/modules/installer/worker.pm @@ -1094,119 +1094,6 @@ sub find_file_by_id return $onefile; } -######################################################### -# Calling sum -######################################################### - -sub call_sum -{ - my ($filename) = @_; - - $sumfile = "/usr/bin/sum"; - - if ( ! -f $sumfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/sum", "call_sum"); } - - my $systemcall = "$sumfile $filename |"; - - my $sumoutput = ""; - - open (SUM, "$systemcall"); - $sumoutput = <SUM>; - close (SUM); - - my $returnvalue = $?; # $? contains the return value of the systemcall - - my $infoline = "Systemcall: $systemcall\n"; - push( @installer::globals::logfileinfo, $infoline); - - if ($returnvalue) - { - $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - else - { - $infoline = "Success: Executed \"$systemcall\" successfully!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - - return $sumoutput; -} - -######################################################### -# Calling wc -# wc -c pkginfo | cut -f6 -d' ' -######################################################### - -sub call_wc -{ - my ($filename) = @_; - - $wcfile = "/usr/bin/wc"; - - if ( ! -f $wcfile ) { installer::exiter::exit_program("ERROR: No file /usr/bin/wc", "call_wc"); } - - my $systemcall = "$wcfile -c $filename |"; - - my $wcoutput = ""; - - open (WC, "$systemcall"); - $wcoutput = <WC>; - close (WC); - - my $returnvalue = $?; # $? contains the return value of the systemcall - - my $infoline = "Systemcall: $systemcall\n"; - push( @installer::globals::logfileinfo, $infoline); - - if ($returnvalue) - { - $infoline = "ERROR: Could not execute \"$systemcall\"!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - else - { - $infoline = "Success: Executed \"$systemcall\" successfully!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - - return $wcoutput; -} - -############################################## -# Setting time stamp of copied files to avoid -# errors from pkgchk. -############################################## - -sub set_time_stamp -{ - my ($olddir, $newdir, $copyfiles) = @_; - - for ( my $i = 0; $i <= $#{$copyfiles}; $i++ ) - { - my $sourcefile = $olddir . $installer::globals::separator . ${$copyfiles}[$i]; - my $destfile = $newdir . $installer::globals::separator . ${$copyfiles}[$i]; - - my $systemcall = "touch -r $sourcefile $destfile"; - - my $returnvalue = system($systemcall); - - my $infoline = "Systemcall: $systemcall\n"; - push( @installer::globals::logfileinfo, $infoline); - - if ($returnvalue) - { - $infoline = "ERROR: \"$systemcall\" failed!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - else - { - $infoline = "Success: \"$systemcall\" !\n"; - push( @installer::globals::logfileinfo, $infoline); - } - } -} - ################################################# # Generating paths for cygwin (second version) # This function generates smaller files for @@ -1562,121 +1449,6 @@ sub tar_package return $filesize; } -################################################ -# Defining the English license text to add -# it into Solaris packages. -################################################ - -sub set_english_license -{ - my $additional_license_name = $installer::globals::englishsolarislicensename; # always the English file - my $licensefileref = installer::scriptitems::get_sourcepath_from_filename_and_includepath(\$additional_license_name, "" , 0); - if ( $$licensefileref eq "" ) { installer::exiter::exit_program("ERROR: Could not find license file $additional_license_name!", "set_english_license"); } - $installer::globals::englishlicenseset = 1; - $installer::globals::englishlicense = installer::files::read_file($$licensefileref); - installer::scpzipfiles::replace_all_ziplistvariables_in_file($installer::globals::englishlicense, $variableshashref); -} - -############################################## -# Setting time stamp of copied files to avoid -# errors from pkgchk. -############################################## - -sub set_time_stamp_for_file -{ - my ($sourcefile, $destfile) = @_; - - my $systemcall = "touch -r $sourcefile $destfile"; - - my $returnvalue = system($systemcall); - - my $infoline = "Systemcall: $systemcall\n"; - push( @installer::globals::logfileinfo, $infoline); - - if ($returnvalue) - { - $infoline = "ERROR: \"$systemcall\" failed!\n"; - push( @installer::globals::logfileinfo, $infoline); - } - else - { - $infoline = "Success: \"$systemcall\" !\n"; - push( @installer::globals::logfileinfo, $infoline); - } -} - -############################################## -# Setting checksum and wordcount for changed -# pkginfo file into pkgmap. -############################################## - -sub change_onefile_in_pkgmap -{ - my ($pkgmapfile, $fullfilename, $shortfilename) = @_; - - # 1 i pkginfo 442 34577 1166716297 - # -> - # 1 i pkginfo 443 34737 1166716297 - # - # wc -c pkginfo | cut -f6 -d' ' -> 442 (variable) - # sum pkginfo | cut -f1 -d' ' -> 34577 (variable) - # grep 'pkginfo' pkgmap | cut -f6 -d' ' -> 1166716297 (fix) - - my $checksum = call_sum($fullfilename); - if ( $checksum =~ /^\s*(\d+)\s+.*$/ ) { $checksum = $1; } - - my $wordcount = call_wc($fullfilename); - if ( $wordcount =~ /^\s*(\d+)\s+.*$/ ) { $wordcount = $1; } - - for ( my $i = 0; $i <= $#{$pkgmapfile}; $i++ ) - { - if ( ${$pkgmapfile}[$i] =~ /(^.*\b\Q$shortfilename\E\b\s+)(\d+)(\s+)(\d+)(\s+)(\d+)(\s*$)/ ) - { - my $newline = $1 . $wordcount . $3 . $checksum . $5 . $6 . $7; - ${$pkgmapfile}[$i] = $newline; - last; - } - } -} - -################################################ -# Adding the content of the English license -# file into the system integration packages. -################################################ - -sub add_license_into_systemintegrationpackages -{ - my ($destdir, $packages) = @_; - - for ( my $i = 0; $i <= $#{$packages}; $i++ ) - { - my $copyrightfilename = ${$packages}[$i] . $installer::globals::separator . "install" . $installer::globals::separator . "copyright"; - if ( ! -f $copyrightfilename ) { installer::exiter::exit_program("ERROR: Could not find license file in system integration package: $copyrightfilename!", "add_license_into_systemintegrationpackages"); } - my $copyrightfile = installer::files::read_file($copyrightfilename); - - # Saving time stamp of old copyrightfile - my $savcopyrightfilename = $copyrightfilename . ".sav"; - installer::systemactions::copy_one_file($copyrightfilename, $savcopyrightfilename); - set_time_stamp_for_file($copyrightfilename, $savcopyrightfilename); # now $savcopyrightfile has the time stamp of $copyrightfile - - # Adding license content to copyright file - push(@{$copyrightfile}, "\n"); - for ( my $i = 0; $i <= $#{$installer::globals::englishlicense}; $i++ ) { push(@{$copyrightfile}, ${$installer::globals::englishlicense}[$i]); } - installer::files::save_file($copyrightfilename, $copyrightfile); - - # Setting the old time stamp saved with $savcopyrightfilename - set_time_stamp_for_file($savcopyrightfilename, $copyrightfilename); # now $copyrightfile has the time stamp of $savcopyrightfile - unlink($savcopyrightfilename); - - # Changing content of copyright file in pkgmap - my $pkgmapfilename = ${$packages}[$i] . $installer::globals::separator . "pkgmap"; - if ( ! -f $pkgmapfilename ) { installer::exiter::exit_program("ERROR: Could not find pkgmap in system integration package: $pkgmapfilename!", "add_license_into_systemintegrationpackages"); } - my $pkgmap = installer::files::read_file($pkgmapfilename); - change_onefile_in_pkgmap($pkgmap, $copyrightfilename, "copyright"); - installer::files::save_file($pkgmapfilename, $pkgmap); - } -} - ######################################################### # Collecting all pkgmap files from an installation set ######################################################### commit cda8ac41f3aa34accac6a58df2c885595e8ce7ec Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 21:10:13 2012 +0100 installer: Replace installer::worker::shuffle_array Change-Id: I2da961affa4bcb8349d8a038bc77986f5209a55d diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm index 49e2e3c..2c2ef22 100644 --- a/solenv/bin/modules/installer.pm +++ b/solenv/bin/modules/installer.pm @@ -32,6 +32,7 @@ use base 'Exporter'; use Cwd; use Data::Dumper; use File::Copy; +use List::Util qw(shuffle); use installer::archivefiles; use installer::control; use installer::converter; @@ -1057,7 +1058,7 @@ sub run { } # shuffle array to reduce parallel packaging process in pool - installer::worker::shuffle_array($packages) + @{$packages} = shuffle @{$packages} unless $installer::globals::simple; # iterating over all packages diff --git a/solenv/bin/modules/installer/worker.pm b/solenv/bin/modules/installer/worker.pm index e954971..4912b4a 100644 --- a/solenv/bin/modules/installer/worker.pm +++ b/solenv/bin/modules/installer/worker.pm @@ -1562,22 +1562,6 @@ sub tar_package return $filesize; } -######################################################### -# Shuffle an array (Fisher Yates shuffle) -######################################################### - -sub shuffle_array -{ - my ( $arrayref ) = @_; - - my $i = @$arrayref; - while (--$i) - { - my $j = int rand ($i+1); - @$arrayref[$i,$j] = @$arrayref[$j,$i]; - } -} - ################################################ # Defining the English license text to add # it into Solaris packages. commit bc9ad85ca4a70e5b14abe79ea59e848ee3b21e23 Author: Tim Retout <t...@retout.co.uk> Date: Wed Sep 26 18:21:27 2012 +0100 installer: Move exiter.pm error handling into installer.pm Change-Id: I50e3ee8ff88f313b82ea617e354334d85fb453e0 diff --git a/solenv/bin/modules/installer.pm b/solenv/bin/modules/installer.pm index 025d471..49e2e3c 100644 --- a/solenv/bin/modules/installer.pm +++ b/solenv/bin/modules/installer.pm @@ -95,8 +95,12 @@ sub main { run(); }; if ($@) { - warn "$@\n"; + my $message = "ERROR: $@"; + + warn "$message\n"; $exit_code = -1; + + cleanup_on_error($message); } installer::logger::stoptime(); @@ -1820,4 +1824,35 @@ sub run { } # end of iteration for one language group } +sub cleanup_on_error { + my $message = shift; + + # If an installation set is currently created, the directory name + # is saved in $installer::globals::saveinstalldir. If this + # directory name contains "_inprogress", it has to be renamed to + # "_witherror". + if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { + installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); + } + + # Removing directories created in the output tree. + installer::worker::clean_output_tree(); + + $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename; + + my @log = (@installer::globals::logfileinfo, @installer::globals::globallogfileinfo); + + push(@log, "\n" . '*' x 65 . "\n"); + push(@log, $message); + push(@log, '*' x 65 . "\n"); + + installer::files::save_file($installer::globals::logfilename, \@log); + + print("ERROR, saved logfile $installer::globals::logfilename is:\n"); + open(my $log, "<", $installer::globals::logfilename); + print ": $_" while (<$log>); + print "\n"; + close($log); +} + 1; diff --git a/solenv/bin/modules/installer/exiter.pm b/solenv/bin/modules/installer/exiter.pm index 55a1dbb..516565f 100644 --- a/solenv/bin/modules/installer/exiter.pm +++ b/solenv/bin/modules/installer/exiter.pm @@ -30,79 +30,13 @@ package installer::exiter; use strict; use warnings; -use installer::files; -use installer::globals; -use installer::logger; -use installer::systemactions; -use installer::worker; - -############################################ -# Exiting the program with an error -# This function is used instead of "die" -############################################ +use Carp; sub exit_program { - my ($message, $function) = @_; - - # If an installation set is currently created, the directory name is saved in $installer::globals::saveinstalldir - # If this directory name matches with "_inprogress", it has to be renamed into "_witherror" - - if ( $installer::globals::saveinstalldir =~ /_inprogress/ ) { installer::systemactions::rename_string_in_directory($installer::globals::saveinstalldir, "_inprogress", "_witherror"); } - - installer::worker::clean_output_tree(); # removing directories created in the output tree - - # If @installer::globals::logfileinfo is not empty, it can be used. - # Otherwise the content of @installer::globals::globallogfileinfo has to be used. - - my $infoline; - - $installer::globals::logfilename = $installer::globals::exitlog . $installer::globals::logfilename; - - if ( ! $installer::globals::globalinfo_copied ) { installer::logger::copy_globalinfo_into_logfile(); } - - if ( $#installer::globals::logfileinfo > -1 ) - { - $infoline = "\n***************************************************************\n"; - push(@installer::globals::logfileinfo, $infoline); - - $infoline = "$message\n"; - push(@installer::globals::logfileinfo, $infoline); - - $infoline = "in function: $function\n"; - push(@installer::globals::logfileinfo, $infoline); - - $infoline = "***************************************************************\n"; - push(@installer::globals::logfileinfo, $infoline); - - installer::files::save_file($installer::globals::logfilename ,\@installer::globals::logfileinfo); - } - else - { - $infoline = "\n***************************************************************\n"; - push(@installer::globals::globallogfileinfo, $infoline); - - $infoline = "$message\n"; - push(@installer::globals::globallogfileinfo, $infoline); - - $infoline = "in function: $function\n"; - push(@installer::globals::globallogfileinfo, $infoline); - - $infoline = "***************************************************************\n"; - push(@installer::globals::globallogfileinfo, $infoline); - - installer::files::save_file($installer::globals::logfilename ,\@installer::globals::globallogfileinfo); - } - installer::logger::print_error("$message\nin function: $function"); - print("ERROR, saved logfile $installer::globals::logfilename is:\n"); - open(LOG, "<", $installer::globals::logfilename); - print ": $_" while (<LOG>); - print "\n"; - close(LOG); - - installer::logger::stoptime(); + my $message = shift; - exit(-1); + croak $message; } 1; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits