ACC SHELL

Path : /usr/share/YaST2/clients/
File Upload :
Current File : //usr/share/YaST2/clients/add-on.ycp

/**
 * File:	clients/add-on.ycp
 * Package:	yast2-installation
 * Summary:	Install an add-on product
 * Authors:	Jiri Srain <jsrain@suse.de>
 *
 */

{
textdomain "add-on";

import "AddOnProduct";
import "Confirm";
import "PackageLock";
import "PackageCallbacksInit";
import "Report";
import "Wizard";
import "GetInstArgs";
import "Mode";
import "CommandLine";
import "Directory";
import "XML";

include "add-on/add-on-workflow.ycp";

list wfm_args = WFM::Args();
y2milestone ("ARGS: %1", wfm_args);

map <string, any> commands = CommandLine::Parse (wfm_args);
y2debug ("Commands: %1", commands);

// bnc #430852
if (commands["command"]:"" == "help" || commands["command"]:"" == "longhelp") {
    Mode::SetUI ("commandline");
    // TRANSLATORS: commandline help
    CommandLine::Print(_("
Add-On Module Help
------------------

To add a new add-on product via the command-line, use this syntax:
    /sbin/yast2 add-on URL
URL is the path to the add-on source.

Examples of URL:
http://server.name/directory/Lang-AddOn-10.2-i386/
ftp://server.name/directory/Lang-AddOn-10.2-i386/
nfs://server.name/directory/SDK1-SLE-i386/
disk://dev/sda5/directory/Product/CD1/
cd://
dvd://
"));
    return `auto;
} else if (commands["command"]:"" == "xmlhelp") {
    Mode::SetUI ("commandline");
    if (! haskey (commands["options"]:$[], "xmlfile")) {
	CommandLine::Print(_("Target file name ('xmlfile' option) is missing. Use xmlfile=<target_XML_file> command line option."));
	return `auto;
    } else {
	map doc = $[];

	doc["listEntries"] = $[
	    "commands": "command",
	    "options": "option",
	    "examples": "example",
	];
	doc["systemID"] = Directory::schemadir + "/commandline.dtd";
	doc["typeNamespace"] = "http://www.suse.com/1.0/configns";
	doc["rootElement"] = "commandline";
	XML::xmlCreateDoc(`xmlhelp, doc);

	map exportmap = $[
	    "module" : "add-on",
	];
	XML::YCPToXMLFile(`xmlhelp, exportmap, commands["options", "xmlfile"]:"");
	y2milestone("exported XML map: %1", exportmap);
	return `auto;
    }
}

Wizard::CreateDialog();

Wizard::SetContents (
    // dialog caption
    _("Add-On Products"),
    // busy message (dialog)
    `VBox(`Label(_("Initializing..."))),
    // help
    _("<p>Initializing add-on products...</p>"),
    false,
    false
);

Wizard::SetTitleIcon("vendor");

Wizard::DisableBackButton();
Wizard::DisableAbortButton();
Wizard::DisableNextButton();

// --> Initialization start

// check whether running as root
// and having the packager for ourselves
if (! Confirm::MustBeRoot () || ! PackageLock::Check ())
{
    UI::CloseDialog ();
    return `abort;
}

// initialize target to import all trusted keys (#165849)
Pkg::TargetInitialize ("/");
Pkg::TargetLoad();

PackageCallbacksInit::InitPackageCallbacks ();

// Initialize current sources
Read();
symbol ret = nil;

// <-- Initialization finish

Wizard::EnableAbortButton();
Wizard::EnableNextButton();

if (size (WFM::Args()) == 0)
{
    y2milestone ("Url not specified in cmdline, starting full-featured module");
    ret = RunAddOnsOverviewDialog();
}
else
{
    string url = (string)WFM::Args(0);
    y2milestone ("Specified URL %1", url);
    do {
	createResult = SourceManager::createSource (url);
	y2milestone ("Source creating result: %1", createResult);
    } while ( createResult == `again );
    AddOnProduct::last_ret = `next;
    ret = RunAutorunWizard ();
}

if (ret == `next) {
    Pkg::SourceSaveAll();
}

// bugzilla #293428
// Release all sources before adding a new one
// because of CD/DVD + url cd://
Pkg::SourceReleaseAll();

UI::CloseDialog();
return ret;

/* EOF */
}

ACC SHELL 2018