2000-04-14 Pixel * install_steps_interactive.pm (choosePartitionsToFormat): don't ask about checking bad blocks for reiserfs, cuz not handled * fs.pm (mount): reiserfs handling * fs.pm (format_reiserfs): added * fs.pm (write_fstab): add option "notail" for reiserfs if the partition holds the kernel (/boot or /) * partition_table.pm (isTrueFS): added, replaces most occurences of isExt2 2000-04-12 François Pons * install2.pm: force installation step if package have been selected on step choose packages. * install_any.pm: protected against die in perl (setstep or theme_changed). 2000-04-11 François Pons * resize_fat: added some limits verification. * interactive_gtk.pm: corrected swap of arg with help adding. 2000-04-10 François Pons * interactive_gtk.pm, my_gtk.pm: added tooltips for ask_from_list, which is used by printerdrake only. drops key bindings. 2000-04-07 François Pons * tools/serial_probe: obsoleting pnp_serial which is now replaced by this one, taken from kudzu, really faster and probe all serial devices at one time. modified to probe correctly modem :-) * mouse.pm: updated to use serial_probe interface of detect_devices.pm. * detect_devices.pm: modified to use serial_probe, cache probed devices to avoid reprobing. 2000-04-06 François Pons * install_steps_interactive.pm, install_steps.pm: added support for peerdns options of ppp, so removed dns address unless expert. 2000-04-05 François Pons * crypto.pm, install_steps_interactive.pm, install2.pm, install_steps.pm: added crypto stuff to support hdlist-crypto.cz2 and depslist-crypto. dependancies are not supported but with a simpler format of depslist file where closure are not done and only package name are used for dependancies. * pkgs.pm: added better support for multi CD manipulation, including selection and refus. 2000-04-04 François Pons * pkgs.pm: modified selection packages from compssList by incremental selection, much more quickly. added selected medium for selecting a package. * install_any.pm: refused media hash transfered to selected value of media table. @needToCopy list should only have package of default medium. 2000-04-03 Pixel * fs.pm (format_ext2): add options "-b 1024 -O none" for alpha 2000-03-31 François Pons * install_steps_gtk.pm: made changeMedium sub modification permanent. * pkgs.pm: modified upgrade to avoid use of header. 2000-03-31 Pablo Saratxaga * keyboard.pm: some more choices for PPC keyboards 2000-03-30 François Pons * install2pm: added eval around loading af_packet and postinstall copy of RPMS. * devices.pm: added /dev/kdb for SPARC. * install_any.pm: modified multi CD management, postinstall copy of RPMS. * install_steps_gtk.pm: added support for Xsun server for SPARC. * install_steps_interactive.pm: added multi CD dialog box for selecting CD available. Serialized ethernet configuration and ppp configuration. * pkgs.pm: added check for infinite recursion for bad depslist. * printer.pm: better test for reparse of printerdb. * Xconfigurator.pm: added support for Xsun server for SPARC. 2000-03-30 Pixel * install_steps_gtk.pm (choosePackagesTree): enhance tree selection 2000-03-29 Pixel * interactive_gtk.pm (wait_messageW): add some padding (nicer) * install_steps_interactive.pm (generateAutoInstFloppy): created, creates a floppy for auto installs. * install_any.pm (generate_ks_cfg): created, generates stage1 ks.cfg file * share/po/DrakX.pot: added special comment for grub entry 2000-03-28 Pixel * install_steps_interactive.pm (selectKeyboard): sort langs for many-lang install * mouse.pm (write): add WHEEL telling if a wheel mouse is there 2000-03-28 Pablo Saratxaga * keyboard.pm: added entries for all three Armenian keyboards 2000-03-26 Pixel * install_any.pm (install_urpmi): full support for multi-hdlist's * pkgs.pm (extractHeaders): look for hdlist in /tmp instead of $prefix/var/lib/urpmi * pkgs.pm (psUsingHdlists): put hdlist's in /var/lib/urpmi with a fake name. Access via /tmp/$hdlist is given for non-fake name * detect_devices.pm (hasHPT): return undef if no htp (silly me :-/) 2000-03-25 Pixel * lilo.pm: updated to the new format of entries. It was an hash. Now the key is field kernel_or_dev, and entries is an array. (get): added, it returns the entry using a kernel (needed because entries is no more a hash) * install_steps_interactive.pm (setupLILO): adapted to the new format * Xconfigurator.pm (write_XF86Config): basic XF86Config-4 handling * fsedit.pm (suggest_part): if suggested part contains a field "hd", ensure the partition is created on this hard drive * install2.pm (main): before leaving installation, remove /var/lib/urpmi if urpmi not installed * diskdrake.pm (Resize): ext2resize to size $part->{size} instead of $size 2000-03-24 Pixel * detect_devices.pm (hasHPT): added. Now nice handling of hpt366 (ultra66) without rebooting and making special floppy :) * lilo.pm (install_grub): much better grub configuration (better than lilo's :pp) * install_steps.pm (setupBootloaderBefore): remove entry floppy for security > 3 2000-03-23 Pixel * install_steps_gtk.pm (selectMouse): added, takes care of telling the X server if the user changed the mouse type. Only done if a serial mouse is chosen. * install_steps_newt.pm (doPartitionDisks): add a call to * mouse.pm (write): added "device=" in etc/sysconfig/mouse for devfs (it looses the symlink /dev/mouse) 2000-03-22 Pixel * pci_probing/pcitable: replace Server:Rage128 by proper XFree entry 2000-03-20 François Pons * detect_devices.pm, fs.pm, install_any.pm: added supports for LS-120 floppy drive and icons on desktop of KDE (untested). * printer.pm, printerdrake.pm: added supports for PPA interface in new rhs-printfilters, always enable "Print text as postscript" option for such printers. 2000-03-20 Pablo Saratxaga * keyboard.pm: changed XKB name for Swedish keyboard changed XKB names for Russian and German keyboards added a choice for "Croatian" keyboard * share/compss{,List}: added various new locales-*, ispell-* and netscape-* files. changed ppa to pnm2ppa. 2000-03-17 François Pons * install_steps.pm: added setup for all configured queue. * install_steps_interactive.pm: modified for retrieving packages or current configuration. * printer.pm: correction, tested retrieve of printer configuration without printtool comments in printcap file: added update of entry according to gsdriver used (untested again). * printerdrake.pm: better handling of cancel, manage of multiple queue definition together (as lp|My printer). 2000-03-16 François Pons * install_steps_interactive.pm: moved in printerdrake.pm the test of printer usage. * printerdrake.pm: heavy modification to handle multiple queue, corrected some bugs too, added much more features as printtool. * printer.pm: added more features for filter, allow printer to be retrieved without help of printtool id in printcap file (untested). 2000-03-14 Pixel * diskdrake.pm (Loopback): handling of the file loopback: test existence of the file and take its size. 2000-03-14 François Pons * install_any.pm: corrected for duplicate file on other CD. 2000-03-13 Pixel * detect_devices.pm (floppies): don't return hash but the device name 2000-03-13 François Pons * pkgs.pm, install_any.pm: small correction for multiple media installation. * tools/syncrpms: added for handling synchronisation of multiple source rpm directories (and multiple target), include cleaning. * tools/closurepkgs: tools to get rpm that may be installed by DrakX after normal packages installation (printer, network, X11...), may be used to duplicate on other CD some important stuff of the first one. 2000-03-12 Pixel * install_steps_interactive.pm (choosePackages): compute the max_size very simply (sum of all package sizes), otherwise too costly * pkgs.pm (install): call cleanHeaders at the end * pkgs.pm (cleanHeaders): created * install2.pm (miscellaneous): /etc/msec/init.sh is now /usr/sbin/msec (yoann thanks for not telling :pp) * pkgs.pm (install): remove the $prefix of mountpoints for not enough room to install error message 2000-03-11 Pixel * my_gtk.pm (_create_window): add callback on focus to ensure_focus. The result is no more 3 focus states with 2 buttons. * interactive_gtk.pm (ask_from_treelistW): better keyboard handling * raid.pm (make): check the result of mkraid. Suggest raidtools are missing in standalone diskdrake * devices.pm (set_loop): created, searches for an available loopback and sets the file to it * lilo.pm (dev2grub): fixed a missing slash * interactive_gtk.pm (wait_message_nextW): do not update if same message, otherwise silly gtk won't do anything and we'll wait forever :( 2000-03-10 François Pons * *.pm: heavy modification to take into account multiple media installation. 2000-03-10 Pixel * install2.pm (@install_classes): cleanup, no more i18n (is now in install_steps_interactive), remove old entries 2000-03-09 Pixel * modules.pm (write_conf): don't add alias block-major-11 in every case * modules.pm (add_alias): special case oss (post-installs modprobe snd-pcm-oss) * fs.pm (format_*): move the @options before the device * loopback.pm: created, added a lot of stuff for loopback in diskdrake.pm, fs.pm... 2000-03-08 Pixel * partition_table.pm: %type2fs replaced ox402 by 0x402 * detect_devices.pm (cdroms): fix "scd" (should be "scd0") * install_any.pm (install_urpmi): update for new hdlist.cz2 2000-03-07 Pixel * interactive_gtk.pm (ask_from_treelistW): s/focus_row/set_focus_row/ * install_steps_interactive.pm (addUser): force add a normal user for security 4 2000-03-05 Pixel * my_gtk.pm (_ask_from_list): replace focus_row with set_focus_row (tis the Gtk-Perl 0.7002 was of doing) 2000-03-04 Pixel * modules.pm (write_conf): add ide-floppy to the modprobes of post-install supermount 2000-03-03 Pixel * commands.pm (ps): add RSS to ps command 2000-03-02 Adam Lebsack * mouse.pm: added mac mouse detection to mouse::detect. * detect_devices.pm: added a routine to probe /dev/usbmouse on macs. 2000-03-01 François Pons * *.pm: heavy modification to take into account smaller transaction during installation. still a lot of test to perform, no provides updated currently and building of hdlist.cz2 and depslist.ordered need old files... nothing done for hdlist.gz during post installation, but hdlist.cz2 is already copied in /var/lib/urpmi [and is used during installation of packages as extract_archive need a true file]. 2000-03-01 Pixel * lilo.pm (install_grub): creation * network.pm (write_interface_conf): ONBOOT = !pcmcia * install_steps_gtk.pm (new): more intelligent SIGCHLD handler 2000-02-29 Pixel * modules.pm: moved common network stuff from "net" to "network" (modules like nfs lockd...) * fs.pm (write_fstab): moved the sort to the right place * services.pm (drakxservices): chkconfig --list is i18n'ed :( set LANGUAGE=C before * partition_table_raw.pm (get_geometry): geom{cylinders} must not be a decimal value :) * install_steps_gtk.pm (create_logo_window): set_name logo for logo window * share/install.rc: force disabling of background image theme * install_steps_gtk.pm (enteringStep): add step information for console 1 * any.pm (addKdmIcon): new function * install_steps.pm (addUser): handle field icon * install_steps_interactive.pm (addUser): add choice of kdm icon * standalone/adduserdrake: add choice of kdm icon * diskdrake.pm (ask_all_data...): change for easier i18n * install_steps.pm (miscellaneous): add CLEAN_TMP handling (need cleaning?) * install_steps_interactive.pm (miscellaneous): add CLEAN_TMP option in expert * install2.pm (miscellaneous): add CLEAN_TMP option for /etc/sysconfig/system * install_steps_interactive.pm (miscellaneous): forbidden useSupermount if high security. * mouse.pm (detect): fix bug (ttyS instead of ttyS0) 2000-02-28 Pixel * install_steps_gtk.pm (createXconf): do not use "Generic VGA" for svga and accel. SVGA also wants 16 bpp. added ugly modeline for 800x600. * partition_table_raw.pm (get_geometry): when the HDIO_GET_IDENTITY fails, defaults to what GETGEO gave * install2.pm (main): use modules::load_multi to increase boot start time * modules.pm (load_multi): added this function for loading many modules at once. * install_steps_gtk.pm (new): increase time before timeout * detect_devices.pm (cdroms): change the device associated with ide-burners (hdX -> scdX). Problem is how to know the X in scdX :( * modules.pm (write_conf): sort scsi_hostadapter's 2000-02-27 Pixel * install2.pm (main): load ide-probe and the like in 'prereq' type so no aliases are added to conf.modules 2000-02-25 Pixel * devices.pm (make): small code cleanup * partition_table_raw.pm (adjustEnd): more explicit error message * fsedit.pm (allocatePartitions): fix a bug (size was getting too big after each allocation) making adjustEnd cry 2000-02-24 Pixel * interactive_gtk.pm (new): added the "new" method to initialize windowheight for isStandalone * install_steps_gtk.pm (new): returns undef in case no X server works * install2.pm (main): moved the ejectCdrom from install_steps::END to here * install2.pm (main): fix the $SIG{SEGV} handler * install2.pm (main): added a "try again" in text install if the "new" fails * install_steps_interactive.pm (createBootdisk): fix an error for non fdX choice of floppy drive * install_steps_interactive.pm (setup_thiskind): remove the "defined @l" 2000-02-23 Pixel * install2.pm (%suggestedPartitions): remove any /boot entries * install2.pm (selectInstallClass): removed the special code to /boot entries from suggestedPartitions for on non-intel (and it was buggy :) * fsedit.pm (@suggestions): remove the /boot entry * fsedit.pm (check_mntpoint): remove the 1024 cylinder check * fsedit.pm (suggest_part): remove the 1024 cylinder special case * install_steps_interactive.pm (setupLILO): replace linear option by lba32 * lilo.pm (suggest): add lba32 by default * install_steps_interactive.pm (load_thiskind): moved the HPT stuff to install_any::ultra66 and call it. Add sound card configuration (3 lines :) * my_gtk.pm and interactive_gtk: resize the list and tree based on root window size * install_steps_gtk: $width and $height goes $::rootwidth and $::rootheight, also other dimensions goes global (main::) * commands.pm (strings): replace the typo \{$n,} by {$n,} 2000-02-23 François Pons * build_archive, extract_archive: changed format of TOC to speed up extraction of archive, now 5 to 6 times faster to read TOC :-) 2000-02-22 Pixel * Xconfigurator.pm: load "Cards" database only to translate NAME to fields. Added file CardsNames created from Cards using share/Cards2CardsNames. Kind of list of normalized NAMEs * MonitorsDB: replace the ` ' separator for vendor by `|' * install_steps_interactive.pm (timeConfig): use ask_from_treelist * interactive_gtk.pm (ask_from_treelist): creation of ask_from_treelist. Usage is just the same as ask_from_list with one more argument (the separator eg: |, /) 2000-02-21 François Pons * diskdrake.pm: fixed deadlock while trying to create partition when available space is equal or less than 2 cylinders. fixed Create action on corrupted partition by removing stalling window. Blocked partition table writing if there are error by forcing user to correct partition table. * partition_table.pm: fixed typo in verifyParts with cdie, added verifyParts on Resize action. 2000-02-21 Pixel * install_steps_gtk.pm (create_big_help): display the help in full screen * my_gtk.pm (_create_window): add big help on F1 * common.pm (add2hash): now returns the first parameter * mouse.pm (detect): really defaults to serial mouse * interactive.pm: add ask_many_from_list_with_help and ask_many_from_list_with_help_ref * services.pm: creation, it handles what was in standalone/drakxservices 2000-02-18 Pixel * install_steps_gtk.pm (createXconf): added /dev/ (X wants "/dev/psaux" and not "psaux") * diskdrake.pm (Create): show start sector even for non-expert on non-i386 2000-02-16 Pixel * mouse.pm (detect): add defaults to serial mouse * install_steps_gtk.pm (createXconf): remove the defaults to serial mouse 2000-02-15 Pixel * diskdrake.pm: "After %s partition %s," inlined otherwise does not please pablo and translators... 2000-02-14 Pixel * diskdrake.pm (Create): hide start sector choice for non-expert 2000-02-11 Pixel * partition_table_raw.pm (get_geometry): do not use the cylinder number given by HDIO_GETGEO cuz limited to 16bits. Compute using the total_sectors using HDIO_GET_IDENTITY * c/stuff.xs.pm: added total_sectors (gives the number of sector of a drive) * modules.pm (load): ignore error in loading prereq's * modules.pm (@drivers_by_category): rcpci instead of rcpci45, z85230 added * commands.pm (mount): add modules::load_deps otherwise the fs::mount won't succeed insmoding vfat if needed 2000-02-11 François Pons * fixed diskdrake to handle limit case when creating and resizing partition table, address size limit and start sector limit. 2000-02-11 Pixel * install2.pm (main): add a callback on SEGV -> message printed -> that way, ENDs are called (otherwise skipped) * install_steps_interactive.pm (setup_thiskind): handles the undef value returned by load_thiskind * install_steps_interactive.pm (exitInstall): do not call install_steps::exitInstall * install_steps (exitInstall): removed * install_steps (END): added (it does ejectCdrom) * install_steps_interactive.pm (load_thiskind): returns undef if error loading a module * fs.pm (format_part): changed the prototype from $;$@ to $;@ otherwise, @options always have a value (mostly undef) and mkdosfs fails (with "mkdosfs", "/dev/hdXX", undef, "-F", 32) * install_steps_interactive.pm (setup_thiskind): add a $auto_probe_pci that overrules $o->{auto_probe_pci} (that way no pci probe the second time) 2000-02-10 François Pons * heavy modification of build_archive and extract_archive to manage a TOC directly in archive file, handle bzip2 or gzip compression, extract_archive can extract multiple files a time, with minimal invocation of uncompress program and follow symlink and expand directory contents. * use build_archive/extract_archive for locales. * fixed a min/max in install_steps_gtk for Resize/Create partition. * fixed adjustEnd with dos partition table, take care of magic 63 sectors at beginning of partitions, a more solid method should be used for that. 2000-02-10 Pixel * modules.pm (load_thiskind): skip modules "unknown" and "ignore" 2000-02-09 Pixel * partition_table.pm (add): cdie if maximum number of partitions handled by linux is reached * Xconfigurator.pm (chooseResolutionsGtk): display the graphic card or server found * install_any.pm (relGetFile): for mdkinst files, take care not to have a double '/' (see debbugs #591) * install_steps_interactive.pm (configureNetwork): purpose: add ability to configure both modem and lan clean up the behaviour * fs.pm (write_fstab): purpose: sort the fstab per mount point (cuz /usr must be before /usr/local) also: rewrite of the part writing the fstab. 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563
package modules;

