home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / root / usr / share / YaST2 / clients / inst_autopost.ycp < prev    next >
Text File  |  2006-11-29  |  6KB  |  181 lines

  1. /**
  2.  * File:    clients/autoinst_post.ycp
  3.  * Package:    Auto-installation
  4.  * Author:      Anas Nashif <nashif@suse.de>
  5.  * Summary:    This module finishes auto-installation and configures
  6.  *        the system as described in the profile file.
  7.  *
  8.  * $Id: inst_autopost.ycp 32929 2006-09-18 13:01:18Z ug $
  9.  */
  10.  
  11. {
  12.     textdomain "autoinst";
  13.     import "Profile";
  14.     import "AutoInstall";
  15.     import "AutoinstGeneral";
  16.     import "Call";
  17.     import "Y2ModuleConfig";
  18.     import "AutoinstSoftware";
  19.     import "AutoinstScripts";
  20.     import "Report";
  21.     import "Progress";
  22.     include "autoinstall/ask.ycp";
  23.  
  24.     y2debug("Profile=%1", Profile::current );
  25.     Report::Import(Profile::current["report"]:$[]);
  26.  
  27.     define void Step (string s) {
  28.         Progress::NextStep();
  29.         Progress::Title(sformat(_("Checking for packages required for %1..."), s));
  30.         return;
  31.     }
  32.  
  33.     list<string> packages = [];
  34.     string resource = "";
  35.     string module_auto = "";
  36.  
  37.     if (Profile::current["report"]:$[] != $[])
  38.         Report::Import(Profile::current["report"]:$[]);
  39.  
  40.  
  41.     string help_text = _("<p>
  42. Please wait while the system is prepared for autoinstallation.</p>
  43. ");
  44.     list<string> progress_stages =
  45.     [
  46.      _("Install required packages"),
  47.      ];
  48.  
  49.     integer steps = size(filter(string p, map d, Y2ModuleConfig::ModuleMap, ``( 
  50.     (d["X-SuSE-YaST-AutoInst"]:"" == "all" || 
  51.          d["X-SuSE-YaST-AutoInst"]:"" == "write") &&
  52.         haskey(Profile::current, d["X-SuSE-YaST-AutoInstResource"]:p)  )));
  53.  
  54.  
  55.     steps = steps + 3;
  56.  
  57.     Progress::New(
  58.           _("Preparing System for Automatic Installation"),
  59.           "",     // progress_title
  60.           steps ,    // progress bar length
  61.           progress_stages,
  62.           [],
  63.           help_text );
  64.     Progress::NextStage();
  65.     Progress::Title(_("Checking for required packages..."));
  66.  
  67.     askDialog();
  68.     /* FIXME: too late here, even though it would be the better place */
  69.     /*
  70.     if (Profile::current["general"]:$[] != $[])
  71.         AutoinstGeneral::Import(Profile::current["general"]:$[]);
  72.     AutoinstGeneral::SetSignatureHandling();
  73.     */
  74.  
  75.     y2milestone("Steps: %1", steps );
  76.  
  77.     foreach(string p, map d, Y2ModuleConfig::ModuleMap,
  78.         ``{
  79.  
  80.     if (d["X-SuSE-YaST-AutoInst"]:"" == "all"
  81.             || d["X-SuSE-YaST-AutoInst"]:"" == "write")
  82.     {
  83.         if (haskey(d,"X-SuSE-YaST-AutoInstResource") &&
  84.                 d["X-SuSE-YaST-AutoInstResource"]:"" != "" )
  85.         resource = d["X-SuSE-YaST-AutoInstResource"]:"unknown";
  86.         else
  87.         resource = p;
  88.  
  89.         y2milestone("current resource: %1", resource);
  90.  
  91.         // determine name of client, if not use default name
  92.         if (haskey(d,"X-SuSE-YaST-AutoInstClient"))
  93.         module_auto = d["X-SuSE-YaST-AutoInstClient"]:"none";
  94.         else
  95.         module_auto = sformat("%1_auto", p);
  96.  
  97.         map result = $[];
  98.  
  99.         if (haskey(Profile::current , resource) )
  100.         {
  101.         y2milestone("Importing configuration for %1", p);
  102.         string tomerge = d["X-SuSE-YaST-AutoInstMerge"]:"";
  103.         string tomergetypes = d["X-SuSE-YaST-AutoInstMergeTypes"]:"";
  104.         list MergeTypes = splitstring(tomergetypes, ",");
  105.  
  106.         if (  size(tomerge) > 0 )
  107.         {
  108.             integer i = 0;
  109.             foreach( string res, splitstring(tomerge, ",") ,
  110.                  ``{
  111.             if ( MergeTypes[i]:"map" == "map")
  112.                 result[res] = Profile::current[res]:$[];
  113.             else
  114.                 result[res] = Profile::current[res]:[];
  115.             i = i + 1;
  116.             });
  117.             if( d["X-SuSE-YaST-AutoLogResource"]:"true" == "true" ) {
  118.                 y2milestone("Calling auto client with: %1", result);
  119.             } else {
  120.                 y2milestone("logging for resource %1 turned off",resource);
  121.                 y2debug("Calling auto client with: %1", result);
  122.             }
  123.             if (size(result) > 0 )
  124.                     {
  125.                         Step(p);
  126.                 Call::Function(module_auto, ["Import", eval(result) ]);
  127.                     map out = (map)Call::Function(module_auto, ["Packages" ]);
  128.                     packages = (list<string>) union(packages, out["install"]:[]);
  129.                     }
  130.         }
  131.         else if (d["X-SuSE-YaST-AutoInstDataType"]:"map" == "map")
  132.         {
  133.             if( d["X-SuSE-YaST-AutoLogResource"]:"true" == "true" ) {
  134.                 y2milestone("Calling auto client with: %1",  eval(Profile::current[resource]:$[]));
  135.             } else {
  136.                 y2milestone("logging for resource %1 turned off",resource);
  137.                 y2debug("Calling auto client with: %1",  eval(Profile::current[resource]:$[]));
  138.             }
  139.             if (size(Profile::current[resource]:$[]) > 0 )
  140.                     {
  141.                         Step(p);
  142.                 Call::Function(module_auto, ["Import", eval(Profile::current[resource]:$[])   ]);
  143.                     map out = (map)Call::Function(module_auto, ["Packages" ]);
  144.                     packages = (list<string>) union(packages, out["install"]:[]);
  145.                     }
  146.         }
  147.         else
  148.         {
  149.             if (size(Profile::current[resource]:[]) > 0 )
  150.                     {
  151.                         Step(p);
  152.                 Call::Function(module_auto, ["Import",  eval(Profile::current[resource]:[]) ]);
  153.                     map out = (map)Call::Function(module_auto, ["Packages" ]);
  154.                     packages = (list<string>) union(packages, out["install"]:[]);
  155.                     }
  156.         }
  157.             }
  158.         }
  159.     });
  160.  
  161.     // Add all found packages
  162.     Progress::NextStep();
  163.     Progress::Title(_("Adding found packages..."));
  164.     AutoinstSoftware::addPostPackages(packages);
  165.  
  166.     // Run early network scripts
  167.     Progress::NextStep();
  168.     Progress::Title(_("Running scripts..."));
  169.     AutoinstScripts::Import(Profile::current["scripts"]:$[]);
  170.     AutoinstScripts::Write("post-scripts", true);
  171.  
  172.  
  173.     // Finish
  174.     Progress::NextStage();
  175.     Progress::Finish();
  176.  
  177.     y2milestone("Finished required package collection");
  178.  
  179.     return `auto;
  180. }
  181.