home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 May / Chip_2000-05_cd2.bin / suse / inst-sys / lib / YaST2 / clients / inst_finish.ycp < prev    next >
Encoding:
Text File  |  2000-03-30  |  22.1 KB  |  666 lines

  1. /**
  2.  *
  3.  * $Id: inst_finish.ycp,v 1.158.4.2 2000/03/27 15:28:27 kkaempf Exp $
  4.  *
  5.  * Module:    inst_finish.ycp
  6.  *
  7.  * Author:    Klaus KΣmpf
  8.  *         Mathias Kettner
  9.  *
  10.  * Purpose:    This module finishes the installation, writes
  11.  *         some files (rc_config fstab ... and so on).
  12.  *
  13.  * user_settings:
  14.  * ro:  entire user_settings  
  15.  * ro: "mouse"
  16.  * ro: "rpassword"
  17.  * ro: "targets"
  18.  * ro: "keyboard"
  19.  * ro: "softwaresel"
  20.  * ro: "language"
  21.  * ro: "timezone"
  22.  * ro: "mouse"
  23.  * ro: "console_font"
  24.  * ro: "console_screenmap"
  25.  * ro: "console_unicodemap"
  26.  * ro: "console_magic"
  27.  * ro: "alldisks"
  28.  * ro: "whole_disk"
  29.  * ro: "loginname"
  30.  * ro: "upassword"
  31.  * ro: "have_x11"
  32.  * ro: "root_device"
  33.  * ro: "swap_device"
  34.  * ro: "modules"
  35.  * 
  36.  * "rw" read/write
  37.  * "ro" readonly 
  38.  
  39.  * Writes:
  40.  * /mnt/var/lib/YaST2/runme_at_boot      run yast2 after initial boot
  41.  * /mnt/var/lib/YaST2/settings.ycp      save settings 
  42.  * /mnt/var/lib/YaST2/hwprobe.ycp     
  43.  * `Write(.etc.shadow.root,
  44.  * `Write(.etc.rcconfig,
  45.  * `Write(.etc.rcconfig.sendmailconfig,
  46.  * `Write(.mnt.etc.fstab,
  47.  * `Write(.yast2.inf.rootpart,
  48.  * `Write(.yast2.inf.swappart,
  49.  */
  50. {
  51.     string architecture = lookup (user_settings, "architecture", default_architecture);
  52.  
  53.     // --------------------------------------------------------------
  54.     // Tell new boot scripts to launch yast2, once the
  55.     // new system has done its virgin boot. The Write call
  56.     // creates any missing directory :-). Also write the
  57.     // user settings to a file. This file is readably only for root!
  58.     // It contains a root password (in crypted form).
  59.  
  60.     Write("/mnt/var/lib/YaST2/runme_at_boot", nil);
  61.     Write("/mnt/var/lib/YaST2/settings.ycp", user_settings, 0600);
  62.     SCR(`Write(.dumpto.mnt.var.lib.YaST2.hwprobe, SCR(`Read(.probe.byclass))));
  63.  
  64.     // debug
  65.     SCR(`Write(.dumpto.mnt.var.lib.YaST2.user_settings, user_settings));
  66.  
  67.     // --------------------------------------------------------------
  68.     // Inform YaST1 about the installation image
  69.  
  70.     SCR(`Write(.mnt.var.lib.yast.installinf, "MediaInfo: 2 /dev/cdrom"));
  71.     SCR(`Write(.mnt.var.lib.yast.systeminf, "ELF=\"1\"\nHAS_LIVE_CD=\"1\""));
  72.  
  73.     // generate /mnt/var/lib/YaST/update.inf from /tmp/info and /tmp/update.in_
  74.     if (0 != Shell ("create_update_inf"))
  75.     _debug("Couldn't create update.info");
  76.  
  77.     // --------------------------------------------------------------
  78.     // Create mount point for YaST1
  79.  
  80.     Mkdir("/mnt/var/adm/mount");
  81.  
  82.  
  83.     // --------------------------------------------------------------
  84.     // Symlink (/mnt)/dev/cdromX to all real cdrom devices
  85.  
  86.     list cddevices = [];
  87.  
  88.     // link /dev/cdrom -> /dev/sr0 (/dev/hdb or whatever)
  89.  
  90.     define symlink_cdrom (map cdinfo, integer number) ``{
  91.     string cddevice = lookup (cdinfo, "dev_name", "");
  92.     string linkname = "/dev/cdrom";
  93.     if (number > 0)
  94.       linkname = linkname + number;
  95.  
  96.     cddevices = add (cddevices, linkname);
  97.  
  98.     if (cddevice != "") {
  99.         y2log (.debug, "inst_finish", 1, sformat("Generating symlink: %1 -> %2", cddevice, linkname));
  100.         Symlink (cddevice, "/mnt" + linkname);
  101.     }
  102.     };
  103.  
  104.     integer cdnum = 0;
  105.     list cddrives = SCR(`Read(.probe.byclass.storage_device.cdrom));
  106.     foreach (`drive, cddrives, ``{
  107.     symlink_cdrom (drive, cdnum);
  108.     cdnum = cdnum + 1;
  109.     });
  110.  
  111.     // --------------------------------------------------------------
  112.     // Symlink (/mnt)/dev/mouse to real mouse device
  113.  
  114.     map mouseinfo = lookup (user_settings, "mouse", $[]);
  115.     string mousedevice = lookup (mouseinfo, "device", "");
  116.     string gpm_param = "";
  117.     if (mousedevice != "") {
  118.         Symlink (mousedevice, "/mnt/dev/mouse");
  119.  
  120.     // if we have a mouse device, set gpm_param
  121.     gpm_param = lookup (mouseinfo, "gpm", "");
  122.     if (gpm_param != "")
  123.         gpm_param = "-t " + gpm_param + " -m /dev/mouse";
  124.     }
  125.  
  126.  
  127.     // --------------------------------------------------------------
  128.     // Set root password
  129.  
  130.     if (!SCR(`Write(.etc.shadow.root, lookup(user_settings, "rpassword", ""))))
  131.     {
  132.       // Error msg
  133.       UI(`DisplayMessage(_("\
  134. The root password could not be set!\n\
  135. You won't be able to login!")));
  136.     }
  137.  
  138.  
  139.     // --------------------------------------------------------------
  140.     // get targets
  141.     // first build map of module names (remove duplicates)
  142.     // then make list of modules as string
  143.     // FIXME: should only include module needed for root-device
  144.  
  145.     map moduleMap = lookup (user_settings, "modules", $[]);
  146.  
  147.     list modules_name = [];
  148.     list modules_conf = [];
  149.     // collect module names and modules.conf entries
  150.     foreach (`mname, `mconf, moduleMap, ``{
  151.     if ((mname != "")
  152.        && (!contains (modules_name, mname)))
  153.         modules_name = add (modules_name, mname);
  154.     if ((mconf != "")
  155.        && (!contains (modules_conf, mconf)))
  156.         modules_conf = add (modules_conf, mconf);
  157.     });
  158.  
  159.     // make module names to one long string
  160.     // start with modules from linuxrc
  161.  
  162.     map install_inf = SCR(`Read(.etc.install_inf));
  163.     list initrdmodules = lookup (install_inf, "initrd_modules", []);
  164.     foreach (`mname, modules_name, ``{
  165.         if (!contains (initrdmodules, mname))
  166.         initrdmodules = add (initrdmodules, mname);
  167.     });
  168.  
  169.     string confmodules = "";
  170.     string install_alias = lookup (install_inf, "alias", "");
  171.     if (install_alias != "")
  172.     confmodules = "alias "+install_alias+"\n";
  173.  
  174.     string start_usb = "no";
  175.     integer usb_type = lookup (user_settings, "usb_type", 0);
  176.     // 1 (uhci) oder 2 (ohci) 
  177.     if (usb_type == 1) {
  178.     if (!contains (initrdmodules, "usbcore"))
  179.         initrdmodules = add (initrdmodules, "usbcore");
  180.     start_usb = "yes";
  181.     confmodules = confmodules + "alias usb-hostadapter usb-uhci\n";
  182.     }
  183.     else if (usb_type == 2) {
  184.     if (!contains (initrdmodules, "usbcore"))
  185.         initrdmodules = add (initrdmodules, "usbcore");
  186.     start_usb = "yes";
  187.     confmodules = confmodules + "alias usb-hostadapter usb-ohci-hcd\n";
  188.     }
  189.  
  190.     // make modules.conf entries as one string with \n
  191.  
  192.     foreach (`mconf, modules_conf, ``{
  193.     confmodules = confmodules + mconf + "\n";
  194.     });
  195.  
  196.     // now re-construct string of modules for initrd
  197.  
  198.     string rc_initrd = "";
  199.     foreach (`mname, initrdmodules, ``{
  200.     if (rc_initrd != "")
  201.         rc_initrd = rc_initrd + " ";
  202.     rc_initrd = rc_initrd + mname;
  203.     });
  204.  
  205.     y2log (.milestone, "inst_finish", 1, sformat("Modules for the initrd:  %1", initrdmodules));
  206.     y2log (.milestone, "inst_finish", 2, sformat("Entries in modules.conf: %1", confmodules));
  207.     y2log (.milestone, "inst_finish", 3, sformat("Entries in rc.config: %1", rc_initrd));
  208.  
  209.     // if needed, re-write /etc/modules.conf
  210.  
  211.     if (confmodules != "") {
  212.     WriteString ("/tmp/add-modules.conf",
  213.       "# Added by YaST2, do not change\n"
  214.       + confmodules
  215.       + "# End of YaST2 additions\n");
  216.     Shell ("cat /mnt/etc/modules.conf /tmp/add-modules.conf > /tmp/new-modules.conf");
  217.     Shell ("cp /tmp/new-modules.conf /mnt/etc/modules.conf");
  218.     }
  219.  
  220.     // --------------------------------------------------------------
  221.     // get console keyboard
  222.  
  223.     string keyboard_name = lookup (user_settings, "keyboard", "english-us");
  224.     list keyboard_desc = lookup (ReadY2("keyboard.ycp"), keyboard_name, []);
  225.     string console_keyboard = lookup (select (keyboard_desc, 1), "ncurses", "qwerty/us.map.gz" );
  226.  
  227.  
  228.     // --------------------------------------------------------------
  229.     // check for Kde vs. Gnome, see inst_xf86config
  230.  
  231.     list current_sel     = lookup(user_settings, "softwaresel", []);
  232.     string default_wm = "kde";
  233.     if (contains (current_sel, .Minimal)
  234.     && contains (current_sel, .Gnome)
  235.     && (!contains (current_sel, .Kde)))
  236.       default_wm = "gnome";
  237.  
  238.     string rc_lang = lookup(user_settings, "language", default_language);
  239.  
  240.     map lang2yast1 = $[
  241.       "en_GB"    : "english",
  242.       "en_US"    : "english",
  243.       "en"     : "english",
  244.       "de_DE"    : "german",
  245.       "de_CH"    : "german",
  246.       "de"      : "german",
  247.       "br_FR"    : "french",
  248.       "fr_FR"    : "french",
  249.       "fr_CH"    : "french",
  250.       "fr"       : "french",
  251.       "it_IT"    : "italian",
  252.       "es_ES"    : "spanish",
  253.       "nl_NL"    : "dutch",
  254.       "pt_PT"    : "portuguese",
  255.       "pt_BR"    : "brazilian",
  256.       "hu_HU"    : "hungarian",
  257.       "pl_PL"    : "polish",
  258.       "el_GR"    : "greek",
  259.       "ru_RU.KOI8-R" : "russian",
  260.       "cs_CZ"    : "czech",
  261.       "sk_SK"    : "slovak"
  262.     ];
  263.  
  264.     string lang4yast1 = lookup(lang2yast1, rc_lang, "english");
  265.  
  266.     string start_gpm = "yes";
  267.     if (lookup (user_settings, "mouse", $[]) == $[])
  268.     start_gpm = "no";
  269.  
  270.     // Set default values in rc.config + timezone + mouse
  271.     map varmap = $[
  272.     "KEYTABLE" : [ console_keyboard, "Keyboard mapping for the text console."],
  273.     "GMT" : [ "", "Set to \"-u\" if your system clock is set to GMT, otherwise \"\"."],
  274.     "START_INETD" : [ "yes", "Start the inet daemon in multi-user? (\"yes\" or \"no\")"],
  275.     "START_PORTMAP" : [ "yes", "Start portmap? (\"yes\" or \"no\") Needed for nfsserver or NIS"],
  276.     "START_USB" : [ start_usb, "Start USB module ?"],
  277.     "NETCONFIG" : [ "", "Number of network cards: \"_0\" for one, \"_0 _1 _2 _3\" for four cards" ],
  278.     "NFS_SERVER" : [ "no", "Should the NFS server be started on this host? (\"yes\" or \"no\")"],
  279.     "START_GPM" :  [ start_gpm, "Should gpm be started on this machine? (\"yes\" or \"no\")"],
  280.     "GPM_PARAM" : [ gpm_param, "gpm will be started in runlevel 2 with this parameters" ],
  281.     "FQHOSTNAME" : [ "linux.local", "The fully qualfied hostname of this computer"],
  282.     "SEARCHLIST" : [ "local", "Domain searchlist that should be used in /etc/resolv.conf" ],
  283.     "NAMESERVER" : [ "", "Space separated list of nameservers that should be used for /etc/resolv.conf" ],
  284.     "LANGUAGE" : [ lang4yast1, "The language setting for the old YaST"],
  285.     "RC_LANG"  : [ rc_lang, "The language setting for the old YaST"],
  286.     "TIMEZONE" : [ lookup(user_settings, "timezone", "Europe/Berlin"), "The timezone setting"],
  287.     "MOUSE"    : [ lookup(lookup(user_settings, "mouse", $[ "device":"/dev/psaux" ]), "device", "/dev/psaux"), "The Unix device for the mouse" ],
  288.     "INITRD_MODULES" : [ rc_initrd, "The module for initrd during boot" ],
  289.     "DEFAULT_WM" : [ default_wm, "run kde or gnome as default wm" ],
  290.     "USE_KERNEL_NFSD" : [ "yes", "should the kernel based NFS server be started on this host"], 
  291.     "CONSOLE_FONT" :        [ lookup(user_settings, "console_font", ""), "Load this console font upon bootup:" ],
  292.     "CONSOLE_SCREENMAP" :   [ lookup(user_settings, "console_screenmap", ""), "Does your console font need a screenmap? Insert it into CONSOLE_SCREENMAP."],
  293.     "CONSOLE_UNICODEMAP" :  [ lookup(user_settings, "console_unicodemap", ""), "some fonts/keymap need a unicode map (TRANSLATION in former releases)." ],
  294.     "CONSOLE_MAGIC" :    [ lookup(user_settings, "console_magic", ""), "special magic to switch console" ]
  295.       ];
  296.  
  297.     if (!SCR(`Write(.etc.rcconfig, varmap))) {
  298.       // Error msg
  299.       UI(`DisplayMessage(_("Couldn't write values to /etc/rc.config")));
  300.     }
  301.  
  302.  
  303.     // --------------------------------------------------------------
  304.     // Set default value for sendmail.rc.config
  305.     varmap = $[
  306.     "FROM_HEADER" : [ "", "From:-Line in email and News postings"],
  307.     "SENDMAIL_TYPE" : [ "yes", "generate sendmail.cf from parameters in rc.config"]
  308.     ];
  309.  
  310.     if (!SCR(`Write(.etc.rcconfig.sendmailconfig, varmap))) {
  311.       // Error msg
  312.       UI(`DisplayMessage(_("Couldn't write values to /etc/rc.config.d/sendmail.rc.config")));
  313.     }
  314.  
  315.  
  316.     // --------------------------------------------------------------
  317.     // Write fstab
  318.     //
  319.     // data:    targets
  320.     //        cddevices
  321.     //
  322.  
  323.     // filesystems for /dos
  324.     list fsid_dostypes = [ 1, 4 ];        /* FAT12, FAT16  */
  325.     // filesystems for /windows
  326.     list fsid_wintypes = [ 6, 11, 12, 14 ];    /* FAT32, Win95-Fat32, Win95LBA, Win95-Fat16  */
  327.     list fsid_ntfstypes = [ 7 ];        /* NTFS  */
  328.     // filesystems mounted read-only
  329.     list fsid_readonly = [ 7 ];
  330.  
  331.     // check partitions list for primary partitions with dos/win id
  332.     // returns list of [ partition-device, partition-name ] entries
  333.     // target is "/dev/?da" (i.e. full device, w/o paritition numbers)
  334.  
  335.     // The filesystem ids for the FAT partitions
  336.     integer fsid_empty = 0;
  337.     integer fsid_native = 131;
  338.     integer fsid_swap = 130;
  339.     integer fsid_extended = 5;
  340.  
  341.     list fstab = [];
  342.     integer other_nr = 1;        // count other mounts
  343.     integer foreign_nr = 0;        // count dos/win mounts
  344.     string foreign_ids = "CDEFGHIJKLMNOPQRSTUVW";
  345.  
  346.     string foreign_primary = "";    // might be windows boot partition
  347.     string cmd4boot_message = "";    // cmd for /boot/message to explain lilo options
  348.  
  349.     if (architecture != "i386")
  350.     foreign_primary = "X";
  351.  
  352.     // convert partitions to fstab entries
  353.     // return map (might be empty)
  354.  
  355.     define onepartition2fstab (string device, map partition) ``{
  356.     if (lookup (partition, "delete", false)
  357.         || (lookup (partition, "type") == `extended))
  358.         return $[];
  359.  
  360.     string spec = device + lookup (partition, "nr");
  361.     string file = lookup (partition, "mount", "");
  362.     integer fsid = lookup (partition, "fsid", 0);
  363.     symbol used_fs = lookup (partition, "used_fs", `ext2);
  364.     string vfstype = "unknown";
  365.     integer freq = 0;
  366.     integer passno = 0;
  367.     string mntops = "defaults";
  368.  
  369.     if (file == "/")
  370.         passno = 1;
  371.     else if (file != "")
  372.         passno = 2;
  373.  
  374.     if (fsid == fsid_swap) {
  375.         // Only use our new swap partition
  376.         if (file == "") return $[];
  377.         vfstype = "swap";
  378.     }
  379.     else if (fsid == fsid_native) {
  380.         if (used_fs == `reiser)
  381.         vfstype = "reiserfs";
  382.         else
  383.         vfstype = "ext2";
  384.         freq = 1;
  385.         if (file == "") {
  386.             file = "/data" + other_nr;
  387.         if (!Mkdir("/mnt" + file))
  388.             return;
  389.         // Don't mount and fsck this filesystem during boot, its
  390.         // state is unknown.
  391.         mntops = "noauto,user";
  392.         vfstype = "auto";
  393.         freq = 0;
  394.         other_nr = other_nr + 1;
  395.         }
  396.     }
  397.     else if (contains (fsid_dostypes, fsid)) {    // dos type
  398.         vfstype = "auto";
  399.         if (contains (fsid_readonly, fsid))
  400.         mntops = "ro,noauto,user";
  401.         else
  402.         mntops = "noauto,user";
  403.         freq = 0;
  404.         if (file == "") {
  405.         file = "/dos/" + substring (foreign_ids, foreign_nr, 1);
  406.         }
  407.         Mkdir ("/mnt"+file);
  408.         if ((foreign_primary == "")
  409.         && (lookup (partition, "type") == `primary)) {
  410.         foreign_primary = spec + " dos";
  411.         cmd4boot_message = "echo 'dos -> Boot DOS' > /mnt/boot/message";
  412.         }
  413.         foreign_nr = foreign_nr + 1;
  414.     }
  415.     else if (contains (fsid_ntfstypes, fsid)) {    // dos type
  416.         vfstype = "ntfs";
  417.         if (contains (fsid_readonly, fsid))
  418.         mntops = "ro,noauto,user";
  419.         else
  420.         mntops = "noauto,user";
  421.         freq = 0;
  422.         if (file == "") {
  423.         file = "/windows/" + substring (foreign_ids, foreign_nr, 1);
  424.         }
  425.         Mkdir ("/mnt"+file);
  426.         if ((foreign_primary == "")
  427.         && (lookup (partition, "type") == `primary)) {
  428.         foreign_primary = spec + " nt";
  429.         cmd4boot_message = "echo 'nt -> Boot Windows NT' > /mnt/boot/message";
  430.         }
  431.         foreign_nr = foreign_nr + 1;
  432.     }
  433.     else if (contains (fsid_wintypes, fsid)) {    // win type
  434.         vfstype = "vfat";
  435.         if (contains (fsid_readonly, fsid))
  436.         mntops = "ro,noauto,user";
  437.         else
  438.         mntops = "noauto,user";
  439.         freq = 0;
  440.         if (file == "") {
  441.         file = "/windows/" + substring (foreign_ids, foreign_nr, 1);
  442.         }
  443.         Mkdir ("/mnt"+file);
  444.         if ((foreign_primary == "")
  445.         && (lookup (partition, "type") == `primary)) {
  446.         foreign_primary = spec + " windows";
  447.         cmd4boot_message = "echo 'windows -> Boot Windows' > /mnt/boot/message";
  448.         }
  449.         foreign_nr = foreign_nr + 1;
  450.     } else
  451.         return $[];                // unknown type
  452.  
  453.     return ($["spec":spec, "file":file, "vfstype":vfstype,
  454.                "mntops":mntops, "freq":freq, "passno":passno]);
  455.     };
  456.  
  457.  
  458.     define allpartitions2fstab (string device, list partitions) ``{
  459.     if (size (partitions) == 0)
  460.         return;
  461.     foreach (`partition, partitions, ``{
  462.         map fstabentry = onepartition2fstab (device, partition);
  463.         if (fstabentry != $[])
  464.         fstab = add (fstab, fstabentry);
  465.     });
  466.     };
  467.  
  468.     map targetMap = lookup (user_settings, "targets", $[]);
  469.  
  470.     foreach (`tdevice, `tdata, targetMap, ``{
  471.     list partitions = lookup (tdata, "partitions", []);
  472.     allpartitions2fstab (tdevice, partitions);
  473.     });
  474.  
  475.     fstab = add (fstab,
  476.          $["spec":"proc", "file":"/proc", "vfstype":"proc",
  477.            "mntops":"defaults", "freq":0, "passno":0]);
  478.     if (start_usb == "yes") {
  479.     fstab = add (fstab,
  480.          $["spec":"usbdevfs", "file":"/proc/bus/usb", "vfstype":"usbdevfs",
  481.            "mntops":"defaults", "freq":0, "passno":0]);
  482.     }
  483.     fstab = add (fstab,
  484.          $["spec":"devpts", "file":"/dev/pts", "vfstype":"devpts",
  485.            "mntops":"defaults", "freq":0, "passno":0]);
  486.  
  487.     // add all cd-drives to fstab
  488.  
  489.     cdnum = 0;
  490.  
  491.     foreach (`cd, cddevices, ``{
  492.     string cdmount = "";
  493.     cdmount = "/cdrom";
  494.     if (cdnum > 0)
  495.         cdmount = cdmount + cdnum;
  496.     Mkdir ("/mnt"+cdmount);
  497.     fstab = add (fstab,
  498.          $["spec":cd, "file":cdmount, "vfstype":"auto",
  499.            "mntops":"ro,noauto,user,exec", "freq":0, "passno":0]);
  500.     cdnum = cdnum + 1;
  501.     });
  502.  
  503.     fstab = add (fstab,
  504.          $["spec":"/dev/fd0", "file":"/floppy", "vfstype":"auto",
  505.            "mntops":"noauto,user", "freq":0, "passno":0]);
  506.  
  507.     if (test_mode)
  508.     y2log (.milestone, "inst_finish", 1, "fstab: "+fstab);
  509.     else
  510.     SCR(`Write(.mnt.etc.fstab, fstab));
  511.  
  512.  
  513.     // --------------------------------------------------------------
  514.     // boot concept
  515.     if ((foreign_primary != "") && (foreign_primary != "X")) {
  516.     user_settings = add (user_settings, "other_lilo", " -o \""+foreign_primary+"\"");
  517.     if (cmd4boot_message != "")
  518.         Shell (cmd4boot_message);
  519.     }
  520.  
  521.     // --------------------------------------------------------------
  522.     // create 1st user from installation dialog
  523.  
  524.     string loginname = lookup (user_settings, "loginname", "");
  525.     string upassword = lookup (user_settings, "upassword", "");
  526.     string uid = "500";        // FIXME: should be looked up dynamically (first free above 500)
  527.  
  528.     integer ret = 0;
  529.     if (!test_mode)
  530.     Shell(sformat("chroot /mnt useradd -G dialout,uucp,video,audio -u %1 -m -p %2 %3", uid, upassword, loginname));
  531.  
  532.     // inform the user, that the user login could not be created
  533.     if ( ret != 0 )
  534.     {
  535.         _debug ("useradd - error:", ret);
  536.         // Error msg
  537.     UI(`DisplayMessage(_("An error occurred during creation of the user login!")));
  538.     }
  539.  
  540.     // clear screen after useradd, but probably on wrong tty ?!
  541.     // Shell ("echo ''");
  542.  
  543.  
  544.     // Run depmod to update modules.dep
  545.     if (!test_mode)
  546.     Shell("chroot /mnt /sbin/depmod -a -F /boot/System.map-`uname -r` `uname -r`");
  547.  
  548.     // Set default runlevel to 3, if X11 packages are installed
  549.     // also make symlink to real X-Server
  550.  
  551.     if (!test_mode && (lookup (user_settings, "have_x11", false) == true)) {
  552.     string xservername = lookup (user_settings, "xservername", "");
  553.     if (xservername == "") {
  554.         // Oops, x11 choosen without xservername ?!
  555.         Shell ("cp /usr/X11R6/bin/XF86_FBDev /mnt/usr/X11R6/bin");
  556.         xservername = "XF86_FBDev";
  557.     }
  558.     Shell("chroot /mnt ln -snf /usr/X11R6/bin/"+xservername+" /var/X11R6/bin/X");
  559.     Shell("sed -e 's/^id:[0-9sSa-cA-C]*:initdefault:/id:3:initdefault:/' /mnt/etc/inittab >/tmp/inittab && cp /tmp/inittab /mnt/etc");
  560.  
  561.     }
  562.  
  563.     // FIXME
  564.     // one more hack to ease testing
  565.     // this effectively overwrites the y2base.rpm and yast2.rpm just installed
  566.  
  567. //    if (lookup (install_inf, "bootmode", "") == "Net") {
  568. //    Shell ("cp /bin/y2bignfat /mnt/bin/y2bignfat");
  569. //    Shell ("cp -a /lib/YaST2/* /mnt/lib/YaST2");
  570. //    }
  571.  
  572.     // Tell linuxrc where swap and root is
  573.     // Tell linuxrc to reboot on an SMP system
  574.  
  575.     if (SCR(`Read(.probe.has_smp))) {
  576.     SCR(`Write(.yast2.inf.rootpart, "reboot"));
  577.     user_settings = add (user_settings, "made_reboot", true);
  578.     }
  579.     else {
  580.     if (SCR(`Read(.probe.has_pcmcia)))
  581.         user_settings = add (user_settings, "made_reboot", true);
  582.     SCR(`Write(.yast2.inf.rootpart, lookup(user_settings, "root_device", "")));
  583.     }
  584.  
  585.     SCR(`Write(.yast2.inf.swappart, lookup(user_settings, "swap_device", "")));
  586.     SCR(`Write(.yast2.inf.language, lookup(user_settings, "yast1_language", "")));
  587.     SCR(`Write(.yast2.inf.keymap, lookup(user_settings, "yast1_keymap", "")));
  588.  
  589.     // --------------------------------------------------------------
  590.     // Copy YaST2 log files into installed system
  591.  
  592.     Shell("cp /var/log/y2log* /mnt/var/log");
  593.  
  594.     // --------------------------------------------------------------
  595.     // Copy /etc/install.inf and /etc/XF86Config into built system so that the
  596.     // second phase of the installation can find it.
  597.  
  598.     Shell("cp /etc/install.inf /etc/yast.inf /mnt/etc");
  599.  
  600.     string mouse_type = lookup (install_inf, "mouse_type", "PS/2");
  601.     map mouseMap = lookup (user_settings, "mouse", $[]);
  602.     string new_mouse = lookup (mouseMap, "xf86", mouse_type);
  603.     if (mouse_type == new_mouse) {
  604.     // keep mouse
  605.     Shell("cp /etc/XF86Config /mnt/etc");
  606.     }
  607.     else {
  608.     // replace with probed type
  609.     Shell("sed -e \"s#"+mouse_type+"#"+new_mouse+"#\" /etc/XF86Config >/mnt/etc/XF86Config");
  610.     }
  611.  
  612.     // --------------------------------------------------------------
  613.     // Copy syslinux files into installed system
  614.  
  615.     Shell("cp /usr/sbin/syslinux /mnt/usr/sbin/syslinux");
  616.  
  617.     // --------------------------------------------------------------
  618.     // Write LILO (not on PPC)
  619.  
  620.     if (architecture != "ppc")
  621.     CallFunction (`inst_writelilo());
  622.  
  623.     // --------------------------------------------------------------
  624.     // message after first round of packet installation
  625.     // now the installed system is run and more packages installed
  626.     // just warn the user that the screen is going back to text mode
  627.     // and yast2 will come up again.
  628.     // dont mention this "going back to text mode" here, maybe this
  629.     // wont be necessary in the final version
  630.  
  631.     // we should tell the user to remove the cd on an SMP or Laptop system
  632.     // where we do a hard reboot. However, the cdrom is still mounted here
  633.     // and cant be removed.
  634.  
  635.     UI(`DisplayMessage(_("Now booting your system...")));
  636.  
  637.     // --------------------------------------------------------------
  638.     // Unmount all mounted devices (from inst_prepdisk)
  639.  
  640.     map mountPoints = lookup(user_settings, "mountpoints", mountPoints);
  641.     list umountList = [];
  642.  
  643.     // go through mountPoints collecting pathes in umountList
  644.  
  645.     foreach (`mountpoint,`mountval,mountPoints, ``{
  646.     if ((mountpoint != "swap")
  647.         && (select (mountval, 1) == fsid_native)) {
  648.         umountList = add (umountList, mountpoint);
  649.     }
  650.     });
  651.  
  652.     // now unmount all mountpoints in reverse order !
  653.  
  654.     if (usb_type != 0)
  655.     Shell ("/bin/umount /mnt/proc/bus/usb");
  656.     Shell ("/bin/umount /mnt/proc");
  657.  
  658.     integer umountLength = size (umountList);
  659.     while (umountLength > 0) {
  660.     umountLength = umountLength - 1;
  661.     Shell ("/bin/umount /mnt"+select (umountList, umountLength));
  662.     }
  663.  
  664.     return `next;
  665. }
  666.