use vars qw(%loaded %drivers);

use common qw(:common :file :system);
use detect_devices;
use run_program;
use log;


my %conf;
my %loaded; #- array of loaded modules for each types (scsi/net/...)
my $scsi = 0;
my %deps = ();

my @drivers_by_category = (
[ 'net', {
arch() =~ /^sparc/ ? (
  "myri_sbus" => "MyriCOM Gigabit Ethernet",
  "sunbmac" => "Sun BigMac Ethernet",
  "sunhme" => "Sun Happy Meal Ethernet",
  "sunqe" => "Sun Quad Ethernet",
) : (
  "3c509" => "3com 3c509",
  "3c501" => "3com 3c501",
  "3c503" => "3com 3c503",
  "3c505" => "3com 3c505",
  "3c507" => "3com 3c507",
  "3c515" => "3com 3c515",
  "3c90x" => "3Com 3c90x (Cyclone/Hurricane/Tornado)",
  "at1700" => "Allied Telesis AT1700",
  "ac3200" => "Ansel Communication AC3200",
  "acenic" => "AceNIC Gigabit Ethernet",
  "pcnet32" => "AMD PC/Net 32",
  "82596" => "Apricot 82596",
#  "atp" => "ATP", # builtin the kernel
  "e2100" => "Cabletron E2100",
  "tlan" => "Compaq Netelligent",
  "cs89x0" => "CS89x0",
  "de600" => "D-Link DE-600 pocket adapter",
  "de620" => "D-Link DE-620 pocket adapter",
  "dgrs" => "Digi International RightSwitch",
  "depca" => "Digital DEPCA and EtherWORKS",
  "ewrk3" => "Digital EtherWORKS 3",
  "old_tulip" => "Digital 21040/21041/21140 (old Tulip driver)",
  "tulip" => "Digital 21040/21041/21140 (Tulip)",
  "eth16i" => "ICL EtherTeam 16i",
  "epic100" => "EPIC 100",
  "eexpress" => "Intel EtherExpress",
  "eepro" => "Intel EtherExpress Pro",
  "eepro100" => "Intel EtherExpress Pro 100", #- should run on sparc but no memory on floppy
  "hp100" => "HP10/100VG any LAN ",
  "hp" => "HP LAN/AnyLan",
  "hp-plus" => "HP PCLAN/plus",
  "lance" => "Lance",
  "lne390" => "Mylex LNE390",
  "ne" => "NE2000 and compatible",
  "ne2k-pci" => "NE2000 PCI",
  "ne3210" => "NE3210",
  "ni5010" => "NI 5010",
  "ni52" => "NI 5210",
  "ni65" => "NI 6510",
  "es3210" => "Racal-Interlan ES3210",
  "rcpci" => "Red Creek Hardware VPN",
  "epic100" => "SMC 83c170 EPIC/100",
  "sktr" => "Syskonnect Token ring adaptor",
  "smc9194" => "SMC 9000 series",
  "smc-ultra" => "SMC Ultra",
  "smc-ultra32" => "SMC Ultra 32",
  "yellowfin" => "Symbios Yellowfin G-NIC",
  "via-rhine" => "VIA Rhine",
#  "wavelan" => "AT&T WaveLAN & DEC RoamAbout DS", # TODO is a "AT&T GIS WaveLAN ISA" ?
  "wd" => "WD8003, WD8013 and compatible",
  "z85230" => "Z85x30",

  "dmfe" => "dmfe",
  "fmv18x" => "fmv18x",
  "ibmtr" => "Token Ring Tropic",
  "olympic" => "olympic",
  "plip" => "PLIP (parallel port)",
  "rl100a" => "rl100a",
  "sb1000" => "sb1000",
  "sbni" => "sbni",
  "sis900" => "sis900",
),
  "3c59x" => "3com 3c59x (Vortex)",
  "de4x5" => "Digital 425,434,435,450,500",
  "rtl8139" => "RealTek RTL8129/8139",
}],
[ 'network', {
  "8390" => "8390",
  "af_packet" => "packet socket",
  "nfs" => "Network File System (nfs)",
  "lockd" => "lockd",
  "sunrpc" => "sunrpc",
}],
[ 'scsi', {
arch() =~ /^sparc/ ? (
  "qlogicpti" => "Performance Technologies ISP",
) : (
  "aha152x" => "Adaptec 152x",
  "aha1542" => "Adaptec 1542",
  "aha1740" => "Adaptec 1740",
  "advansys" => "AdvanSys Adapters",
  "in2000" => "Always IN2000",
  "AM53C974" => "AMD SCSI",
  "BusLogic" => "BusLogic Adapters",
  "dtc" => "DTC 3180/3280",
  "seagate" => "Future Domain TMC-885, TMC-950",
  "fdomain" => "Future Domain TMC-16x0",
  "initio" => "Initio",
  "g_NCR5380" => "NCR 5380",
  "NCR53c406a" => "NCR 53c406a",
  "53c7,8xx" => "NCR 53c7xx",
  "qlogicfas" => "Qlogic FAS",
  "seagate" => "Seagate ST01/02",
  "t128" => "Trantor T128/T128F/T228",
  "u14-34f" => "UltraStor 14F/34F",
  "ultrastor" => "UltraStor 14F/24F/34F",
  "wd7000" => "Western Digital wd7000",

  "a100u2w" => "a100u2w",
  "atp870u" => "atp870u (Acard/Artop)",
  "dc395x_trm" => "dc395x_trm",
  "psi240i" => "psi240i",
  "qlogicfc" => "qlogicfc",
  "sim710" => "sim710",
  "sym53c416" => "sym53c416",
  "tmscsim" => "tmscsim",
),
  "aic7xxx" => "Adaptec 2740, 2840, 2940",
  "ncr53c8xx" => "NCR 53C8xx PCI",
#  "pci2000" => "Perceptive Solutions PCI-2000", # TODO
  "qlogicisp" => "Qlogic ISP",
  "sym53c8xx" => "Symbios 53c8xx",
  "scsi_mod" => "scsi_mod",
  "ide-mod" => "ide-mod",
  "ide-probe" => "ide-probe",
}],
[ 'disk', {
arch() =~ /^sparc/ ? (
  "pluto" => "Sun SparcSTORAGE Array SCSI", #- name it "fc4:soc:pluto" ?
) : (
  "DAC960" => "Mylex DAC960",
#  "dpt" => "Distributed Tech SmartCache/Raid I-IV Controller", # not there anymore?
  "megaraid" => "AMI MegaRAID",
  "cpqarray" => "Compaq Smart-2/P RAID Controller",
  "gdth" => "ICP Disk Array Controller",
  "ips" => "IBM ServeRAID controller",
  "eata" => "EATA SCSI PM2x24/PM3224",
  "eata_pio" => "EATA PIO Adapters",
  "eata_dma" => "EATA DMA Adapters",
  "ppa" => "Iomega PPA3 (parallel port Zip)",
  "imm" => "Iomega Zip (new driver)",
  "ide-disk" => "IDE disk",
),
}],
[ 'cdrom', {
arch() !~ /^sparc/ ? (
  "sbpcd" => "SoundBlaster/Panasonic",
  "aztcd" => "Aztech CD",
  "gscd" => "Goldstar R420",
  "isp16" => "ISP16/MAD16/Mozart",
#-  "mcd" => "Mitsumi", #- removed for space
  "mcdx" => "Mitsumi (alternate)",
  "optcd" => "Optics Storage 8000",
  "cm206" => "Phillips CM206/CM260",
  "sjcd" => "Sanyo",
  "cdu31a" => "Sony CDU-31A",
  "sonycd535" => "Sony CDU-5xx",
) : (),
  "isofs" => "iso9660",
  "ide-cd" => "ide-cd",
  "sr_mod" => "SCSI CDROM support",
  "cdrom" => "cdrom",
}],
[ 'sound', {
arch() !~ /^sparc/ ? (
  "alsa" => "ALSA sound module, many sound cards",
  "cmpci" => "C-Media Electronics CMI8338A CMI8338B CMI8738",
  "es1370" => "Ensoniq ES1370 [AudioPCI]",
  "es1371" => "Ensoniq ES1371 [AudioPCI-97]",
  "esssolo1" => "ESS Technology ES1969 Solo-1 Audiodrive",
  "maestro" => "Maestro",
  "nm256" => "Neomagic MagicMedia 256AV",
  "pas16" => "Pro Audio Spectrum/Studio 16",
  "via82cxxx" => "VIA VT82C686_5",
  "sonicvibes" => "S3 SonicVibes",
) : (),
}],
[ 'pcmcia', {
arch() !~ /^sparc/ ? (
  "ide_cs" => "ide_cs",
  "fmvj18x_cs" => "fmvj18x_cs",
  "fdomain_cs" => "fdomain_cs",
  "netwave_cs" => "netwave_cs",
  "serial_cs" => "serial_cs",
  "wavelan_cs" => "wavelan_cs",
  "pcnet_cs" => "pcnet_cs",
  "aha152x_cs" => "aha152x_cs",
  "xirc2ps_cs" => "xirc2ps_cs",
  "3c574_cs" => "3c574_cs",
  "qlogic_cs" => "qlogic_cs",
  "nmclan_cs" => "nmclan_cs",
  "ibmtr_cs" => "ibmtr_cs",
  "dummy_cs" => "dummy_cs",
  "memory_cs" => "memory_cs",
  "ftl_cs" => "ftl_cs",
  "smc91c92_cs" => "smc91c92_cs",
  "3c589_cs" => "3c589_cs",
  "parport_cs" => "parport_cs", 
  "3c575_cb" => "3c575_cb",
  "apa1480_cb" => "apa1480_cb",
  "cb_enabler" => "cb_enabler",
  "epic_cb" => "epic_cb",
  "iflash2+_mtd" => "iflash2+_mtd",
  "iflash2_mtd" => "iflash2_mtd",
  "memory_cb" => "memory_cb",
  "serial_cb" => "serial_cb",
  "sram_mtd" => "sram_mtd",
  "tulip_cb" => "tulip_cb",

) : (),
}],
[ 'pcmcia_everywhere', {
arch() !~ /^sparc/ ? (
  "pcmcia_core" => "PCMCIA core support",
  "tcic" => "PCMCIA tcic controller",
  "ds" => "PCMCIA card support",
  "i82365" => "PCMCIA i82365 controller",
) : (),
}],
[ 'paride', {
arch() !~ /^sparc/ ? (
  "aten" => "ATEN EH-100",
  "bpck" => "Microsolutions backpack",
  "comm" => "DataStor (older type) commuter adapter",
  "dstr" => "DataStor EP-2000",
  "epat" => "Shuttle EPAT",
  "epia" => "Shuttle EPIA",
  "fit2" => "Fidelity Intl. (older type)",
  "fit3" => "Fidelity Intl. TD-3000",
  "frpw" => "Freecom Power",
  "friq" => "Freecom IQ (ASIC-2)",
  "kbic" => "KingByte KBIC-951A and KBIC-971A",
  "ktti" => "KT Tech. PHd",
  "on20" => "OnSpec 90c20",
  "on26" => "OnSpec 90c26",
  "pd"   => "Parallel port IDE disks",
  "pcd"  => "Parallel port CD-ROM",
  "pf"   => "Parallel port ATAPI disk",
  "paride" => "Main parallel port module",
) : (),
}],
[ 'raid', {
  "linear" => "linear",
  "raid0" => "raid0",
  "raid1" => "raid1",
  "raid5" => "raid5",
}],
[ 'mouse', {
arch() !~ /^sparc/ ? (
  "busmouse" => "busmouse",
  "msbusmouse" => "msbusmouse",
  "serial" => "serial",
  "qpmouse" => "qpmouse",
  "atixlmouse" => "atixlmouse",

  "usb-uhci", "USB (uhci)",
  "usb-ohci", "USB (ohci)",
  "usb-ohci-hcd", "USB (ohci-hcd)",
) : (),
}],
[ 'fs', {
  "smbfs" => "Windows SMB",
  "fat" => "fat",
  "msdos" => "msdos",
  "romfs" => "romfs",
  "sysv" => "sysv",
  "ufs" => "ufs",
  "umsdos" => "umsdos",
  "vfat" => "vfat",
}],
[ 'other', {
  "st" => "st",
  "sg" => "sg",
  "ide-scsi" => "ide-scsi",
  "loop" => "Loopback device",
  "lp" => "Parallel Printer",
  "ide-floppy" => "ide-floppy",
  "ide-tape" => "ide-tape",
  "nbd" => "nbd",
}],
);

