#!/usr/bin/perl use Config; use MDK::Common; Config->import; my ($arch) = $Config{archname} =~ /(.*?)-/; my $default_append = ''; my $default_acpi = ''; my $default_vga = "vga=788 splash=silent"; my $timeout = 150; my $isolinux_bin = $arch eq 'x86_64' ? '/usr/lib/syslinux/isolinux-x86_64.bin' : '/usr/lib/syslinux/isolinux-i586.bin'; my $lib = $arch eq 'x86_64' ? 'lib64' : 'lib'; my $tmp_mnt = '/tmp/drakx_mnt'; my $tmp_initrd = '/tmp/drakx_initrd'; my $sudo; if ($>) { $sudo = "sudo"; $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; } sub __ { print @_, "\n"; system(@_) } sub _ { __ @_; $? and die } sub mke2fs { my ($f) = @_; _ "/sbin/mke2fs -q -m 0 -F -s 1 $f"; _ "/sbin/tune2fs -c 0 -U clear -T 1970010101 $f"; } _ "mkdir -p $tmp_mnt"; mkdir "images"; my @kernels = chomp_(cat_('all.kernels/.list')); my @all_images = ( if_($arch =~ /i.86/, 'isolinux', 'boot.iso', 'all.img', 'hd_grub.img'), if_($arch =~ /x86_64/, 'isolinux', 'boot.iso', 'all.img', 'hd_grub.img'), if_($arch =~ /ia64/, 'all.img'), if_($arch =~ /ppc/, 'all.img'), ); my @images = @ARGV ? @ARGV : map { "images/$_" } @all_images; foreach my $img (@images) { my ($type, $I, $extension) = $img =~ m!([^/]*)(64)?\.([^.]*)$!; if ($img =~ /hd_grub/) { hd_grub($img); } elsif ($img =~ /isolinux/) { isolinux(\@kernels); if (my ($tftpboot) = grep { -e $_ } qw(/tftpboot /var/lib/tftpboot)) { system("/bin/cp -f isolinux/alt0/* $tftpboot"); } } elsif ($img =~ /boot.iso/) { boot_iso($img, \@kernels); } elsif ($extension eq 'rdz') { initrd($type, $I, "$img-$_") foreach @kernels; } elsif ($extension eq 'img') { print STDERR "calling boot_img_$arch for $img\n"; $::{"boot_img_$arch"}->($type, $I, "$img-$_", "all.kernels/$_/vmlinuz") foreach @kernels; rename("$img-$kernels[0]", $img); } else { die "unknown image $img"; } } sub syslinux_color { "0" . { default => '7', blue => '9', green => 'a', red => 'c', yellow => 'e', white => 'f', }->{$_[0]} || die "unknown color $_[0]\n"; } sub syslinux_msg { my ($msg_xml_file, @more_text) = @_; require XML::Parser; sub xml_tree2syslinux { my ($current_color, $tree) = @_; my (undef, @l) = @$tree; join('', map { my ($type, $val) = @$_; if ($type eq '0') { $val; } else { syslinux_color($type) . xml_tree2syslinux($type, $val) . syslinux_color($current_color); } } group_by2(@l)); } print "parsing $msg_xml_file\n"; my $tree = XML::Parser->new(Style => 'Tree')->parsefile($msg_xml_file); $tree->[0] eq 'document' or die "bad file $msg_xml_file\n"; my $text = xml_tree2syslinux('default', $tree->[1]); pack("C*", 0x0E, 0x80, 0x03, 0x00) . " " . $text . join('', @more_text) . "\n" . syslinux_color('red') . "[F1-Help] [F2-Advanced Help]" . syslinux_color('default') . "\n"; } sub syslinux_cfg { my ($entries, $b_gfxboot) = @_; my $default = 'linux'; my $header = <{append} =~ s/\s+/ /g; "label $_->{label}\n" . " kernel $_->{kernel}\n" . ($_->{initrd} ? " append initrd=$_->{initrd} $_->{append}\n" : ''); } @$entries; $header . ($b_gfxboot ? $header_gfxboot : $header_non_gfxboot) . join('', @l); } sub initrd { my ($type, $I, $img, $o_bootsplash_cfg) = @_; my $stage1_root = $ENV{DEBUGSTAGE1} ? "../mdk-stage1" : "/usr/$lib/drakx-installer-binaries"; _ "rm -rf $tmp_initrd"; mkdir_p("$tmp_initrd$_") foreach qw(/etc /lib /modules /sbin /tmp /var); symlink "../modules", "$tmp_initrd/lib/modules"; symlink "/proc/mounts", "$tmp_initrd/etc/mtab"; symlink "../tmp", "$tmp_initrd/var/run"; _ "install -D /usr/share/terminfo/l/linux $tmp_initrd/usr/share/terminfo/l/linux"; foreach ('pcitable', 'usbtable') { _ "install -D /usr/share/ldetect-lst/$_.gz $tmp_initrd/usr/share/ldetect-lst/$_.gz"; } _ "install -D /usr/share/pci.ids $tmp_initrd/usr/share/pci.ids"; foreach ("/usr/share/ldetect-lst/fallback-modules.alias", "/lib/module-init-tools/ldetect-lst-modules.alias") { _ "install -D $_ $tmp_initrd$_"; } _ "install $stage1_root/init $tmp_initrd/"; foreach ('stage1', 'pppd', 'pppoe') { _ "install $stage1_root/$_ $tmp_initrd/sbin/"; } if ($arch !~ /ppc|ia64/) { mkdir_p("$tmp_initrd/etc/pcmcia"); _ "cp -a /etc/pcmcia/config.opts $tmp_initrd/etc/pcmcia"; } { my ($ext) = $img =~ /rdz-(.*)/ or die "bad initrd name ($img)"; my $modz = "all.kernels$I/$ext"; mkdir_p("$tmp_initrd/modules/$ext"); __ "tar xC $tmp_initrd/modules/$ext -f $modz/${type}_modules.tar"; _ "depmod -b $tmp_initrd $ext"; # depmod keeps only available modules in modules.alias, but we want them all _ "cp -f $modz/modules.alias $modz/modules.description $tmp_initrd/modules/$ext"; } # ka deploy need some files in all.rdz { mkdir_p("$tmp_initrd/$_") foreach qw(sbin dev ka proc sbin var/tmp); symlink("/sbin", "$tmp_initrd/bin"); cp_af("/usr/bin/ka-d-client", "$tmp_initrd/ka/ka-d-client"); cp_af("/usr/bin/mke2fs_diet", "$tmp_initrd/sbin/mke2fs"); cp_af("/usr/bin/busybox", "$tmp_initrd/sbin/busybox"); my @funct = map { /functions:/ .. /^$/ ? do { s/\s//g; split /,/ } : () } `busybox`; shift @funct; symlink('busybox', $tmp_initrd . "/sbin/$_") foreach @funct; } if ($ENV{DEBUGSTAGE1}) { _ "cp -f /usr/bin/busybox $tmp_initrd/sbin"; symlink "busybox", "$tmp_initrd/sbin/$_" foreach qw(cat chgrp chmod chown chroot chvt clear cp cut date dd df dirname dmesg du echo env false find free grep gunzip gzip halt head id init kill killall klogd linuxrc ln logger ls lsmod mkdir mknod mkswap more mount mv poweroff ps pwd reboot reset rm rmdir sed sleep sh sort swapoff swapon sync syslogd tail tar touch true tty umount uname uniq uptime wc which whoami xargs yes zcat); } if ($o_bootsplash_cfg) { _ "splash -s -f $o_bootsplash_cfg > $tmp_initrd/bootsplash"; } my $devs = sprintf "ls /dev/{%s}", join(',', qw(console fb0 fd0 loop3 mem null ppp ptyp0 ram3 tty[0-7] ttyp0 ttyS0)); _ "(cd $tmp_initrd; (find . ; $devs) | cpio -o -c --quiet) | gzip -9 > $img"; _ "rm -rf $tmp_initrd"; } sub entries_append { my ($type) = @_; my $automatic = $type =~ /cdrom/ ? 'automatic=method:cdrom ' : ''; $automatic .= 'changedisk ' if $type =~ /changedisk/; my @simple_entries = ( linux => $default_vga, vgalo => "vga=785", vgahi => "vga=791", text => "text", # patch => "patch $default_vga", rescue => "rescue", ); my @entries = ( (map { $_->[0] => "$automatic$default_acpi $_->[1]" } group_by2(@simple_entries)), noacpi => "$automatic$default_vga acpi=off", restore => "$automatic$default_vga --restore", ); map { { label => $_->[0], append => join(' ', grep { $_ } $default_append, $_->[1]) } } group_by2(@entries); } sub syslinux_cfg_all { my ($type, $b_gfxboot) = @_; syslinux_cfg([ (map { { kernel => 'alt0/vmlinuz', initrd => 'alt0/all.rdz', %$_ }; } entries_append($type)), (map_index { { label => "alt$::i", kernel => "alt$::i/vmlinuz", initrd => "alt$::i/all.rdz", append => join(' ', grep { $_ } $default_append, $default_acpi, $default_vga) }; } @kernels), { label => 'memtest', kernel => 'memtest' }, ], $b_gfxboot); } sub remove_ending_zero { my ($img) = @_; _(q(perl -0777 -pi -e 's/\0+$//' ) . $img); } sub boot_img_i386 { my ($type, $I, $img, $kernel) = @_; _ "rm -rf $tmp_mnt"; mkdir $tmp_mnt; _ "cat $kernel > $tmp_mnt/vmlinuz"; output("$tmp_mnt/help.msg", syslinux_msg('help.msg.xml')); output("$tmp_mnt/advanced.msg", syslinux_msg('advanced.msg.xml')); (my $rdz = $img) =~ s/\.img/.rdz/; (my $initrd_type = $type) =~ s/-changedisk//; initrd($initrd_type, $I, $rdz); my $short_type = substr($type, 0, 8); output("$tmp_mnt/syslinux.cfg", syslinux_cfg([ map { { kernel => 'vmlinuz', initrd => "$short_type.rdz", %$_ }; } entries_append($type) ])); _ "cp -f $rdz $tmp_mnt/$short_type.rdz"; unlink $rdz; my $size = max(chomp_(`du -s -k $tmp_mnt`) + 50, 1440); _ "dd if=/dev/zero of=$img bs=1k count=$size"; _ "mkdosfs-with-dir $tmp_mnt $img"; _ "syslinux $img"; _ "rm -rf $tmp_mnt"; } # alias to x86 variant, slightly bigger with images though sub boot_img_x86_64 { &boot_img_i386 } sub boot_img_alpha { my ($type, $I, $img) = @_; __ "$sudo umount $tmp_mnt 2>/dev/null"; _ "dd if=/dev/zero of=$img bs=1k count=1440"; mke2fs($img); _ "/sbin/e2writeboot $img /boot/bootlx"; _ "$sudo mount -t ext2 $img $tmp_mnt -o loop"; _ "cp -f vmlinux.gz $tmp_mnt"; -f "$type.rdz" ? _ "cp -f $type.rdz $tmp_mnt" : initrd($type, $I, "$tmp_mnt/$type.rdz"); mkdir "$tmp_mnt/etc", 0777; output("$tmp_mnt/etc/aboot.conf", "0:vmlinux.gz initrd=$type.rdz rw $default_append $type 1:vmlinux.gz initrd=$type.rdz rw $default_append text $type "); _ "sync"; _ "df $tmp_mnt"; } sub boot_img_ia64 { my ($type, $_I, $img, $kernel) = @_; my $rdz = $img; $rdz =~ s/\.img/.rdz/; __ "$sudo umount $tmp_mnt 2>/dev/null"; _ "dd if=/dev/zero of=$img bs=1k count=16384"; _ "mkdosfs $img"; _ "$sudo mount -t vfat $img $tmp_mnt -o loop,umask=000"; _ "$sudo cp -f $kernel $tmp_mnt/vmlinux"; _ "cp -f $rdz $tmp_mnt/$type.rdz"; _ "$sudo cp -f tools/ia64/elilo.efi $tmp_mnt"; output("$tmp_mnt/elilo.conf", qq( prompt timeout=50 image=vmlinux label=linux initrd=$type.rdz append=" ramdisk_size=120000" read-only image=vmlinux label=rescue initrd=$type.rdz append=" rescue ramdisk_size=120000" ")); _ "sync"; _ "df $tmp_mnt"; } sub boot_img_sparc { my ($type, $I, $_img) = @_; if ($type =~ /^live(.*)/) { #- hack to produce directly into /export the needed file for cdrom boot. my $dir = "/export"; my $boot = "boot"; #- non-absolute pathname only! _ "mkdir -p $dir/$boot"; _ "cp -f /boot/cd.b /boot/second.b $dir/$boot"; _ "cp -f vmlinux$1 $dir/$boot/vmlinux$1"; -f "live$1.rdz" ? _ "cp -f live$1.rdz $dir/$boot" : initrd($type, $I, "$dir/$boot/live$1.rdz"); output("$dir/$boot/silo.conf", qq( partition=1 default=linux timeout=100 read-write message=/$boot/boot.msg image="cat /$boot/boot.msg" label=1 single-key image="cat /$boot/general.msg" label=2 single-key image="cat /$boot/expert.msg" label=3 single-key image="cat /$boot/rescue.msg" label=4 single-key image="cat /$boot/kickit.msg" label=5 single-key image="cat /$boot/param.msg" label=6 single-key image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=linux alias=install initrd=/$boot/live.rdz append="ramdisk_size=128000" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=text initrd=/$boot/live.rdz append="ramdisk_size=128000 text" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=expert initrd=/$boot/live.rdz append="ramdisk_size=128000 expert" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=ks initrd=/$boot/live.rdz append="ramdisk_size=128000 ks" image[sun4c,sun4d,sun4m]=/$boot/vmlinux label=rescue initrd=/$boot/live.rdz append="ramdisk_size=128000 rescue" image[sun4u]=/$boot/vmlinux64 label=linux alias=install initrd=/$boot/live64.rdz append="ramdisk_size=128000" image[sun4u]=/$boot/vmlinux64 label=text initrd=/$boot/live64.rdz append="ramdisk_size=128000 text" image[sun4u]=/$boot/vmlinux64 label=expert initrd=/$boot/live64.rdz append="ramdisk_size=128000 expert" image[sun4u]=/$boot/vmlinux64 label=ks initrd=/$boot/live64.rdz append="ramdisk_size=128000 ks" image[sun4u]=/$boot/vmlinux64 label=rescue initrd=/$boot/live64.rdz append="ramdisk_size=128000 rescue" ")); output("$dir/$boot/README", " To Build a Bootable CD-ROM, try: genisoimage -R -o t.iso -s /$boot/silo.conf /export "); } elsif ($type =~ /^tftprd(.*)/) { my $dir = "/export"; my $boot = "images"; my $setarch = $1 ? "sparc64" : "sparc32"; _ "mkdir -p $dir/$boot"; -f "$type.rdz" or initrd($type, $I, "$type.rdz"); _ "cp -f vmlinux$1.aout $dir/$boot/$type.img"; _ "$setarch kernel$1/src/arch/sparc$1/boot/piggyback $dir/$boot/$type.img kernel$1/boot/System.map $type.rdz"; } elsif ($type =~ /^tftp(.*)/) { my $dir = "/export"; my $boot = "images"; _ "mkdir -p $dir/$boot"; _ "cp -f vmlinux$1.aout $dir/$boot/$type.img"; } else { my $dir = "floppy"; __ "$sudo umount $tmp_mnt 2>/dev/null"; _ "rm -rf $dir"; _ "mkdir -p $dir"; _ "cp -f /boot/fd.b /boot/second.b $dir"; _ "cp -f vmlinuz$I $dir/vmlinux$I.gz"; -f "$type.rdz" ? _ "cp -f $type.rdz $dir" : initrd($type, $I, "$dir/$type.rdz"); output("$dir/boot.msg", " Welcome to Mandriva Linux 7.1 Press to install or upgrade a system 7mMandriva Linux7m "); output("$dir/silo.conf", qq( partition=1 default=linux timeout=100 read-write message=/boot.msg image=/vmlinux$I.gz label=linux initrd=/$type.rdz append="ramdisk_size=128000 $type" ")); _ "genromfs -d $dir -f /dev/ram -A 2048,/.. -a 512 -V 'DrakX boot disk'"; _ "$sudo mount -t romfs /dev/ram $tmp_mnt"; _ "silo -r $tmp_mnt -F -i /fd.b -b /second.b -C /silo.conf"; _ "$sudo umount $tmp_mnt"; _ "dd if=/dev/ram of=$type.img bs=1440k count=1"; _ "sync"; _ "$sudo mount -t romfs /dev/ram $tmp_mnt"; _ "df $tmp_mnt"; } } sub boot_img_ppc { my ($_type, $I, $_img, $_kernel) = @_; foreach (glob("all.kernels/*")) { my $ext = basename($_); if ($ext =~ /legacy/) { initrd("all", $I, "images/all.rdz-$ext"); _ "mv images/all.rdz-$ext images/all.rdz-legacy"; _ "cp $_/vmlinuz images/vmlinux-legacy"; } elsif ($ext =~ /2.6/) { initrd("all", $I, "images/all.rdz-$ext"); _ "mv images/all.rdz-$ext images/all.rdz"; _ "cp $_/vmlinuz images/vmlinux"; } } _ "cp -f /usr/lib/yaboot/yaboot images/yaboot"; output("images/ofboot.b", ' MacRISC Mandriva Linux PPC bootloader " screen" output load-base release-load-area dev screen " "(0000000000aa00aa0000aaaaaa0000aa00aaaa5500aaaaaa)" drop 0 8 set-colors " "(5555555555ff55ff5555ffffff5555ff55ffffff55ffffff)" drop 8 8 set-colors device-end 3 to foreground-color 0 to background-color " "(0C)" fb8-write drop " Booting Mandriva Linux PPC..." fb8-write drop 100 ms boot cd:,\boot\yaboot 1010 000000000000F8FEACF6000000000000 0000000000F5FFFFFEFEF50000000000 00000000002BFAFEFAFCF70000000000 0000000000F65D5857812B0000000000 0000000000F5350B2F88560000000000 0000000000F6335708F8FE0000000000 00000000005600F600F5FD8100000000 00000000F9F8000000F5FAFFF8000000 000000008100F5F50000F6FEFE000000 000000F8F700F500F50000FCFFF70000 00000088F70000F50000F5FCFF2B0000 0000002F582A00F5000008ADE02C0000 00090B0A35A62B0000002D3B350A0000 000A0A0B0B3BF60000505E0B0A0B0A00 002E350B0B2F87FAFCF45F0B2E090000 00000007335FF82BF72B575907000000 000000000000ACFFFF81000000000000 000000000081FFFFFFFF810000000000 0000000000FBFFFFFFFFAC0000000000 000000000081DFDFDFFFFB0000000000 000000000081DD5F83FFFD0000000000 000000000081DDDF5EACFF0000000000 0000000000FDF981F981FFFF00000000 00000000FFACF9F9F981FFFFAC000000 00000000FFF98181F9F981FFFF000000 000000ACACF981F981F9F9FFFFAC0000 000000FFACF9F981F9F981FFFFFB0000 00000083DFFBF981F9F95EFFFFFC0000 005F5F5FDDFFFBF9F9F983DDDD5F0000 005F5F5F5FDD81F9F9E7DF5F5F5F5F00 0083DD5F5F83FFFFFFFFDF5F835F0000 000000FBDDDFACFBACFBDFDFFB000000 000000000000FFFFFFFF000000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFF0000000000 0000000000FFFFFFFFFFFFFF00000000 00000000FFFFFFFFFFFFFFFFFF000000 00000000FFFFFFFFFFFFFFFFFF000000 000000FFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFFFF0000 00FFFFFFFFFFFFFFFFFFFFFFFFFF0000 00FFFFFFFFFFFFFFFFFFFFFFFFFFFF00 00FFFFFFFFFFFFFFFFFFFFFFFFFF0000 000000FFFFFFFFFFFFFFFFFFFF000000 '); output("images/yaboot.conf", ' init-message = "\nWelcome to Mandriva Linux PPC!\nHit for boot options.\n\n" timeout = 150 device=cd: default = install-gui message=/boot/yaboot.msg image = /boot/vmlinux label = install-gui initrd = /boot/all.gz initrd-size = 34000 append = " ramdisk_size=128000" image = /boot/vmlinux-power4 label = install-gui-power4 initrd = /boot/all-power4.gz initrd-size = 34000 append = " ramdisk_size=128000" image = /boot/vmlinux label = install-text initrd = /boot/all.gz initrd-size = 34000 append = " text ramdisk_size=128000" image = /boot/vmlinux-power4 label = install-text-power4 initrd = /boot/all-power4.gz initrd-size = 34000 append = " text ramdisk_size=128000" image = /boot/vmlinux label = install-gui-old initrd = /boot/all.gz initrd-size = 34000 append = " gui-old ramdisk_size=128000" image = /boot/vmlinux-power4 label = install-gui-old-power4 initrd = /boot/all-power4.gz initrd-size = 34000 append = " gui-old ramdisk_size=128000" image = enet:0,vmlinux label = install-net initrd = enet:0,all.gz initrd-size = 34000 append = " ramdisk_size=128000" image = enet:0,vmlinux-power4 label = install-net-power4 initrd = enet:0,all-power4.gz initrd-size = 34000 append = " ramdisk_size=128000" image = enet:0,vmlinux label = install-net-text initrd = enet:0,all.gz initrd-size = 34000 append = " text ramdisk_size=128000" image = enet:0,vmlinux-power4 label = install-net-text-power4 initrd = enet:0,all-power4.gz initrd-size = 34000 append = " text ramdisk_size=128000" image = /boot/vmlinux label = rescue initrd = /boot/all.gz initrd-size = 34000 append = " rescue ramdisk_size=128000" image = /boot/vmlinux-power4 label = rescue-power4 initrd = /boot/all-power4.gz initrd-size = 34000 append = " rescue ramdisk_size=128000" image = enet:0,vmlinux label = rescue-net initrd = enet:0,all.gz initrd-size = 34000 append = " rescue ramdisk_size=128000" image = enet:0,vmlinux-power4 label = rescue-net-power4 initrd = enet:0,all-power4.gz initrd-size = 34000 append = " rescue ramdisk_size=128000" '); output("images/yaboot.msg", ' Thanks for choosing Mandriva Linux PPC. The following is a short explanation of the various options for booting the install CD. All options ending with "-power4" use the BOOT kernel for ppc 9xx and POWER4. The default syntax with no suffix uses the BOOT kernel for ppc 6xx 7xx and 7xxx. The default if you just hit enter is "install-gui". install-gui: uses Xorg fbdev mode install-text: text based install install-net: allows you to use a minimal boot CD, pulling the rest of the install from a network server install-net-text: text mode network install rescue: boots the rescue image rescue-net: boots the rescue image from a network server '); } sub VERSION { my ($kernels) = @_; map { "$_\n" } $ENV{DISTRIB_DESCR}, scalar gmtime(), '', @$kernels; } sub syslinux_all_files { my ($dir, $kernels) = @_; eval { rm_rf($dir) }; mkdir_p($dir); @$kernels or die "syslinux_all_files: no kernel\n"; $default_vga =~ /788/ or die 'we rely on vga=788 for bootsplash'; my $theme = $ENV{THEME} || 'Mandriva-Free'; my $bootsplash_cfg = "/etc/bootsplash/themes/$theme/config/bootsplash-800x600.cfg"; -e $bootsplash_cfg or die "can't find $bootsplash_cfg"; each_index { mkdir "$dir/alt$::i", 0777; _ "cp all.kernels/$_/vmlinuz $dir/alt$::i"; initrd('all', '', "images/all.rdz-$_", $bootsplash_cfg); rename("images/all.rdz-$_", "$dir/alt$::i/all.rdz"); } @$kernels; _ "install -m 644 -D /boot/memtest* $dir/memtest"; output("$dir/help.msg", syslinux_msg('help.msg.xml')); output("$dir/advanced.msg", syslinux_msg('advanced.msg.xml', "\nYou can choose the following kernels :\n", map_index { " o " . syslinux_color('white') . "alt$::i" . syslinux_color('default') . " is kernel $_\n" } @$kernels)); } sub isolinux { my ($kernels) = @_; syslinux_all_files('isolinux', $kernels); _ "cp $isolinux_bin isolinux/isolinux.bin"; _ "cp /usr/lib/syslinux/gfxboot.com isolinux/gfxboot.com"; output("isolinux/isolinux.cfg", syslinux_cfg_all('cdrom', 1)); xbox_stage1() if arch() =~ /i.86/; } sub xbox_stage1() { my $xbox_kernel = find { /xbox/ } all('all.kernels') or return; my $dir = 'isolinux/xbox'; eval { rm_rf($dir) }; mkdir_p($dir); _ "cp all.kernels/$xbox_kernel/vmlinuz $dir"; initrd('all', '', "images/all.rdz-$xbox_kernel"); rename("images/all.rdz-$xbox_kernel", "$dir/initrd"); _ "cp /usr/share/cromwell/xromwell-installer.xbe $dir/default.xbe"; output("$dir/linuxboot.cfg", < until you reach "HELP END" pause . pause Please see http://qa.mandriva.com/hd_grub.cgi for a friendlier solution pause . pause To specify the location where Mandriva Linux is copied, pause choose "Mandriva Linux Install", and press "e". pause Then change "root (hd0,0)". FYI: pause - (hd0,0) is the first partition on first bios hard drive (usually hda1) pause - (hd0,4) is the first extended partition (usually hda5) pause - (hd1,0) is the first partition on second bios hard drive pause Replace /cooker to suits the directory containing Mandriva Linux pause . pause HELP END EOF _ "mkdosfs-with-dir $tmp_mnt $img"; _ "rm -rf $tmp_mnt"; output($mapfile, "(fd0) $img\n"); open(my $G, "| grub --device-map=$mapfile --batch"); print $G < 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853
package network::netconnect; # $Id$

