home *** CD-ROM | disk | FTP | other *** search
-
- /**
- * Module: inst_rpmcopy.ycp
- *
- * Authors: Mathias Kettner (kettner@suse.de)
- * Klaus Kaempf (kkaempf@suse.de) (initial)
- *
- * Purpose:
- * Install all the RPM packages the user has selected.
- * Show installation dialogue. Show progress bars.
- * Request CD change from user.
- *
- * user_settings read: "continue_mode"
- * "language"
- * "install_info"
- * "packages_installed"
- *
- * user_settings write: ---
- *
- *
- * SCR: Read(.yast2.instsource.cdnum)
- *
- * $Id: inst_rpmcopy.ycp,v 1.84.4.1 2000/03/22 16:43:01 kkaempf Exp $
- */
-
- {
- integer maxnumbercds = 8;
-
- map installMap = SCR(`Read(.etc.install_inf));
-
- // Check if the source is remountable
- boolean remountable = true;
-
- string boot_src = "";
- integer current_cd = 0;
- string bootmode = lookup (installMap, "bootmode", "");
- list cddrives = [];
- list cddevices = [];
-
- if (bootmode == "CD") {
- boot_src = "/dev/" + lookup (installMap, "cdrom", "cdrom");
- cddevices = add (cddevices, boot_src);
- cddrives = SCR(`Read(.probe.byclass.storage_device.cdrom));
- foreach (`drive, cddrives, ``{
- if (!contains (cddevices, drive))
- cddevices = add (cddevices, lookup (drive, "dev_name", ""));
- });
- remountable = true;
- }
- else if (bootmode == "Net") {
- boot_src = lookup (installMap, "server", "")
- + ":"
- + lookup (installMap, "serverdir", "");
- cddevices = add (cddevices, boot_src);
- integer nfscd = 1;
- while (nfscd <= maxnumbercds) {
- cddevices = add (cddevices, boot_src + "/CD" + nfscd);
- nfscd = nfscd + 1;
- }
- remountable = false;
- }
- else if (bootmode == "Harddisk") {
- boot_src = lookup (installMap, "partition", "");
- cddevices = add (cddevices, boot_src);
- integer hdcd = 1;
- while (hdcd <= maxnumbercds) {
- cddevices = add (cddevices, boot_src + "/CD" + hdcd);
- hdcd = hdcd + 1;
- }
- remountable = false;
- }
- y2log (.milestone, "inst_rpmcopy", 1, sformat("bootmode: %1, boot_src: %2, remountable: %3, cddevices: %4", bootmode, boot_src, remountable, cddevices));
-
- // Tell the user to change the CD.
- define ChangeCD(integer cdnum) ``{
- if (size (cddevices) == 0) {
- Shell ("/bin/mount "+boot_src+" /var/adm/mount");
- }
- else {
- current_cd = 0;
- Shell ("/bin/mount "+select(cddevices, current_cd)+" /var/adm/mount");
- }
-
- integer|void actcdnum = nil;
- while (true) {
- actcdnum = SCR(`Read(.yast2.instsource.cdnum));
- if (actcdnum == cdnum) return true;
- else {
- Shell ("/bin/umount /var/adm/mount");
- current_cd = current_cd+1;
- if (current_cd >= size (cddevices)) { // list exhausted
- current_cd = 0; // restart at 0
- // advise user to insert the right CD
- string message = sformat(UI(_("Please insert CD %1.")), cdnum);
- if (is(actcdnum, integer))
- // inform user about current CD
- message = sformat(UI(_("%1\nCurrently CD %2 is inserted.")), message, actcdnum);
- UI(`DisplayMessage(message));
- }
- if (size (cddevices) == 0) {
- Shell ("/bin/mount "+boot_src+" /var/adm/mount");
- }
- else {
- Shell ("/bin/mount "+select(cddevices, current_cd)+" /var/adm/mount");
- }
- }
- }
- };
-
- UI(``{
- define RpmDialog(integer maxpacs) ``{
- // Announce number of packages that will be installed
- SetWizardContents(sformat(_("Installing %1 software packages"), maxpacs),
- `VBox(
- `ProgressBar(`id(`package), " ", 100),
- `ProgressBar(`id(`numpacs), " ", maxpacs),
- // Label for disk usage progress bar
- `ProgressBar(`id(`diskusage), _("Disk Usage"), 100),
- `PushButton(`id(`cancel), _("&Cancel"))),
- // report software will be installed
- _("\
- <p>
- The selected software will be installed.
- </p>
-
- <p>
- And if you're feeling bored watching this screen take the time to
- browse through appendix F of
- the manual; this appendix tries to answer <em>Frequently Asked
- Questions</em> (FAQ).
- </p>
-
- <p>
- Don't hesitate to have a look at the <em>SuSE Support Database</em>
- (http://sdb.suse.de) if you want to know more about the
- software coming with <b>SuSE Linux</b>.
- </p>
- <br>
- "), false, false);
- };
- });
-
- // define macros for the ui that is called by the package
- // installer in order to update the progressbars.
-
- UI(``{
- define ShowProgressBars(
- string pacname,
- string pack_descr,
- integer percent,
- integer current_number,
- integer disk_usage,
- integer disk_capacity)
- ``{
- // display package and package description
- ChangeWidget(`id(`package), `Label, sformat(_("%1 - %2"), pacname, pack_descr));
- ChangeWidget(`id(`package), `Value, percent);
- // inform user about installation progress
- ChangeWidget(`id(`numpacs), `Label, sformat(_("%1 packages installed"), current_number+1));
- ChangeWidget(`id(`numpacs), `Value, current_number+1);
- integer how_much = (disk_usage * 100) / disk_capacity;
- ChangeWidget(`id(`diskusage), `Value, how_much);
- if (how_much > 95) {
- // warn user about exhausted diskspace during installation of packages
- // this is a popup with options "continue" and "cancel"
- if (!ContinueCancel(_("Diskspace exhausted !"),
- // Continue button
- _("C&ontinue"),
- // Cancel button
- _("&Cancel") ) )
- return `diskfull;
- }
- any r = PollInput();
- // in case of cancel ask user if he really wants to quit installation
- if (r == `cancel && YesOrNo(_("Do you really want\nto quit the installation?"), _("&Yes"), _("&No")))
- return `cancel;
- return nil;
- };
- });
-
- boolean continue_mode = lookup(user_settings, "continue_mode", false);
- string language = lookup(user_settings, "language", default_language);
-
- string target = "/mnt";
- if (continue_mode) {
- target = "/";
-
- string ckb_cmd = lookup(user_settings, "ckb_cmd", "");
- string xkb_cmd = lookup(user_settings, "xkb_cmd", "");
-
- UI(`SetLanguage(language));
- if (ckb_cmd != "")
- Shell (ckb_cmd);
- if (xkb_cmd != "")
- Shell (xkb_cmd);
- y2log (.milestone, "continue", 1, "lang: "+language+"; ckb: "+ckb_cmd+"; xkb: "+xkb_cmd);
-
- UI(`SetConsoleFont (lookup(user_settings, "console_magic", ""),
- lookup(user_settings, "console_font", ""),
- lookup(user_settings, "console_screenmap", ""),
- lookup(user_settings, "console_unicodemap", "")));
-
- }
-
- // List of all packages to install
- list install_info = [];
-
- // Prepare the source
- string source = "/var/adm/mount/suse/";
-
- if (continue_mode) {
- Shell("echo "+ "'YaST2 Version " + SCR(`Read(.probe.version)) + "' > /dev/tty2");
- y2log (.milestone, "inst_rpmcopy", 3, "Starting second part of package installation");
- install_info = Read("/var/lib/YaST2/pacs_to_install.ycp");
- }
- else {
- y2log (.milestone, "inst_rpmcopy", 4, "Starting first part of package installation");
- // Make sure, CD 1 is inserted
- ChangeCD(1);
-
- // save info and update.in_ from CD1 for generating update.inf for YaST1
- // see inst_finish for update.inf generation
-
- string shellcmd = "cp " + source + "setup/descr/info /tmp/info";
- Shell (shellcmd);
- shellcmd = "cp " + source + "setup/descr/update.in_ /tmp/update.in_";
- Shell (shellcmd);
-
- // Initialize the target system.
- CallModule("packager", [nil, `init, `root(target)]);
- UI(`SetModulename("inst_rpmcopy"));
-
- install_info = lookup(user_settings, "install_info");
- }
-
- // Now that we know how many packages to install, we can show the dialog
-
- integer packages_installed = 0;
-
- if (continue_mode) {
- // get the number of already installed packages
- packages_installed = lookup (user_settings, "packages_installed", 0);
- }
- y2log (.milestone, "inst_rpmcopy", 1, sformat("%1 packages have been installed", packages_installed));
-
- any dlg = UI(`RpmDialog(size(install_info) + packages_installed));
-
- if (!continue_mode) {
- // First install the base system. This has to be done with the %pre
- // and %post scripts handled separately and not by rpm, because
- // without a minimal system being installed no scripts can be executed
- // chroot in the new system. We filter the pacdesc list and extract
- // only the base packages, and only those that are contained in our
- // package selection. This filtered list we convert into a list
- // containing only the package filename and the label in the current
- // language.
-
- // Base packages must be on CD1
- list base_packages = filter(`v, install_info, ``(select(v, 3) && (select(v, 2) == 1)));
- _debug(base_packages);
-
- any ret =
- CallModule("packager", [``ShowProgressBars, `add(source, base_packages),
- `root(target),
- `manual_scripts,
- `number(0)]);
-
- UI(`SetModulename("inst_rpmcopy"));
-
- packages_installed = packages_installed + size(base_packages);
-
- if (ret == `cancel) return `cancel;
- if (ret == `diskfull) break;
- else if (ret == `error) UI(`DisplayMessage(_("RPM returned an error")));
- else if (ret != `ok) UI(`DisplayMessage(_("The packager returned an unknown code")));
-
- // Filter out the packages for the first round of install
- install_info = filter(`v, install_info, ``(!(select(v, 3) && (!remountable || (select(v, 2) == 1)))));
- }
-
- // Install the software from CD1 to CDmax, but not the already
- // installed base packages
-
- integer cdnum = 1;
- while (cdnum <= maxnumbercds)
- {
- list this_cd_packages =
- filter(`v, install_info, ``(select(v, 2) == cdnum));
- y2log (.debug, "inst_rpmcopy", 6, sformat("this_cd_packages: %1", this_cd_packages));
-
- if (this_cd_packages != [])
- {
- if (remountable) ChangeCD(cdnum);
- any ret = CallModule("packager", [``ShowProgressBars, `add(source, this_cd_packages),
- `root(target),
- `number(packages_installed)]);
- UI(`SetModulename("inst_rpmcopy"));
- packages_installed = packages_installed + size(this_cd_packages);
- if (ret == `cancel) return `cancel;
- if (ret == `diskfull) break;
- }
-
- install_info = filter(`v, install_info, ``(select(v, 2) != cdnum));
-
- // break on first round with CDs
- if (!continue_mode && remountable) break;
-
- cdnum = cdnum + 1;
- }
-
- if (!continue_mode) {
- // Write out a list of packages that must be installed
- // in the second phase
- Write("/mnt/var/lib/YaST2/pacs_to_install.ycp", install_info);
- user_settings = add (user_settings, "packages_installed", packages_installed);
- }
- else
- // Everything done, remove that thing.
- Shell("rm /var/lib/YaST2/pacs_to_install.ycp");
-
- if (remountable) {
- Shell ("/bin/umount /var/adm/mount");
- }
-
- return `next;
- }
-