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 / modules / ProfileLocation.ycp < prev    next >
Text File  |  2006-11-29  |  4KB  |  164 lines

  1. /**
  2.  * File:    modules/ProfileLocation.ycp
  3.  * Package:    Auto-installation
  4.  * Summary:    Process Auto-Installation Location
  5.  * Author:    Anas Nashif <nashif@suse.de>
  6.  *
  7.  * $Id: ProfileLocation.ycp 27288 2006-01-24 14:29:15Z ug $
  8.  */
  9. {
  10.     module "ProfileLocation";
  11.     textdomain "autoinst";
  12.  
  13.     import "AutoinstConfig";
  14.     import "AutoInstallRules";
  15.     import "StorageDevices";
  16.     import "Mode";
  17.     import "Installation";
  18.     import "Popup";
  19.     import "Label";
  20.     import "URL";
  21.  
  22.  
  23.     include "autoinstall/autoinst_dialogs.ycp";
  24.     include "autoinstall/io.ycp";
  25.  
  26.  
  27.     /**
  28.      * Constructor
  29.      * @return void
  30.      */
  31.     global define void ProfileLocation ()
  32.         ``{
  33.         return;
  34.     }
  35.  
  36.  
  37.     /**
  38.      * Initiate retrieving of control files and Rules.
  39.      * @return boolean
  40.      */
  41.     global define boolean Process() ``{
  42.  
  43.         boolean ok = false;
  44.         boolean ret = false;
  45.  
  46.         y2milestone("Path to remote control file: %1", AutoinstConfig::filepath);
  47.  
  48.         string localfile  =  AutoinstConfig::xml_tmpfile;
  49.  
  50.         boolean is_directory = false;
  51.  
  52.         string filename = basename(AutoinstConfig::filepath);
  53.  
  54.  
  55.         if ( filename != "" )
  56.         {
  57.             y2milestone("File=%1", filename);
  58.             ret = Get(AutoinstConfig::scheme,
  59.                     AutoinstConfig::host,
  60.                     AutoinstConfig::filepath,
  61.                     localfile
  62.                     );
  63.             if (!ret)
  64.             {
  65.                 // autoyast hit an error while fetching it's config file
  66.                 string error = _("An error occurred while fetching the profile:\n");
  67.                 Popup::Error( error + GET_error );
  68.                 return false;
  69.             }
  70.         }
  71.         else
  72.         {
  73.             is_directory = true;
  74.         }
  75.  
  76.         AutoinstConfig::directory = dirname(AutoinstConfig::filepath);
  77.  
  78.         y2milestone("Dir=%1", AutoinstConfig::directory);
  79.         y2milestone("Fetching Rules File");
  80.  
  81.         // Get rules file
  82.  
  83.         boolean mkdir = (boolean)SCR::Execute(.target.mkdir, AutoinstConfig::local_rules_location);
  84.         if (!mkdir)
  85.         {
  86.             y2error("Error creating directory: %1", AutoinstConfig::local_rules_location );
  87.         }
  88.  
  89.         if (is_directory)
  90.         {
  91.             ret = Get(AutoinstConfig::scheme,
  92.                     AutoinstConfig::host,
  93.                     AutoinstConfig::directory + "/" +  AutoinstConfig::remote_rules_location ,
  94.                     AutoinstConfig::local_rules_file);
  95.         }
  96.         else
  97.         {
  98.             ret = false;
  99.         }
  100.  
  101.         if (ret)
  102.         {
  103.             AutoInstallRules::userrules = true;
  104.         }
  105.         else
  106.         {
  107.             AutoInstallRules::userrules = false;
  108.             SCR::Execute(.target.remove, AutoinstConfig::local_rules_file );
  109.         }
  110.  
  111.         boolean process_rules = true;
  112.         boolean try_default_rules = false;
  113.         if ( AutoInstallRules::userrules)
  114.         {
  115.             y2milestone("Reading Rules File");
  116.             AutoInstallRules::Read();
  117.             // returns false if no rules have matched
  118.             ret = AutoInstallRules::GetRules();
  119.             if (!ret)
  120.             {
  121.                 try_default_rules = true;
  122.             }
  123.         }
  124.         else
  125.         {
  126.                 try_default_rules = true;
  127.         }
  128.  
  129.         // Hex IP, MAC Address.
  130.         if (try_default_rules)
  131.         {
  132.             y2milestone("Creating default Rules");
  133.             if (is_directory)
  134.             {
  135.                 // Create rules for hex ip and mac address
  136.                 AutoInstallRules::CreateDefault();
  137.             }
  138.             else
  139.             {
  140.                 // Create rules for file
  141.                 AutoInstallRules::CreateFile( filename );
  142.             }
  143.             ret = AutoInstallRules::GetRules();
  144.             if (!ret)
  145.             {
  146.                 return false;
  147.             }
  148.         }
  149.  
  150.         if (process_rules)
  151.         {
  152.             boolean rulesret = AutoInstallRules::Process( AutoinstConfig::xml_tmpfile);
  153.             y2milestone("rulesret=%1", rulesret);
  154.             return rulesret;
  155.         }
  156.  
  157.         return true;
  158.     }
  159.  
  160.  
  161.  
  162.  
  163. }
  164.