ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/OneClickInstallWorker.ycp

{
	textdomain "oneclickinstall";

	import "OneClickInstall";
	import "OneClickInstallWorkerResponse";
	import "OneClickInstallWorkerFunctions";
	import "Popup";
	include "packager/inst_source_dialogs.ycp";
	import "PackageCallbacks";
	import "SlideShow";
	import "SlideShowCallbacks";
	import "PackageInstallation";
	import "PackageSlideShow";
	import "SourceManager";
	import "Progress";
	import "Wizard";

	list args = WFM::Args();
		
	string xmlFileName = args[0]:"";

	if (xmlFileName == "")
		return false;
	
	Wizard::CreateDialog();
	Wizard::SetDesktopIcon("sw_single");
	

	//Load the xml communication from the user interface.
	OneClickInstall::FromXML(xmlFileName);
	
	list<string> rurls = OneClickInstall::GetRequiredRepositories();
	list<string> rnames = [];
	foreach (string url, rurls, 
	{
		rnames = add(rnames,OneClickInstall::GetRepositoryName(url));
	});
	if (size(rnames) == 0)
		rnames = [_("Repositories")];

	//xxx add better stage and title when not in string freeze.
	Progress::New(_("Perform Installation"), "", 2, rnames, [], "");
	Progress::NextStage();

	boolean success = true;
	
	success = OneClickInstallWorkerFunctions::AddRepositories(OneClickInstall::GetRequiredRepositories());
	
	if (!success)
	{
		OneClickInstallWorkerResponse::SetFailureStage("Adding Repositories");
		OneClickInstallWorkerResponse::SetErrorMessage(_("An error occurred while attempting to subscribe to the required repositories. Review the yast2 logs for more information."));
	}

	Progress::NextStage();

	if (success)
	{
		SlideShow::SetLanguage (UI::GetLanguage(true));

		SlideShow::Setup( 
			[$[
            		"name" : "packages",
            		"description" : _("Installing Packages..."),
            		"value" : PackageSlideShow::total_size_to_install / 1024 , // kilobytes
            		"units" : `kb,
        	]]);
		SlideShow::ShowTable();
		SlideShow::OpenDialog();

		SlideShow::MoveToStage( "packages" );

		PackageInstallation::CommitPackages(0,0);

		//Remove any removals
		if (success && OneClickInstall::HaveRemovalsToInstall())
		{
			success = OneClickInstallWorkerFunctions::RemovePackages(OneClickInstall::GetRequiredRemoveSoftware());
			
			if (!success)
			{
				OneClickInstallWorkerResponse::SetFailureStage("Removing Packages");
				OneClickInstallWorkerResponse::SetErrorMessage(_("An error occurred while attempting to remove the specified packages. Review the yast2 logs for more information."));
			}
		}
		
	
		//if that was successful now try and install the patterns
		if (success && OneClickInstall::HavePatternsToInstall())
		{
			success = OneClickInstallWorkerFunctions::InstallPatterns(OneClickInstall::GetRequiredPatterns());
			
			if (!success)
			{
				OneClickInstallWorkerResponse::SetFailureStage("Installing Patterns");
				OneClickInstallWorkerResponse::SetErrorMessage(_("An error occurred while attempting to install the specified patterns. Review the yast2 logs for more information."));
			}
		}
	
	
		//if that was successful now try and install the packages
		if (success && OneClickInstall::HavePackagesToInstall())
		{
			success = OneClickInstallWorkerFunctions::InstallPackages(OneClickInstall::GetRequiredPackages());
			if (!success)
			{
				OneClickInstallWorkerResponse::SetFailureStage("Installing Packages");
				OneClickInstallWorkerResponse::SetErrorMessage(_("An error occurred while attempting to install the specified packages. Review the yast2 logs for more information."));
			}
		}
	
		SlideShow::CloseDialog();

	}

	//If we don't want to remain subscribed, remove the repositories that were added for installation.
	if (OneClickInstall::HaveRepositoriesToInstall() && !OneClickInstall::GetRemainSubscribed())
	{
		success = OneClickInstallWorkerFunctions::RemoveAddedRepositories();
		if (!success)
		{
			OneClickInstallWorkerResponse::SetFailureStage("Removing temporarily installed repositories.");
			OneClickInstallWorkerResponse::SetErrorMessage(_("An error occurred while attempting to unsubscribe from the repositories that were used to perform the installation. You can remove them manually in YaST > Software Repositories. Review the yast2 logs for more information."));
		}
	}

	OneClickInstallWorkerResponse::SetSuccess(success);

	if (success)
	{
		OneClickInstallWorkerResponse::SetFailureStage("No Failure");
		OneClickInstallWorkerResponse::SetErrorMessage(_("No error occurred."));
	}

	//Overwrite the information we were passed with our response back to the UI.
	OneClickInstallWorkerResponse::ToXML(xmlFileName);

	UI::CloseDialog();

	return success;
}

ACC SHELL 2018