Author: lslezak Date: Wed Oct 5 13:46:05 2011 New Revision: 66260 URL: http://svn.opensuse.org/viewcvs/yast?rev=66260&view=rev Log: backported commit #54940: - installation callbacks - collect installation data for the summary dialog (bnc#431854) - sw_single.ycp - do the action specified in PKGMGR_ACTION_AT_EXIT sysconfig variable when package installation is finished Modified: branches/tmp/lslezak/packager/src/clients/sw_single.ycp branches/tmp/lslezak/packager/src/modules/PackageInstallation.ycp branches/tmp/lslezak/packager/src/modules/PackageSlideShow.ycp Modified: branches/tmp/lslezak/packager/src/clients/sw_single.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/packager/src/clients/sw_single.ycp?rev=66260&r1=66259&r2=66260&view=diff ============================================================================== --- branches/tmp/lslezak/packager/src/clients/sw_single.ycp (original) +++ branches/tmp/lslezak/packager/src/clients/sw_single.ycp Wed Oct 5 13:46:05 2011 @@ -19,7 +19,6 @@ { textdomain "packager"; - import "Arch"; import "Confirm"; import "Installation"; import "Mode"; @@ -32,13 +31,14 @@ import "Wizard"; import "Popup"; import "GetInstArgs"; - import "Label"; import "PackageSystem"; import "Report"; import "FileUtils"; import "PackagesUI"; import "CommandLine"; import "Progress"; + import "Directory"; + import "String"; symbol StartSWSingle() { @@ -555,8 +555,57 @@ // prepare "you must boot" popup in inst_suseconfig Kernel::SetInformAboutKernelChange (oldvmlinuzsize != newvmlinuzsize); + string suseconfig_log = Directory::logdir + "/y2log.SuSEconfig"; + integer suseconfig_log_size = FileUtils::GetSize(suseconfig_log); + + if (suseconfig_log_size < 0) + { + suseconfig_log_size = 0; + } + result = (symbol) WFM::CallFunction ("inst_suseconfig", [GetInstArgs::Buttons(false, false)]); + + // read only the new lines at the end + string command = sformat("dd bs=1 if='%1' skip=%2", String::Quote(suseconfig_log), suseconfig_log_size); + y2milestone("Reading new susconfig log: %1", command); + + map out = (map)SCR::Execute(.target.bash_output, command); + if (out["exit"]:-1 == 0) + { + PackagesUI::SetPackageSummaryItem("postinstall_log", out["stdout"]:""); + } + else + { + y2error("Could not read susconfig log: %1", out); + } } + + if (Mode::normal()) + { + string PKGMGR_ACTION_AT_EXIT = (string)SCR::Read(.sysconfig.yast2.PKGMGR_ACTION_AT_EXIT); + + if (PKGMGR_ACTION_AT_EXIT == nil) + { + PKGMGR_ACTION_AT_EXIT = "close"; + } + + y2milestone("PKGMGR_ACTION_AT_EXIT: %1", PKGMGR_ACTION_AT_EXIT); + + // display installation summary if there has been an error + // or if it's enabled in sysconfig + if (PKGMGR_ACTION_AT_EXIT == "summary" + || size(commit_result[1]:[]) > 0) + { + if (PackagesUI::ShowInstallationSummary() == `back) + { + force_restart = true; + } + } + else if (PKGMGR_ACTION_AT_EXIT == "restart") + { + force_restart = true; + } + } } } while ( force_restart ); Modified: branches/tmp/lslezak/packager/src/modules/PackageInstallation.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/packager/src/modules/PackageInstallation.ycp?rev=66260&r1=66259&r2=66260&view=diff ============================================================================== --- branches/tmp/lslezak/packager/src/modules/PackageInstallation.ycp (original) +++ branches/tmp/lslezak/packager/src/modules/PackageInstallation.ycp Wed Oct 5 13:46:05 2011 @@ -17,6 +17,7 @@ import "Packages"; import "SlideShow"; import "PackageSlideShow"; + import "PackagesUI"; import "Label"; @@ -129,6 +130,8 @@ PackageSlideShow::UpdateAllCdProgress (false); SlideShow::StartTimer(); + integer start_time = time(); + list commit_result = []; // returns [ int successful, list failed, list remaining, list srcremaining ] y2milestone ("Calling Pkg::Commit (%1)", config); @@ -142,6 +145,9 @@ return []; } + integer installation_time = time() - start_time; + y2milestone("Installation took %1 seconds", installation_time); + // see if installation of some packages failed list<string> errpacks = (list<string>) (commit_result[1]:[]); if (size (errpacks) > 0) @@ -160,6 +166,25 @@ merge (old_failed_packs, errpacks)); } + if (Mode::normal()) + { + // collect and set installation summary data + map<string,any> summary = PackageSlideShow::GetPackageSummary(); + + summary["time_seconds"] = installation_time; + summary["success"] = size(errpacks) == 0; + summary["remaining"] = commit_result[2]:[]; + summary["install_log"] = SlideShow::inst_log; + + if (size(errpacks) > 0) + { + summary["error"] = Pkg::LastError(); + summary["failed"] = errpacks; + } + + PackagesUI::SetPackageSummary(summary); + } + return commit_result; }; Modified: branches/tmp/lslezak/packager/src/modules/PackageSlideShow.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/lslezak/packager/src/modules/PackageSlideShow.ycp?rev=66260&r1=66259&r2=66260&view=diff ============================================================================== --- branches/tmp/lslezak/packager/src/modules/PackageSlideShow.ycp (original) +++ branches/tmp/lslezak/packager/src/modules/PackageSlideShow.ycp Wed Oct 5 13:46:05 2011 @@ -50,6 +50,57 @@ string provide_name = ""; // currently downlaoded package name string provide_size = ""; // currently downlaoded package size + // package summary + // package counters + integer installed_packages = 0; + integer updated_packages = 0; + integer removed_packages = 0; + + integer total_downloaded = 0; + integer total_installed = 0; + + // package list (only used in installed system) + list<string> installed_packages_list = []; + list<string> updated_packages_list = []; + list<string> removed_packages_list = []; +// integer avg_download_rate = 0; + + integer current_provide_size = 0; + integer current_install_size = 0; + string current_pkg_name = ""; + boolean updating = false; + + void ResetPackageSummary() + { + installed_packages = 0; + updated_packages = 0; + removed_packages = 0; + total_downloaded = 0; + total_installed = 0; +// avg_download_rate = 0; + + // temporary values + current_provide_size = 0; + current_install_size = 0; + current_pkg_name = ""; + updating = false; + } + + global map<string,any> GetPackageSummary() + { + return $[ + "installed" : installed_packages, + "updated" : updated_packages, + "removed" : removed_packages, + "installed_list" : installed_packages_list, + "updated_list" : updated_packages_list, + "removed_list" : removed_packages_list, + "downloaded_bytes" : total_downloaded, + "installed_bytes" : total_installed, + ]; + } + + /*****************************************************************************/ /*************** Formatting functions and helpers ***************************/ /*****************************************************************************/ @@ -176,41 +227,6 @@ return total_size_to_install - TotalRemainingSize(); } - - /** - * Format an integer number as (at least) two digits; use leading zeroes if - * necessary. - * @return number as two-digit string - **/ - string FormatTwoDigits( integer x ) - { - return x < 10 && x >= 0 ? - sformat( "0%1", x ) : - sformat( "%1", x ); - } - - - /** - * Format an integer seconds value with min:sec or hours:min:sec - **/ - string FormatTime( integer seconds ) - { - if ( seconds < 0 ) - return ""; - - if ( seconds < 3600 ) // Less than one hour - { - return sformat( "%1:%2", FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) ); - } - else // More than one hour - we don't hope this will ever happen, but who knows? - { - integer hours = seconds / 3600; - seconds = seconds % 3600; - return sformat( "%1:%2:%3", hours, FormatTwoDigits( seconds / 60 ), FormatTwoDigits( seconds % 60 ) ); - } - } - - /** * Format an integer seconds value with min:sec or hours:min:sec * @@ -227,11 +243,11 @@ // cut off the predicted time at a reasonable maximum. // "%1" is a predefined maximum time. - text = sformat( _(">%1"), FormatTime( -seconds ) ); + text = sformat( _(">%1"), String::FormatTime( -seconds ) ); } else { - text = FormatTime( seconds ); + text = String::FormatTime( seconds ); } return text; @@ -297,7 +313,7 @@ // %2: Media name ("SuSE Linux Professional CD 2" ) // %3: Time remaining until this media will be needed text = sformat( _("Next %1: %2 -- %3"), media_type, next_media_name, - FormatTime( remaining_times_per_cd_per_src[ current_src_no-1, current_cd_no-1 ]: 1) ); + String::FormatTime( remaining_times_per_cd_per_src[ current_src_no-1, current_cd_no-1 ]: 1) ); } else { @@ -445,6 +461,7 @@ if ( init_pkg_data_complete && ! force) return; + ResetPackageSummary(); // Reinititalize some globals (in case this is a second run) total_size_installed = 0; //total_time_elapsed = 0; @@ -923,7 +940,7 @@ if ( unit_is_seconds && bytes_per_second > 0 ) { remaining = remaining / bytes_per_second; - rem_time = FormatTime( remaining ); // column #2 + rem_time = String::FormatTime( remaining ); // column #2 if ( remaining > max_time_per_cd ) // clip off at 2 hours { @@ -971,6 +988,8 @@ // update the download rate global void UpdateCurrentPackageRateProgress(integer pkg_percent, integer bps_avg, integer bps_current) { +// avg_download_rate = bps_avg; + if( ! SlideShow::ShowingDetails() ) return; string new_text = nil; // no update of the label @@ -1023,6 +1042,13 @@ SlideShow::UpdateTable( CdStatisticsTableItems() ); } + global void DoneProvide( integer error, string reason, string name ) + { + if (error == 0) + { + total_downloaded = total_downloaded + current_provide_size; + } + } /** * Return a CD's progress bar ID @@ -1063,8 +1089,37 @@ UpdateTotalProgress(false); + if (updating) + { + updated_packages = updated_packages + 1; + + if (Mode::normal()) + { + updated_packages_list = add(updated_packages_list, current_pkg_name); + } + } + else + { + installed_packages = installed_packages + 1; + + if (Mode::normal()) + { + installed_packages_list = add(installed_packages_list, current_pkg_name); + } + } + + total_installed = total_installed + current_install_size; + } // ! deleting + else + { + removed_packages = removed_packages + 1; + if (Mode::normal()) + { + removed_packages_list = add(removed_packages_list, current_pkg_name); + } + } } @@ -1117,12 +1172,17 @@ // Heading for the progress bar for the current package // while it is deleted. "%1" is the package name. msg = sformat( _("Deleting %1"), pkg_name ); + current_pkg_name = pkg_name; } else { + updating = Pkg::PkgInstalled(current_pkg_name); + // package installation - summary text // %1 is RPM name, %2 is installed (unpacked) size (e.g. 6.20MB) msg = sformat( _("Installing %1 (installed size %2)"), pkg_name, String::FormatSize( pkg_size ) ); + + current_install_size = pkg_size; } @@ -1206,6 +1266,9 @@ */ global void SlideProvideStart (string pkg_name, integer sz, boolean remote) { + current_provide_size = remote ? sz : 0; + current_pkg_name = pkg_name; + if (remote) { // message in the installatino log, %1 is package name, -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org