/**
 * This client starts a custom  autoinstallation workflow using
 * a stripped down control file and an autoyast profile.
 * first argument is the autoyast profile, second is the workflow 
 * control file.
 * see a test workflow control file in the same directory
 */

{
    import "XML";
    import "Profile";
    import "AutoInstall";
    import "ProductControl";

    import "Wizard";
    import "Popup";
    import "Mode";
    import "Stage";

    Mode::SetMode ("autoinstallation");
    Stage::Set ("continue");

    string control = "";
    string profile = "";
    if (size (WFM::Args ()) > 0 && (is (WFM::Args(0), string)) && (is (WFM::Args(1), string)))
    {
        profile  = (string)WFM::Args(0);
        control  = (string)WFM::Args(1);
    }

    ProductControl::custom_control_file = control;
    if (!ProductControl::Init())
    {
        y2error("control file %1 not found", ProductControl::custom_control_file );
        return `abort;
    }

    Profile::ReadXML(  profile );

    Wizard::OpenNextBackStepsDialog();
    list<map> stage_mode = [$["stage": "continue",  "mode": Mode::mode () ]];
    ProductControl::AddWizardSteps(stage_mode);

    symbol ret = ProductControl::Run();

    Pkg::SourceFinishAll();
    Pkg::TargetFinish();

    UI::CloseDialog();
    return ret;

}