use strict;
use common;
use log;
use detect_devices;
use list_modules;
use modules;
use mouse;
use services;
use network::network;
use network::tools;
use network::thirdparty;
use network::connection;

sub detect {
    my ($modules_conf, $auto_detect, $o_class) = @_;
    my %l = (
             isdn => sub {
                 require network::connection::isdn;
                 $auto_detect->{isdn} = network::connection::isdn::detect_backend($modules_conf);
             },
             modem => sub {
                 $auto_detect->{modem} = { map { $_->{description} || "$_->{MANUFACTURER}|$_->{DESCRIPTION} ($_->{device})" => $_ } detect_devices::getModem($modules_conf) };
             },
            );
    $l{$_}->() foreach $o_class || keys %l;
    return;
}

sub detect_timezone() {
    my %tmz2country = ( 
		       'Europe/Paris' => N("France"),
		       'Europe/Amsterdam' => N("Netherlands"),
		       'Europe/Rome' => N("Italy"),
		       'Europe/Brussels' => N("Belgium"),
		       'America/New_York' => N("United States"),
		       'Europe/London' => N("United Kingdom")
		      );
    my %tm_parse = MDK::Common::System::getVarsFromSh("$::prefix/etc/sysconfig/clock");
    my @country;
    foreach (keys %tmz2country) {
	if ($_ eq $tm_parse{ZONE}) {
	    unshift @country, $tmz2country{$_};
	} else { push @country, $tmz2country{$_} }
    }
    \@country;
}