my %type_aliases = (
  scsi => 'disk',
);

my @skip_modules_on_stage1 =
  arch() =~ /alpha/ ? qw(sb1000) :
  ();


my @drivers_fields = qw(text type);
%drivers = ();

foreach (@drivers_by_category) {
    my @l = @$_;
    my $l = pop @l;
    foreach (keys %$l) { $drivers{$_} = [ $l->{$_}, @l ]; }
}
while (my ($k, $v) = each %drivers) {
    my %l; @l{@drivers_fields} = @$v;
    $drivers{$k} = \%l;
}


1;

sub module_of_type($) {
    my ($type) = @_;
    my %skip; @skip{@skip_modules_on_stage1} = ();
    grep { !exists $skip{$_} } grep { $drivers{$_}{type} =~ /^($type)$/ } keys %drivers;
}

sub text_of_type($) {
    my ($type) = @_;
    my $alias = $type_aliases{$type};

    map { $_->{text} } grep { $_->{type} eq $type || $_->{type} eq $alias } values %drivers;
}

sub text2driver($) {
    my ($text) = @_;
    while (my ($k, $v) = each %drivers) {
	$v->{text} eq $text and return $k;
    }
    die "$text is not a valid module description";
}

sub get_alias {
    my ($alias) = @_;
    $conf{$alias}{alias};
}

