summaryrefslogtreecommitdiffstats
path: root/perl-install/install_steps_stdio.pm
blob: 908d140806c9ed5440f836de853317d92b22d53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package install_steps_stdio;

use diagnostics;
use strict;
use vars qw(@ISA);

@ISA = qw(install_steps_interactive interactive_stdio);

use common qw(:common);
use devices;
use run_program;
use interactive_stdio;
use install_steps_interactive;
use install_any;
use log;

1;

sub enteringStep($$$) {
    my ($o, $step) = @_;
    print _("Starting step `%s'\n", $o->{steps}->{$step}->{text});
}
sub leavingStep {
    my ($o) = @_;
    print "--------\n";
}

sub installPackages {
    my $o = shift;

    my $old = \&log::ld;
    local *log::ld = sub { 
	my $m = shift;
	if ($m =~ /^starting installing/) {
	    my $name = first($_[0] =~ m|([^/]*)-.+?-|);
	    print("installing package $name");
	} else { goto $old }
    };    
    $o->SUPER::installPackages(@_);
}


sub setRootPassword($) {
    my ($o) = @_;
    
    my (%w);
    do {
	$w{password} and print "You must enter the same password, please try again\n";
	print "Password: "; $w{password} = $o->readln(); 
	print "Password (again for confirmation): "; 
    } until ($w{password} eq $o->readln());

    $o->{default}->{rootPassword} = $w{password};
    $o->SUPER::setRootPassword;
}

sub addUser($) {
    my ($o) = @_;
    my %w;
    print "\nCreating a normal user account:\n";
    print "Name: "; $w{name} = $o->readln() or return;
    do {
	$w{password} and print "You must enter the same password, please try again\n";
	print "Password: "; $w{password} = $o->readln(); 
	print "Password (again for confirmation): "; 
    } until ($w{password} eq $o->readln());
    print "Real name: "; $w{realname} = $o->readln();
    
    $w{shell} = $o->ask_from_list('', 'Shell', $o->{default}->{shells}, "/bin/bash");
    
    $o->{default}->{user} = { map { $_ => $w{$_}->get_text } qw(name password realname shell) };
    $o->SUPER::addUser;
}