sub real_main {
      my ($net, $in, $modules_conf) = @_;
      #- network configuration should have been already read in $net at this point
      my $mouse = $::o->{mouse} || {};
      my (@connections_list, $connection, @providers_data, $provider_name, $protocol_settings, $access_settings, $control_settings);
      my $connection_compat;
      my ($hardware_settings, $network_access_settings, $address_settings, $hostname_settings);
      my ($modem, $modem_name, $modem_dyn_dns, $modem_dyn_ip);
      my ($up);
      my ($isdn, $isdn_name, $isdn_type, %isdn_cards, @isdn_dial_methods);
      my $my_isdn = join('', N("Manual choice"), " (", N("Internal ISDN card"), ")");
      my $success = 1;
      my $db_path = "/usr/share/apps/kppp/Provider";
      my (%countries, @isp, $country, $provider, $old_provider);

      my $system_file = '/etc/sysconfig/drakx-net';
      my %global_settings = getVarsFromSh($system_file);

      my $_w = N("Protocol for the rest of the world");
      my %isdn_protocols = (
                            2 => N("European protocol (EDSS1)"),
                            3 => N("Protocol for the rest of the world\nNo D-Channel (leased lines)"),
                           );

      $net->{autodetect} = {};

      my %ppp_auth_methods = (
                              0 => N("Script-based"),
                              1 => N("PAP"),
                              2 => N("Terminal-based"),
                              3 => N("CHAP"),
                              4 => N("PAP/CHAP"),
                             );

      my %steps_compat = (
          'network::connection::isdn' => 'isdn',
          'network::connection::pots' => 'modem',
      );

      my $get_next = sub {
          my ($step) = @_;
          my @steps = (
              "select_connection" => sub { 0 },
              "configure_hardware" => sub { $connection->can('get_hardware_settings') && !$connection->{device}{no_hardware_settings} },
              #- network is for example wireless/3G access point
              "select_network" => sub { $connection->can('get_networks') },
              "configure_network_access" => sub { $connection->can('get_network_access_settings') },
              #- allow to select provider after network
              "select_provider" => sub { $connection->can('get_providers') },
              #- protocol may depend on provider settings (xDSL)
              "select_protocol" => sub { $connection->can('get_protocols') },
              #- peer settings may depend on provider and protocol (VPI/VCI for xDSL)
              "configure_access" => sub { $connection->can('get_access_settings') },
              "configure_address" => sub { ($connection->can('get_address_settings') || $connection->can('get_hostname_settings')) && !text2bool($global_settings{AUTOMATIC_ADDRESS}) },
              "configure_control" => sub { $connection->can('get_control_settings') },
              "apply_connection" => sub { 1 },
          );
          my $can;
          foreach (group_by2(@steps)) {
              $can && $_->[1]->() and return $_->[0];
              $can ||= $_->[0] eq $step;
          }
      };

      use locale;
      set_l10n_sort();

      require wizards;
      my $wiz = wizards->new(
        {
         defaultimage => "drakconnect.png",
         name => N("Network & Internet Configuration"),
         pages => {
                   welcome => {
                    pre => sub { undef $net->{type} },
                    if_(!$::isInstall, no_back => 1),
                    name => N("Choose the connection you want to configure"),
                    interactive_help_id => 'configureNetwork',
                    data => [ { list => [ network::connection::get_types ],
                                type => 'list', val => \$net->{type}, format => sub { $_[0] && $_[0]->get_type_description },
                                gtk => { use_scrolling => 1 } } ],
                    complete => sub {
                        my @packages = $net->{type}->can('get_packages') ? $net->{type}->get_packages : ();
                        if (@packages && !$in->do_pkgs->install(@packages)) {
                            $in->ask_warn(N("Error"), N("Could not install the packages (%s)!", join(', ', @packages)));
                            1;
                        }
                    },
                    post => sub {
                        if (exists $steps_compat{$net->{type}}) {
                            return $steps_compat{$net->{type}};
                        }
                        @connections_list = $net->{type}->get_connections(automatic_only => text2bool($global_settings{AUTOMATIC_IFACE_CHOICE}));
                        @connections_list ? "select_connection" : "no_connection";
                    },
                   },

                   select_connection => {
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Select the network interface to configure:") },
                       data => [ { val => \$connection, type => 'list', list => \@connections_list,
                                   format => sub { $_[0] && $_[0]->get_description }, allow_empty_list => !text2bool($global_settings{AUTOMATIC_IFACE_CHOICE})} ],
                       complete => sub {
                           $connection->setup_thirdparty($in) or return 1;
                           $connection->prepare_device;
                           if ($connection->can("check_device") && !$connection->check_device) {
                               $in->ask_warn('', $connection->{device}{error});
                               return 1;
                           }
                           return 0;
                       },
                       post => sub {
                           $connection->load_interface_settings;
                           $get_next->("select_connection");
                       },
                   },

                   no_connection => {
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("No device can be found for this connection type.") },
                       end => 1,
                   },

                   configure_hardware => {
                       pre => sub {
                           $hardware_settings = $connection->get_hardware_settings;
                           $connection->guess_hardware_settings if $connection->can('guess_hardware_settings');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Hardware Configuration") },
                       data => sub { $hardware_settings },
                       complete => sub {
                           if ($connection->can("check_hardware_settings") && !$connection->check_hardware_settings) {
                               $in->ask_warn('', $connection->{hardware}{error});
                               return 1;
                           }
                           if ($connection->can('check_hardware')) {
                               my $_w = $in->wait_message(N("Please wait"), N("Configuring device..."));
                               if (!$connection->check_hardware) {
                                   $in->ask_warn(N("Error"), $connection->{hardware}{error}) if $connection->{hardware}{error};
                                   return 1;
                               }
                           }
                       },
                       post => sub { $get_next->("configure_hardware") },
                   },

                   select_provider => {
                       pre => sub {
                           @providers_data = $connection->get_providers;
                           require lang;
                           my $locale_country = lang::c2name($::o->{locale}{country} || lang::read()->{country});
                           my $separator = $providers_data[1];
                           $provider_name = find { /^\Q$locale_country$separator\E/ } sort(keys %{$providers_data[0]});
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Please select your provider:") },
                       data => sub {
                           [ { type => "list", val => \$provider_name, separator => $providers_data[1],
                               list => [ N("Unlisted - edit manually"), sort(keys %{$providers_data[0]}) ], sort => 0 } ];
                       },
                       post => sub {
                           if ($provider ne N("Unlisted - edit manually")) {
                               $connection->set_provider($providers_data[0]{$provider_name});
                           }
                           $get_next->("select_provider");
                       },
                   },

                   select_network => {
                       pre => sub {
                           my $_w = $in->wait_message(N("Please wait"), N("Scanning for networks..."));
                           $connection->get_networks;
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Please select your network:") },
                       data => sub {
                           [ { type => "list", val => \$connection->{network}, allow_empty_list => 1,
                               list => [ keys %{$connection->{networks}}, undef ], gtk => { use_scrolling => 1 },
                               format => sub { exists $connection->{networks}{$_[0]} ?
                                                 $connection->{networks}{$_[0]}{name} :
                                                 N("Unlisted - edit manually");
                                               } } ];
                       },
                       post => sub {
                           $get_next->("select_network");
                       },
                   },

                   configure_network_access => {
                       pre => sub {
                           $network_access_settings = $connection->get_network_access_settings;
                           $connection->guess_network_access_settings if $connection->can('guess_network_access_settings');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . $connection->get_network_access_settings_label },
                       data => sub { $network_access_settings },
                       complete => sub {
                           if ($connection->can('check_network_access_settings') && !$connection->check_network_access_settings) {
                               $in->ask_warn(N("Error"), $connection->{network_access}{error}{message});
                               my $index = eval { find_index { $_->{val} eq $connection->{network_access}{error}{field} } @$network_access_settings };
                               return 1, $index;
                           }
                           return 0;
                       },
                       post => sub { $get_next->("configure_network_access") },
                   },

                   select_protocol => {
                       pre => sub {
                           $protocol_settings = $connection->get_protocol_settings;
                           $connection->guess_protocol($net) if $connection->can('guess_protocol');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Please select your connection protocol.
If you do not know it, keep the preselected protocol.") },
                       data => sub { $protocol_settings },
                       post => sub { $get_next->("select_protocol") },
                   },

                   configure_access => {
                       pre => sub {
                           $access_settings = $connection->get_access_settings;
                           $connection->guess_access_settings if $connection->can('guess_access_settings');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . $connection->get_access_settings_label },
                       data => sub { $access_settings },
                       post => sub { $get_next->("configure_access") },
                   },

                   configure_address => {
                       pre => sub {
                           $address_settings = $connection->can('get_address_settings') && $connection->get_address_settings;
                           $connection->guess_address_settings if $connection->can('guess_address_settings');
                           $hostname_settings = $connection->can('get_hostname_settings') && $connection->get_hostname_settings;
                           $connection->guess_hostname_settings if $connection->can('guess_hostname_settings');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . $connection->get_address_settings_label },
                       data => sub { [ @$address_settings, @$hostname_settings ] },
                       complete => sub {
                           if ($connection->can('check_address_settings') && !$connection->check_address_settings($net)) {
                               $in->ask_warn(N("Error"), $connection->{address}{error}{message});
                               my $index = eval { find_index { $_->{val} eq $connection->{address}{error}{field} } @$address_settings };
                               return 1, $index;
                           }
                           return 0;
                       },
                       post => sub { $get_next->("configure_address") },
                   },

                   configure_control => {
                       pre => sub {
                           $control_settings = $connection->get_control_settings;
                           $connection->can('get_network_control_settings') and
                             push @$control_settings, @{$connection->get_network_control_settings};
                           $connection->guess_control_settings if $connection->can('guess_control_settings');
                           $connection->guess_network_control_settings if $connection->can('guess_network_control_settings');
                       },
                       name => sub { $net->{type}->get_type_name . "\n\n" . N("Connection control") },
                       data => sub { $control_settings },
                       post => sub { $get_next->("configure_control") },
                   },

                   apply_connection => {
                       name => N("Do you want to start the connection now?"),
                       type => "yesorno",
                       complete => sub {
                           $connection->can('install_packages') && !$connection->install_packages($in);
                       },
                       post => sub {
                           my ($answer) = @_;
                           my $_w = $in->wait_message(N("Please wait"), N("Testing your connection..."), 1);
                           $connection->unload_connection if $connection->can('unload_connection');
                           $connection->write_settings($net, $modules_conf);
                           $connection->prepare_connection if $connection->can('prepare_connection');
                           if ($answer) {
                               $connection->disconnect;
                               $connection->connect;
                               #- FIXME: should use network::test for ppp (after future merge with network::connection)
                               #- or start interface synchronously
                               services::start('network-up') unless $::isInstall;
                           }
                           "end"; #- handle disconnection in install?
                       },
                   },

                   isdn_account =>
                   {
                    pre => sub {
                        network::connection::isdn::get_info_providers_backend($isdn, $provider);
                        $isdn->{huptimeout} ||= 180;
                    },
                    name => N("Connection Configuration") . "\n\n" . N("Please fill or check the field below"),
                    data => sub {
			[
			 { label => N("Your personal phone number"), val => \$isdn->{phone_in} },
			 { label => N("Provider name (ex provider.net)"), val => \$net->{resolv}{DOMAINNAME2} },
			 { label => N("Provider phone number"), val => \$isdn->{phone_out} },
			 { label => N("Provider DNS 1 (optional)"), val => \$net->{resolv}{dnsServer2} },
			 { label => N("Provider DNS 2 (optional)"), val => \$net->{resolv}{dnsServer3} },
			 { label => N("Dialing mode"),  list => ["auto", "manual"], val => \$isdn->{dialing_mode} },
			 { label => N("Connection speed"), list => ["64 Kb/s", "128 Kb/s"], val => \$isdn->{speed} },
			 { label => N("Connection timeout (in sec)"), val => \$isdn->{huptimeout} },
			 { label => N("Account Login (user name)"), val => \$isdn->{login} },
			 { label => N("Account Password"),  val => \$isdn->{passwd}, hidden => 1 },
			 { label => N("Card IRQ"), val => \$isdn->{irq}, advanced => 1 },
			 { label => N("Card mem (DMA)"), val => \$isdn->{mem}, advanced => 1 },
			 { label => N("Card IO"), val => \$isdn->{io}, advanced => 1 },
			 { label => N("Card IO_0"), val => \$isdn->{io0}, advanced => 1 },
			 { label => N("Card IO_1"), val => \$isdn->{io1}, advanced => 1 },
			];
		    },
                    post => sub {
                        network::connection::isdn::apply_config($in, $isdn);
                        $net->{net_interface} = 'ippp0';
                        "isdn_dial_on_boot";
                    },
                   },

                   isdn =>
                   {
                    pre=> sub {
                        detect($modules_conf, $net->{autodetect}, 'isdn');
                        %isdn_cards = map { $_->{description} => $_ } @{$net->{autodetect}{isdn}};
                    },
                    name => N("Select the network interface to configure:"),
                    data =>  sub {
                        [ { label => N("Net Device"), type => "list", val => \$isdn_name, allow_empty_list => 1,
                            list => [ $my_isdn, N("External ISDN modem"), keys %isdn_cards ] } ];
                    },
                    post => sub {
                        if ($isdn_name eq $my_isdn) {
                            return "isdn_ask";
                        } elsif ($isdn_name eq N("External ISDN modem")) {
                            $net->{type} = 'isdn_external';
                            return "modem";
                        }

                        # FIXME: some of these should be taken from isdn db
                        $isdn = { map { $_ => $isdn_cards{$isdn_name}{$_} } qw(description vendor id card_type driver type mem io io0 io1 irq firmware) };

                        if ($isdn->{id}) {
                            log::explanations("found isdn card : $isdn->{description}; vendor : $isdn->{vendor}; id : $isdn->{id}; driver : $isdn->{driver}\n");
                            $isdn->{description} =~ s/\|/ -- /;
                        }

                        network::connection::isdn::read_config($isdn);
                        $isdn->{driver} = $isdn_cards{$isdn_name}{driver}; #- do not let config overwrite default driver

                        #- let the user choose hisax or capidrv if both are available
                        $isdn->{driver} ne "capidrv" && network::connection::isdn::get_capi_card($in, $isdn) and return "isdn_driver";
                        return "isdn_protocol";
                    },
                   },


                   isdn_ask =>
                   {
                    pre => sub {
                        %isdn_cards = network::connection::isdn::get_cards();
                    },
                    name => N("Select a device!"),
                    data => sub { [ { label => N("Net Device"), val => \$isdn_name, type => 'list', separator => '|', list => [ keys %isdn_cards ], allow_empty_list => 1 } ] },
                    pre2 => sub {
                        my ($label) = @_;

                        #- ISDN card already detected
                        goto isdn_ask_step_3;

                      isdn_ask_step_1:
                        my $e = $in->ask_from_list_(N("ISDN Configuration"),
                                                    $label . "\n" . N("What kind of card do you have?"),
                                                    [ N_("ISA / PCMCIA"), N_("PCI"), N_("USB"), N_("I do not know") ]
                                                   ) or return;
                      isdn_ask_step_1b:
                        if ($e =~ /PCI/) {
                            $isdn->{card_type} = 'pci';
                        } elsif ($e =~ /USB/) {
                            $isdn->{card_type} = 'usb';
                        } else {
                            $in->ask_from_list_(N("ISDN Configuration"),
                                                N("
If you have an ISA card, the values on the next screen should be right.\n
If you have a PCMCIA card, you have to know the \"irq\" and \"io\" of your card.
"),
                                                [ N_("Continue"), N_("Abort") ]) eq 'Continue' or goto isdn_ask_step_1;
                            $isdn->{card_type} = 'isa';
                        }

                      isdn_ask_step_2:
                        $e = $in->ask_from_listf(N("ISDN Configuration"),
                                                 N("Which of the following is your ISDN card?"),
                                                 sub { $_[0]{description} },
                                                 [ network::connection::isdn::get_cards_by_type($isdn->{card_type}) ]) or goto($isdn->{card_type} =~ /usb|pci/ ? 'isdn_ask_step_1' : 'isdn_ask_step_1b');
                        $e->{$_} and $isdn->{$_} = $e->{$_} foreach qw(driver type mem io io0 io1 irq firmware);

                        },
                    post => sub {
                        $isdn = $isdn_cards{$isdn_name};
                        return "isdn_protocol";
                    }
                   },


                   isdn_driver =>
                   {
                    pre => sub {
                        $isdn_name = "capidrv";
                    },
                    name => N("A CAPI driver is available for this modem. This CAPI driver can offer more capabilities than the free driver (like sending faxes). Which driver do you want to use?"),
                    data => sub { [
                                   { label => N("Driver"), type => "list", val => \$isdn_name,
                                     list => [ $isdn->{driver}, "capidrv" ] }
                                  ] },
                    post => sub {
                        $isdn->{driver} = $isdn_name;
                        return "isdn_protocol";
                    }
                   },


                   isdn_protocol =>
                   {
                    name => N("ISDN Configuration") . "\n\n" . N("Which protocol do you want to use?"),
                    data => [
                             { label => N("Protocol"), type => "list", val => \$isdn_type,
                               list => [ keys %isdn_protocols ], format => sub { $isdn_protocols{$_[0]} } }
                            ],
                    post => sub { 
                        $isdn->{protocol} = $isdn_type;
                        return "isdn_db";
                    }
                   },


                   isdn_db =>
                   {
                    name => N("ISDN Configuration") . "\n\n" . N("Select your provider.\nIf it is not listed, choose Unlisted."),
                    data => sub {
                        [ { label => N("Provider:"), type => "list", val => \$provider, separator => '|',
                            list => [ N("Unlisted - edit manually"), network::connection::isdn::read_providers_backend() ] } ];
                    },
		    next => "isdn_account",
                   },


                   no_supported_winmodem =>
                   {
                    name => N("Warning") . "\n\n" . N("Your modem is not supported by the system.
Take a look at http://www.linmodems.org"),
                    end => 1,
                   },


                   modem =>
                   {
                    pre => sub {
			require network::modem;
			detect($modules_conf, $net->{autodetect}, 'modem');
			$modem = {};
			if ($net->{type} eq 'isdn_external') {
			    #- FIXME: seems to be specific to ZyXEL Adapter Omni.net/TA 128/Elite 2846i
			    #- it does not even work with TA 128 modems
			    #- http://bugs.mandrakelinux.com/query.php?bug=1033
			    $modem->{special_command} = 'AT&F&O2B40';
			}
                    },
                    name => N("Select the modem to configure:"),
                    data => sub {
                        [ { label => N("Modem"), type => "list", val => \$modem_name, allow_empty_list => 1,
                            list => [ keys %{$net->{autodetect}{modem}}, N("Manual choice") ], } ];
                    },
		    complete => sub {
                        my $driver = $net->{autodetect}{modem}{$modem_name}{driver} or return 0;
                        #- some modem configuration programs modify modprobe.conf while we're loaded
                        #- so write it now and reload then
                        $modules_conf->write;
                        require network::connection::pots;
                        my $settings = network::thirdparty::apply_settings($in, 'pots', network::connection::pots::get_thirdparty_settings(), $driver);
                        $modem->{device} = $settings->{device} if $settings;
                        $modules_conf->read if $settings;
                        !$settings;
		    },
                    post => sub {
                        return 'choose_serial_port' if $modem_name eq N("Manual choice");
			if (exists $net->{autodetect}{modem}{$modem_name}{device}) {
			    #- this is a serial probed modem
			    $modem->{device} = $net->{autodetect}{modem}{$modem_name}{device};
			}
			if (exists $modem->{device}) {
			    return "ppp_provider";
			} else {
			    #- driver exists but device field hasn't been filled by network::thirdparty::setup_device
			    return "no_supported_winmodem";
			}
		    },
		   },


                   choose_serial_port =>
                   {
                    pre => sub {
                        $modem->{device} ||= readlink "$::prefix/dev/modem";
                    },
                    name => N("Please choose which serial port your modem is connected to."),
                    interactive_help_id => 'selectSerialPort',
                    data => sub {
                        [ { val => \$modem->{device}, format => \&mouse::serial_port2text, type => "list",
                            list => [ grep { $_ ne $mouse->{device} } (mouse::serial_ports(), glob_("/dev/ttyUSB*"), grep { -e $_ } '/dev/modem', '/dev/ttySL0', '/dev/ttyS14',) ] } ];
                        },
                    post => sub {
                        return 'ppp_provider';
                    },
                   },


                   ppp_provider =>
                   {
                    pre => sub {
                        add2hash($modem, network::modem::ppp_read_conf());
                        $in->do_pkgs->ensure_is_installed('kdenetwork-kppp-provider', $db_path);
                        my $p_db_path = "$::prefix$db_path";
                        @isp = map {
                            my $country = $_;
                            map { 
                                s!$p_db_path/$country!!;
                                s/%([0-9]{3})/chr(int($1))/eg;
                                $countries{$country} ||= translate($country);
                                join('', $countries{$country}, $_);
                            } grep { !/.directory$/ } glob_("$p_db_path/$country/*");
                        } map { s!$p_db_path/!!o; s!_! !g; $_ } glob_("$p_db_path/*") if !@isp;
                        $old_provider = $provider;
                    },
                    name => N("Select your provider:"),
                    data => sub {
                        [ { label => N("Provider:"), type => "list", val => \$provider, separator => '/',
                            list => [ N("Unlisted - edit manually"), @isp ] } ];
                    },
                    post => sub {
                        if ($provider ne N("Unlisted - edit manually")) {
                            ($country, $provider) = split('/', $provider);
                            $country = { reverse %countries }->{$country};
                            my %l = getVarsFromSh("$::prefix$db_path/$country/$provider");
                            if (defined $old_provider && $old_provider ne $provider) {
                                $modem->{connection} = $l{Name};
                                $modem->{phone} = $l{Phonenumber};
                                $modem->{$_} = $l{$_} foreach qw(Authentication AutoName Domain Gateway IPAddr SubnetMask);
                                ($modem->{dns1}, $modem->{dns2}) = split(',', $l{DNS});
                            }
                        }
                        return "ppp_account";
                    },
                   },


                   ppp_account =>
                   {