sub add_alias($$) { 
    my ($alias, $name) = @_;
    /\Q$alias/ && $conf{$_}{alias} && $conf{$_}{alias} eq $name and return $_ foreach keys %conf;
    $alias .= $scsi++ || '' if $alias eq 'scsi_hostadapter';
    log::l("adding alias $alias to $name");
    $conf{$alias}{alias} ||= $name;
    if ($alias eq "sound" && $name =~ /^snd-card-/) {
	$conf{$name}{"post-install"} = "modprobe snd-pcm-oss";
    }
    $alias;
}

sub remove_alias($) {
    my ($name) = @_;
    foreach (keys %conf) {
	$conf{$_}{alias} && $conf{$_}{alias} eq $name or next;
	delete $conf{$_}{alias};
	return 1;
    }
    0;
}

sub load {
    my ($name, $type, @options) = @_;

    if ($::testing) {
	print join ",", @options, "\n";
	log::l("i try to install $name module (@options)");
    } else {
	$conf{$name}{loaded} and return;

	$type ||= ($drivers{$name} || { type => 'unknown'})->{type};

	eval { load($_, 'prereq') } foreach @{$deps{$name}};
	load_raw($name, @options);
    }
    push @{$loaded{$type}}, $name;

    if ($type) {
	add_alias('usb-interface', $name) if $type =~ /SERIAL_USB/i;
	add_alias('scsi_hostadapter', $name) if $type eq "scsi" || $type eq $type_aliases{scsi};
    }
    $conf{$name}{options} = join " ", @options if @options;
}
sub load_multi {
    my $f; $f = sub { map { $f->(@{$deps{$_}}), $_ } @_ };
    my %l; my @l = 
      grep { !$conf{$_}{loaded} }
      grep { my $o = $l{$_}; $l{$_} = 1; !$o }
      $f->(@_);

    $::testing and log::l("i would install modules @l"), return;

    run_program::run("extract_archive", "/lib/modules.cz2", "/tmp", map { "$_.o" } @l);
    run_program::run(["insmod_", "insmod"], "/tmp/$_.o") and $conf{$_}{loaded} = 1 foreach @l;
    unlink map { "/tmp/$_.o" } @l;
}

