#!/usr/bin/perl # # Guillaume Cottenceau (gc@mandrakesoft.com) # # Copyright 2001 MandrakeSoft # # This software may be freely redistributed under the terms of the GNU # public license. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # use lib qw(/usr/lib/libDrakX); use common; use interactive; use standalone; use devices; use detect_devices; use steps; use commands; use fs; use Data::Dumper; $::isEmbedded = ($::XID, $::CCPID) = "@ARGV" =~ /--embedded (\w+) (\w+)/; local $_ = join '', @ARGV; /-h/ and die "usage: drakautoinst [--version]\n"; /-version/ and die 'version: $Id: drakautoinst,v 1.1.1.1 2003/06/06 09:53:07 rider Exp $ '."\n"; $::direct = /-direct/; my $in = 'interactive'->vnew('su', 'default'); begin: $::isEmbedded and kill USR2, $::CCPID; my $imagefile = "/root/replay_install.img"; -f $imagefile or $in->ask_okcancel(_("Error!"), _("I can't find needed image file `%s'.", $imagefile), 1), quit_global($in, 0); $::direct or $in->ask_okcancel(_("Auto Install Configurator"), _("You are about to configure an Auto Install floppy. This feature is somewhat dangerous and must be used circumspectly. With that feature, you will be able to replay the installation you've performed on this computer, being interactively prompted for some steps, in order to change their values. For maximum safety, the partitioning and formatting will never be performed automatically, whatever you chose during the install of this computer. Do you want to continue?"), 1) or quit_global($in, 0); my @manual_steps = qw(doPartitionDisks formatPartitions); my @all_steps; my @choices; my $st = \%steps::installSteps; for (my $f = $st->{first}; $f; $f = $st->{$f}{next}) { next if member($f, @manual_steps); my $def_choice = 'replay'; push @choices, { label => _($st->{$f}{text}), val => \$def_choice, list => [ _('replay'), _('manual') ] }; push @all_steps, [ $f, \$def_choice ]; } $in->ask_from(_("Automatic Steps Configuration"), _("Please choose for each step whether it will replay like your install, or it will be manual"), \@choices ) or quit_global($in, 0); ${$_->[1]} eq _('manual') and push @manual_steps, $_->[0] foreach @all_steps; my $mountdir = "/root/tmp/drakautoinst-mountdir"; -d $mountdir or mkdir $mountdir, 0755; my $floppy = detect_devices::floppy(); my $dev = devices::make($floppy); $in->ask_okcancel('', _("Insert a blank floppy in drive %s", $floppy), 1) or quit_global($in, 0); { my $w = $in->wait_message('', _("Creating auto install floppy")); commands::dd("if=$imagefile", "of=$dev", "bs=1440", "count=1024"); common::sync(); } fs::mount($dev, $mountdir, 'vfat', 0); my $cfgfile = "$mountdir/auto_inst.cfg"; eval(cat_($cfgfile)); my $str = join('', "#!/usr/bin/perl -cw # # Special file generated by ``drakautoinst''. # # You should check the syntax of this file before using it in an auto-install. # You can do this with 'perl -cw auto_inst.cfg.pl' or by executing this file # (note the '#!/usr/bin/perl -cw' on the first line). ", Data::Dumper->Dump([$o], ['$o']), q( package install_steps_auto_install; $graphical = 1; ), Data::Dumper->Dump([\@manual_steps], ['$msteps']), q(push @graphical_steps, @$msteps; ), "\0"); $str =~ s/ {8}/\t/g; output($cfgfile, $str); fs::umount($mountdir); $in->ask_okcancel(_("Congratulations!"), _("The floppy has been successfully generated. You may now replay your installation.")); quit_global($in, 0); sub quit_global { my ($in, $exitcode) = @_; $::isEmbedded ? kill USR1, $::CCPID : $in->exit($exitcode); goto begin; }