sub unload($;$) {
    my ($m, $remove_alias) = @_; 
    if ($::testing) {
	log::l("rmmod $m");
    } else {	
	run_program::run("rmmod", $m) && delete $conf{$m}{loaded};
    }
    remove_alias($m) if $remove_alias;
}

sub load_raw($@) {
    my ($name, @options) = @_;

    run_program::run("insmod", $name, @options) or die("insmod $name failed");

    #- this is a hack to make plip go
    if ($name eq "parport_pc") {
	foreach (@options) {
	    /^irq=(\d+)/ or next;
	    log::l("writing to /proc/parport/0/irq");
	    local *F;
	    open F, "> /proc/parport/0/irq" or last;
	    print F $1;
	}
    }
    $conf{$name}{loaded} = 1;
}

sub read_already_loaded() {
    foreach (cat_("/proc/modules", "die")) {
	my ($name) = split;
	$conf{$name}{loaded} = 1;
    }
}

sub load_deps($) {
    my ($file) = @_;

    local *F;
    open F, $file or log::l("error opening $file: $!"), return 0;
    foreach (<F>) {
	my ($f, $deps) = split ':';
	push @{$deps{$f}}, split ' ', $deps;
    }
}

sub read_conf($;$) {
    my ($file, $scsi) = @_;
    my %c;

    foreach (cat_($file)) {
	do {
	    $c{$2}{$1} = $3;
	    $$scsi = max($$scsi, $1 || 0) if /^\s*alias\s+scsi_hostadapter (\d*)/x && $scsi; #- space added to make perl2fcalls happy!
	} if /^\s*(\S+)\s+(\S+)\s+(.*?)\s*$/;
    }
    #- cheating here: not handling aliases of aliases
    while (my ($k, $v) = each %c) {
#-	$$scsi ||= $v->{scsi_hostadapter} if $scsi;
	if (my $a = $v->{alias}) {
	    local $c{$a}{alias};
	    add2hash($c{$a}, $v);
	}
    }
    \%c;
}

sub write_conf {
    my ($file) = @_;

    #- remove the post-install supermount stuff. We may have to add some more
    substInFile { $_ = '' if /^post-install supermount/ } $file;

    my $written = read_conf($file);

    my %net = detect_devices::net2module();
    while (my ($k, $v) = each %net) { add_alias($k, $v) }

    my @l = sort grep { $conf{$_}{alias} && /scsi_hostadapter/ } keys %conf;
    add_alias('block-major-11', 'scsi_hostadapter') if @l;
    push @l, "ide-floppy" if detect_devices::zips();
    $conf{supermount}{"post-install"} = join " ; ", map { "modprobe $_" } @l if @l;

    local *F;
    open F, ">> $file" or die("cannot write module config file $file: $!\n");
    while (my ($mod, $h) = each %conf) {
	while (my ($type, $v2) = each %$h) {
	    print F "$type $mod $v2\n" if $v2 && $type ne "loaded" && !$written->{$mod}{$type};
	}
    }
}

sub read_stage1_conf {
    add2hash(\%conf, read_conf($_[0], \$scsi));
    $conf{parport_lowlevel}{alias} ||= "parport_pc";
    $conf{pcmcia_core}{"pre-install"} ||= "CARDMGR_OPTS=-f /etc/rc.d/init.d/pcmcia start";
    $conf{plip}{"pre-install"} ||= "modprobe parport_pc ; echo 7 > /proc/parport/0/irq";
}

sub load_thiskind($;&$) {
    my ($type, $f, $pcic) = @_;

    require pci_probing::main;
    my @pcidevs = pci_probing::main::probe($type);
    log::l("pci probe found " . scalar @pcidevs . " $type devices");

    my @pcmciadevs = get_pcmcia_devices($type, $pcic);
    log::l("pcmcia probe found " . scalar @pcmciadevs . " $type devices");

    my @devs = (@pcidevs, @pcmciadevs);

    my %devs; foreach (@devs) {
	my ($text, $mod) = @$_;
	pci_probing::main::check($mod) or next;
	$devs{$mod}++ and log::l("multiple $mod devices found"), next;
	log::l("found driver for $mod");
	&$f($text, $mod) if $f;
	load($mod, $type);
    }
    @devs, map { [ $_, $_ ] } @{$loaded{$type} || []};
}

sub pcmcia_need_config($) {
    return $_[0] && ! -s "/var/run/stab";
}

sub get_pcmcia_devices($$) {
    my ($type, $pcic) = @_;
    my (@devs, $module, $desc);

    #- try to setup pcmcia if cardmgr is not running.
    if (pcmcia_need_config($pcic)) {
	log::l("i try to configure pcmcia services");

	symlink("/tmp/stage2/etc/pcmcia", "/etc/pcmcia") unless -e "/etc/pcmcia";
	symlink("/sbin/install", "/sbin/cardmgr") unless -x "/sbin/cardmgr";

	load("pcmcia_core");
	load($pcic);
	load("ds");

	#- run cardmgr in foreground while it is configuring the card.
	run_program::run("cardmgr", "-f", "-m" ,"/modules");
	sleep(3);

	#- make sure to be aware of loaded module by cardmgr.
	read_already_loaded();
    }

    foreach (cat_("/var/run/stab")) {
	$desc = $1 if /^Socket\s+\d+:\s+(.*)/;
	$module = $1 if /^\d+\s+$type[^\s]*\s+([^\s]+)/;
	if ($desc && $module) {
	    push @devs, [ $desc, $module ];
	    $desc = $module = undef;
	}
    }
    @devs;
}