summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>1999-10-08 11:42:45 +0000
committerPascal Rigaux <pixel@mandriva.com>1999-10-08 11:42:45 +0000
commit0f48e147d39575f98db29f7e21d5347e6e309d04 (patch)
treefba03e3d6c57d3b202f973fc11907372dd26f64e /perl-install
parentc5a4cbe6c55d38bcc411bd94f088f36b85681899 (diff)
downloaddrakx-0f48e147d39575f98db29f7e21d5347e6e309d04.tar
drakx-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.gz
drakx-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.bz2
drakx-0f48e147d39575f98db29f7e21d5347e6e309d04.tar.xz
drakx-0f48e147d39575f98db29f7e21d5347e6e309d04.zip
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/Makefile2
-rw-r--r--perl-install/Xconfigurator.pm2
-rw-r--r--perl-install/common.pm16
-rw-r--r--perl-install/fs.pm54
-rw-r--r--perl-install/fsedit.pm51
-rw-r--r--perl-install/help.pm14
-rw-r--r--perl-install/install2.pm123
-rw-r--r--perl-install/install_any.pm84
-rw-r--r--perl-install/install_steps.pm6
-rw-r--r--perl-install/install_steps_interactive.pm79
-rw-r--r--perl-install/modules.pm7
-rw-r--r--perl-install/partition_table_raw.pm17
-rw-r--r--perl-install/pkgs.pm5
-rw-r--r--perl-install/printer.pm11
14 files changed, 271 insertions, 200 deletions
diff --git a/perl-install/Makefile b/perl-install/Makefile
index 1f1db5421..90f4a88f6 100644
--- a/perl-install/Makefile
+++ b/perl-install/Makefile
@@ -170,7 +170,7 @@ as_root:
chmod a+w /mnt/initrd
full_stage2: $(BASE)/depslist $(BASE)/hdlist
- rm -rf $(DEST)
+ sudo rm -rf $(DEST)
mkdir -p $(DEST)
$(MAKE) get_needed_files
$(MAKE) stage2
diff --git a/perl-install/Xconfigurator.pm b/perl-install/Xconfigurator.pm
index 260391894..5d57a2521 100644
--- a/perl-install/Xconfigurator.pm
+++ b/perl-install/Xconfigurator.pm
@@ -423,7 +423,7 @@ sub chooseResolutions($$;$) {
),
),
0, gtkadd($W->create_okcancel,
- gtksignal_connect(new Gtk::Button('Show all'), clicked => sub { $W->{retval} = 1; $chosen_w = 0; Gtk->main_quit })),
+ gtksignal_connect(new Gtk::Button(_("Show all")), clicked => sub { $W->{retval} = 1; $chosen_w = 0; Gtk->main_quit })),
));
$depth_combo->disable_activate;
$depth_combo->set_use_arrows_always(1);
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 8d6bf4307..f2d458a26 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -8,7 +8,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $printable_chars $sizeof_int $bitof_int
%EXPORT_TAGS = (
common => [ qw(__ even odd min max sqr sum sign product bool listlength bool2text text2bool to_int to_float ikeys member divide is_empty_array_ref is_empty_hash_ref add2hash add2hash_ set_new set_add round round_up round_down first second top uniq translate untranslate warp_text formatAlaTeX) ],
functional => [ qw(fold_left compose map_index grep_index map_each grep_each map_tab_hash mapn mapn_ difference2 before_leaving catch_cdie cdie) ],
- file => [ qw(dirname basename touch all glob_ cat_ chop_ mode) ],
+ file => [ qw(dirname basename touch all glob_ cat_ chop_ mode typeFromMagic) ],
system => [ qw(sync makedev unmakedev psizeof strcpy gettimeofday syscall_ crypt_ getVarsFromSh setVarsInSh) ],
constant => [ qw($printable_chars $sizeof_int $bitof_int $SECTORSIZE) ],
);
@@ -354,6 +354,20 @@ sub bestMatchSentence2 {
$bestSentence;
}
+sub typeFromMagic($@) {
+ my $f = shift;
+ local *F; sysopen F, $f, 0 or return;
+
+ my $tmp;
+ foreach (@_) {
+ my ($name, $offset, $signature) = @$_;
+ sysseek(F, $offset, 0) or next;
+ sysread(F, $tmp, length $signature);
+ $tmp eq $signature and return $name;
+ }
+ undef;
+}
+
#-######################################################################################
#- Wonderful perl :(
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index 23ef5e380..55f7367a9 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -3,7 +3,7 @@ package fs;
use diagnostics;
use strict;
-use common qw(:common :file :system);
+use common qw(:common :file :system :functional);
use log;
use devices;
use partition_table qw(:types);
@@ -16,7 +16,6 @@ use modules;
1;
-
sub read_fstab($) {
my ($file) = @_;
@@ -39,7 +38,7 @@ sub check_mounted($) {
open H, "/proc/swaps";
foreach (<F>, <G>, <H>) {
foreach my $p (@$fstab) {
- /$p->{device}\s+([^\s]*)\s+/ and $p->{currentMntpoint} = $1, $p->{isMounted} = $p->{isFormatted} = 1;
+ /$p->{device}\s+([^\s]*)\s+/ and $p->{realMntpoint} = $1, $p->{isMounted} = $p->{isFormatted} = 1;
}
}
}
@@ -139,8 +138,8 @@ sub umount($) {
foreach (@mtab) { print F $_ unless /(^|\s)$mntpoint\s/; }
}
-sub mount_part($;$) {
- my ($part, $prefix) = @_;
+sub mount_part($;$$) {
+ my ($part, $prefix, $rdonly) = @_;
$part->{isMounted} and return;
@@ -148,8 +147,7 @@ sub mount_part($;$) {
swap::swapon($part->{device});
} else {
$part->{mntpoint} or die "missing mount point";
- mount(devices::make($part->{device}), ($prefix || '') . $part->{mntpoint}, type2fs($part->{type}),
- $part->{mntreadonly} ? 1 : 0);
+ mount(devices::make($part->{device}), ($prefix || '') . $part->{mntpoint}, type2fs($part->{type}), $rdonly);
}
$part->{isMounted} = $part->{isFormatted} = 1; #- assume that if mount works, partition is formatted
}
@@ -189,36 +187,29 @@ sub umount_all($;$) {
#- do some stuff before calling write_fstab
sub write($$) {
my ($prefix, $fstab) = @_;
- my @cd_drives = detect_devices::cdroms();
-
- log::l("scanning /proc/mounts for iso9660 filesystems");
- unshift @cd_drives, grep { $_->{type} eq 'iso9660' } read_fstab("/proc/mounts");
- log::l("found cdrom drive(s) " . join(', ', map { $_->{device} } @cd_drives));
-
- #- cd-rom rooted installs have the cdrom mounted on /dev/root which
- #- is not what we want to symlink to /dev/cdrom.
- my $cddev = first(grep { $_ ne 'root' } map { $_->{device} } @cd_drives);
log::l("resetting /etc/mtab");
local *F;
open F, "> $prefix/etc/mtab" or die "error resetting $prefix/etc/mtab";
- if ($cddev) {
- mkdir "$prefix/mnt/cdrom", 0755 or log::l("failed to mkdir $prefix/mnt/cdrom: $!");
- symlink $cddev, "$prefix/dev/cdrom" or log::l("failed to symlink $prefix/dev/cdrom: $!");
- }
- write_fstab($fstab, $prefix, $cddev);
-
- return if $::g_auto_install;
-
- devices::make "$prefix/dev/$_->{device}" foreach grep { $_->{device} && !isNfs($_) } @$fstab;
+ my @to_add = (
+ [ split ' ', '/dev/fd0 /mnt/floppy auto sync,user,noauto,nosuid,nodev,unhide 0 0' ],
+ [ split ' ', 'none /proc proc defaults 0 0' ],
+ [ split ' ', 'none /dev/pts devpts mode=0620 0 0' ],
+ map_index {
+ my $i = $::i ? $::i + 1 : '';
+ mkdir "$prefix/mnt/cdrom$i", 0755 or log::l("failed to mkdir $prefix/mnt/cdrom$i: $!");
+ symlink $_->{device}, "$prefix/dev/cdrom$i" or log::l("failed to symlink $prefix/dev/cdrom$i: $!");
+ [ "/dev/cdrom$i", "/mnt/cdrom$i", "auto", "user,noauto,nosuid,exec,nodev,ro", 0, 0 ];
+ } detect_devices::cdroms());
+ write_fstab($fstab, $prefix, @to_add);
}
sub write_fstab($;$$) {
- my ($fstab, $prefix, $cddev) = @_;
+ my ($fstab, $prefix, @to_add) = @_;
$prefix ||= '';
- my @to_add =
+ unshift @to_add,
map {
my ($dir, $options, $freq, $passno) = qw(/dev/ defaults 0 0);
$options ||= $_->{options};
@@ -226,17 +217,12 @@ sub write_fstab($;$$) {
isExt2($_) and ($freq, $passno) = (1, ($_->{mntpoint} eq '/') ? 1 : 2);
isNfs($_) and ($dir, $options) = ('', 'ro');
+ devices::make("$prefix/$dir$_->{device}") if $_->{device} && $dir;
+
[ "$dir$_->{device}", $_->{mntpoint}, type2fs($_->{type}), $options, $freq, $passno ];
} grep { $_->{mntpoint} && type2fs($_->{type}) } @$fstab;
- {
- push @to_add, [ split ' ', '/dev/fd0 /mnt/floppy auto sync,user,noauto,nosuid,nodev,unhide 0 0' ];
- push @to_add, [ split ' ', '/dev/cdrom /mnt/cdrom auto user,noauto,nosuid,exec,nodev,ro 0 0' ] if $cddev;
- push @to_add, [ split ' ', 'none /proc proc defaults 0 0' ];
- push @to_add, [ split ' ', 'none /dev/pts devpts mode=0620 0 0' ];
- }
-
#- get the list of devices and mntpoint
my @new = grep { $_ ne 'none' } map { @$_[0,1] } @to_add;
my %new; @new{@new} = undef;
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index c4e43e148..cdebe6608 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -6,11 +6,14 @@ use strict;
#-######################################################################################
#- misc imports
#-######################################################################################
-use common qw(:common :constant :functional);
+use common qw(:common :constant :functional :file);
use partition_table qw(:types);
use partition_table_raw;
+use detect_devices;
use Data::Dumper;
+use fsedit;
use devices;
+use fs;
use log;
#-#####################################################################################
@@ -29,6 +32,13 @@ my @suggestions = (
my @suggestions_mntpoints = qw(/mnt/dos);
+my @partitions_signatures = (
+ [ 0x83, 0x438, "\xEF\x53" ],
+ [ 0x82, 4086, "SWAP-SPACE" ],
+);
+
+sub typeOfPart($) { typeFromMagic(devices::make($_[0]), @partitions_signatures) }
+
#-######################################################################################
#- Functions
#-######################################################################################
@@ -63,6 +73,21 @@ sub hds($$) {
[ @hds ];
}
+sub readProcPartitions {
+ my ($hds) = @_;
+ my @parts;
+ foreach (cat_("/proc/partitions")) {
+ my (undef, undef, $size, $device) = split;
+ next if $size eq "1"; #- extended partitions
+ foreach (@$hds) {
+ push @parts, { start => 0, size => $size * 2, device => $device,
+ type => typeOfPart($device), rootDevice => $_->{device}
+ } if $device =~ /^$_->{device}./;
+ }
+ }
+ @parts;
+}
+
sub get_fstab(@) {
map { partition_table::get_normal_parts($_) } @_;
}
@@ -329,6 +354,30 @@ sub rescuept($) {
}
}
+sub verifyHds {
+ my ($hds, $readonly, $ok) = @_;
+
+ if (is_empty_array_ref($hds)) { #- no way
+ die _("An error has occurred - no valid devices were found on which to create new filesystems. Please check your hardware for the cause of this problem");
+ }
+
+ my @parts = readProcPartitions($hds);
+ $ok &&= @parts == listlength(get_fstab(@$hds));
+
+ if ($readonly && !$ok) {
+ log::l("using /proc/partitions as diskdrake failed :(");
+ foreach my $hd (@$hds) {
+ $hd->{primary} = [ grep { $hd->{device} eq $_->{rootDevice} } @parts ];
+ delete $hd->{extended};
+ }
+ }
+ my $fstab = [ get_fstab(@$hds) ];
+ if (is_empty_array_ref($fstab) && $readonly) {
+ die _("You don't have any partitions!");
+ }
+ ($hds, $fstab, $ok);
+}
+
#-######################################################################################
#- Wonderful perl :(
#-######################################################################################
diff --git a/perl-install/help.pm b/perl-install/help.pm
index 233bd1ced..f12f3413d 100644
--- a/perl-install/help.pm
+++ b/perl-install/help.pm
@@ -193,10 +193,9 @@ and its own \"home directory\", in which these preferences are
stored.
-First of all, create an account for yourself! Even if you will be
-the only user of the machine, you may NOT connect as root for daily
-use of the system: it's a very high security risk. Making the
-system unusable is very often a typo away.
+First of all, create an account for yourself! Even if you will be the only user
+of the machine, you may NOT connect as root for daily use of the system: it's a
+very high security risk. Making the system unusable is very often a typo away.
Therefore, you should connect to the system using the user account
@@ -425,10 +424,9 @@ and its own \"home directory\", in which these preferences are
stored.
-First of all, create an account for yourself! Even if you will be
-the only user of the machine, you may NOT connect as root for daily
-use of the system: it's a very high security risk. Making the
-system unusable is very often a typo away.
+First of all, create an account for yourself! Even if you will be the only user
+of the machine, you may NOT connect as root for daily use of the system: it's a
+very high security risk. Making the system unusable is very often a typo away.
Therefore, you should connect to the system using the user account
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index f50f289a5..cd03399d5 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -121,7 +121,7 @@ $o = $::o = {
autoSCSI => 0,
mkbootdisk => 1, #- no mkbootdisk if 0 or undef, find a floppy with 1
#- packages => [ qw() ],
- partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0, autoformat => 0 },
+ partitioning => { clearall => 0, eraseBadPartitions => 0, auto_allocate => 0, autoformat => 0, readonly => 1 },
#- partitions => [
#- { mntpoint => "/boot", size => 16 << 11, type => 0x83 },
#- { mntpoint => "/", size => 256 << 11, type => 0x83 },
@@ -174,7 +174,7 @@ $o = $::o = {
#- user => { name => 'foo', password => 'bar', home => '/home/foo', shell => '/bin/bash', realname => 'really, it is foo' },
#- keyboard => 'de',
-# display => "192.168.1.19:1",
+#- display => "192.168.1.19:1",
steps => \%installSteps,
orderedSteps => \@orderedInstallSteps,
@@ -239,85 +239,7 @@ sub selectKeyboard {
#------------------------------------------------------------------------------
sub selectPath {
$o->selectPath;
-
- if ($o->{isUpgrade}) {
- #- try to find the partition where the system is installed if beginner
- #- else ask the user the right partition, and test it after.
- unless ($o->{hds}) {
- $o->{drives} = [ detect_devices::hds() ];
- $o->{hds} = catch_cdie { fsedit::hds($o->{drives}, $o->{partitioning}) }
- sub { 1; };
-
- unless (@{$o->{hds}} > 0) {
- $o->setupSCSI if $o->{autoSCSI}; #- ask for an unautodetected scsi card
- }
- }
-
- my @normal_partitions = fsedit::get_fstab(@{$o->{hds}});
-
- fs::check_mounted([@normal_partitions]);
-
- #- get all ext2 partition that may be root partition.
- my %partitions_lookup;
- my @partitions = map {
- $partitions_lookup{$_->{device}} = $_;
- type2fs($_->{type}) eq 'ext2' ? $_->{device} : (); } @normal_partitions;
-
- my $root;
- my $root_partition;
- my $selected_partition;
- do {
- if ($selected_partition->{mntpoint} && !$selected_partition->{currentMntpoint}) {
- $o->ask_warn(_("Information"), "$selected_partition->{device}" . _(" : This is not a root partition, please select another one."))
- unless $::beginner;
- log::l("umounting non root partition $selected_partition->{device}");
- eval { fs::umount_part($selected_partition); };
- $selected_partition->{mntpoint} = '';
- $selected_partition->{mntreadonly} = undef;
- }
-
- $root_partition = $::beginner ? $partitions[0] : $o->selectRootPartition(@partitions);
- $selected_partition = $partitions_lookup{$root_partition};
-
- unless ($root = $selected_partition->{currentMntpoint}) {
- $selected_partition->{mntpoint} = $root = $o->{prefix};
- $selected_partition->{mntreadonly} = 1;
- log::l("trying to mount root partition $root_partition");
- eval { fs::mount_part($selected_partition); };
- }
-
- #- avoid testing twice a partition.
- for my $i (0..$#partitions) {
- splice @partitions, $i, 1 if $partitions[$i] eq $root_partition;
- }
- } until $root && -d "$root/etc/sysconfig" && -r "$root/etc/fstab" || !(scalar @partitions);
-
-
- if ($root && -d "$root/etc/sysconfig" && -r "$root/etc/fstab") {
- $o->ask_warn(_("Information"), _("Found root partition : ") . $root_partition);
- $o->{prefix} = $root;
- $o->{fstab} = \@normal_partitions;
-
- #- test if the partition has to be fschecked and remounted rw.
- if ($selected_partition->{mntpoint} && !$selected_partition->{currentMntpoint}) {
- my @fstab = fs::read_fstab("$root/etc/fstab");
-
- eval { fs::umount_part($selected_partition); };
- $selected_partition->{mntpoint} = '';
- $selected_partition->{mntreadonly} = undef;
-
- foreach (@fstab) {
- if ($selected_partition = $partitions_lookup{$_->{device}}) {
- $selected_partition->{mntpoint} = $_->{mntpoint};
- }
- }
- #- TODO fsck, create check_mount_all ?
- fs::mount_all([ grep { isExt2($_) || isSwap($_) } @{$o->{fstab}} ], $o->{prefix});
- }
- } else {
- $o->ask_warn(_("Error"), _("No root partition found"));
- }
- }
+ install_any::searchAndMount4Upgrade($o) if $o->{isUpgrade};
}
#------------------------------------------------------------------------------
@@ -327,7 +249,6 @@ sub selectInstallClass {
$::expert = $o->{installClass} eq "expert";
$::beginner = $o->{installClass} eq "beginner";
$o->{partitions} ||= $suggestedPartitions{$o->{installClass}};
- $o->{partitioning}{auto_allocate} ||= -1 if $::beginner;
if ($o->{steps}{choosePackages}{entered} >= 1 && !$o->{steps}{doInstallStep}{done}) {
$o->setPackages(\@install_classes);
@@ -347,43 +268,27 @@ sub setupSCSI {
sub partitionDisks {
return if ($o->{isUpgrade});
- unless ($o->{hds}) {
- $o->{drives} = [ detect_devices::hds() ];
- $o->{hds} = catch_cdie { fsedit::hds($o->{drives}, $o->{partitioning}) }
- sub {
- $o->ask_warn(_("Error"),
-_("I can't read your partition table, it's too corrupted for me :(
-I'll try to go on blanking bad partitions"));
- $o->{partitioning}{auto_allocate} = 0;
- 1;
- };
-
- unless (@{$o->{hds}} > 0) {
- $o->setupSCSI if $o->{autoSCSI}; #- ask for an unautodetected scsi card
- }
- }
- if (@{$o->{hds}} == 0) { #- no way
- die _("An error has occurred - no valid devices were found on which to create new filesystems. Please check your hardware for the cause of this problem");
- }
+ $::o->{steps}{formatPartitions}{done} = 0;
+ fs::umount_all($o->{fstab}, $o->{prefix}) if $o->{fstab};
- $o->{partitioning}{auto_allocate} = 0
- if $o->{partitioning}{auto_allocate} == -1 && fsedit::get_fstab(@{$o->{hds}}) >= 4;
+ my $ok = is_empty_array_ref($o->{hds}) ? install_any::getHds($o) : 1;
+ my $auto = $ok && !$o->{partitioning}{readonly} &&
+ ($o->{partitioning}{auto_allocate} || $::beginner && fsedit::get_fstab(@{$o->{hds}}) < 4);
- eval { fsedit::auto_allocate($o->{hds}, $o->{partitions}) } if
- $o->{partitioning}{auto_allocate} && ($o->{partitioning}{auto_allocate} != -1 || $::beginner);
+ eval { fsedit::auto_allocate($o->{hds}, $o->{partitions}) } if $auto;
- if ($o->{partitioning}{auto_allocated} = ($::beginner && fsedit::get_root_($o->{hds}) && $_[1] == 1)) {
- install_steps::doPartitionDisks($o, $o->{hds});
+ if ($auto && fsedit::get_root_($o->{hds}) && $_[1] == 1) {
+ #- we have a root partition, that's enough :)
+ $o->install_steps::doPartitionDisks($o->{hds});
+ } elsif ($o->{partitioning}{readonly}) {
+ $o->ask_mntpoint_s($o->{fstab});
} else {
$o->doPartitionDisks($o->{hds});
}
-
unless ($::testing) {
$o->rebootNeeded foreach grep { $_->{rebootNeeded} } @{$o->{hds}};
}
-
$o->{fstab} = [ fsedit::get_fstab(@{$o->{hds}}) ];
-
fsedit::get_root($o->{fstab}) or die _("Partitioning failed: no root filesystem");
}
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index c77448218..1fb53407e 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -13,11 +13,14 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK);
#-######################################################################################
#- misc imports
#-######################################################################################
-use common qw(:common :system);
+use common qw(:common :system :functional);
use commands;
use run_program;
+use partition_table qw(:types);
+use fsedit;
use detect_devices;
use pkgs;
+use fs;
use log;
@@ -111,7 +114,8 @@ sub setPackages($$) {
if ($o->{packages}) {
$_->{selected} = 0 foreach values %{$o->{packages}};
} else {
- my $useHdlist = $o->{method} !~ /nfs|hd/;
+ my $useHdlist = $o->{method} !~ /nfs|hd/ || $o->{isUpgrade};
+ $useHdlist = 0;
eval { $o->{packages} = pkgs::psUsingHdlist() } if $useHdlist;
$o->{packages} = pkgs::psUsingDirectory() if !$useHdlist || $@;
@@ -164,3 +168,79 @@ sub install_cpio($$) {
run_program::run("cd $dir ; bzip2 -cd $cpio | cpio -id $name $name/*");
"$dir/$name";
}
+
+sub getHds {
+ my ($o) = @_;
+ my ($ok, $ok2) = 1;
+
+ getHds:
+ $o->{hds} = catch_cdie { fsedit::hds([ detect_devices::hds() ], $o->{partitioning}) }
+ sub {
+ $o->ask_warn(_("Error"),
+_("I can't read your partition table, it's too corrupted for me :(
+I'll try to go on blanking bad partitions")) unless $o->{partitioning}{readonly};
+ $ok = 0; 1
+ };
+
+ if (is_empty_array_ref($o->{hds}) && $o->{autoSCSI}) {
+ $o->setupSCSI; #- ask for an unautodetected scsi card
+ goto getHds;
+ }
+
+ ($o->{hds}, $o->{fstab}, $ok2) = fsedit::verifyHds($o->{hds}, $o->{partitioning}{readonly}, $ok);
+
+ $o->ask_warn('',
+_("DiskDrake failed to read correctly the partition table.
+Continue at your own risk!")) if !$ok2 && $ok;
+
+ $ok2;
+}
+
+sub searchAndMount4Upgrade {
+ my ($o) = @_;
+ my ($root, $found);
+
+ #- try to find the partition where the system is installed if beginner
+ #- else ask the user the right partition, and test it after.
+ getHds($o);
+
+ #- get all ext2 partition that may be root partition.
+ my %Parts = my %parts = map { $_->{device} => $_ } grep { isExt2($_->{type}) } @{$o->{fstab}};
+ while (%parts) {
+ my $root = $::beginner ? first(%parts) : $o->selectRootPartition(keys %parts);
+ $root = delete $parts{$root};
+
+ my $r; unless ($r = $root->{realMntpoint}) {
+ $r = $o->{prefix};
+ $root->{mntpoint} = "/";
+ log::l("trying to mount root partition $root->{device}");
+ eval { fs::mount_part($root, $o->{prefix}, 'readonly') };
+ }
+ my $found = -d "$r/etc/sysconfig" && [ fs::read_fstab("$root/etc/fstab") ];
+
+ unless ($root->{realMntpoint}) {
+ log::l("umounting non root partition $root->{device}");
+ eval { fs::umount_part($root) };
+ }
+
+ last if $found;
+
+ delete $root->{mntpoint};
+ $o->ask_warn(_("Information"),
+ _("%s: This is not a root partition, please select another one.", $root->{device})) unless $::beginner;
+ undef $root;
+ }
+ $root or die _("No root partition found");
+
+ $o->ask_warn(_("Information"), _("Found root partition : %s", $root->{device}));
+ $o->{prefix} = $root->{mntpoint};
+
+ #- test if the partition has to be fschecked and remounted rw.
+ unless ($root->{realMntpoint}) {
+ delete $root->{mntpoint};
+ ($Parts{$_->{device}} || {})->{mntpoint} = $_->{mntpoint} foreach @$found;
+
+ #- TODO fsck, create check_mount_all ?
+ fs::mount_all([ grep { isExt2($_) || isSwap($_) } @{$o->{fstab}} ], $o->{prefix});
+ }
+}
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 37667a202..d736aeee2 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -115,8 +115,10 @@ sub choosePartitionsToFormat($$) {
my ($o, $fstab) = @_;
$_->{mntpoint} = "swap" foreach grep { isSwap($_) } @$fstab;
- $_->{toFormat} = $_->{mntpoint} &&
- ($_->{notFormatted} || $o->{partitioning}{autoformat}) foreach @$fstab;
+ $_->{toFormat} = $_->{mntpoint} &&
+ (fsedit::typeOfPart($_->{device}) != $_->{type} ||
+ $_->{notFormatted} ||
+ $o->{partitioning}{autoformat}) foreach @$fstab;
}
sub formatPartitions {
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 03899cb83..91943cd69 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -17,6 +17,7 @@ use pci_probing::main;
use install_any;
use detect_devices;
use timezone;
+use fsedit;
use network;
use mouse;
use modules;
@@ -78,11 +79,11 @@ sub selectPath($) {
}
#------------------------------------------------------------------------------
sub selectRootPartition($@) {
- my ($o,@partitions) = @_;
+ my ($o, @parts) = @_;
$o->{upgradeRootPartition} =
- $o->ask_from_list_(_("Root Partition"),
- _("What is the root partition (/) of your system?"),
- [ @partitions ]);
+ $o->ask_from_list(_("Root Partition"),
+ _("What is the root partition (/) of your system?"),
+ [ @parts ], $o->{upgradeRootPartition});
#- TODO check choice, then mount partition in $o->{prefix} and autodetect.
#- install_steps::selectRootPartition($o);
}
@@ -117,6 +118,37 @@ sub selectMouse {
}
#------------------------------------------------------------------------------
sub setupSCSI { setup_thiskind($_[0], 'scsi', $_[1], $_[2]) }
+
+sub ask_mntpoint_s {
+ my ($o, $fstab) = @_;
+ my @fstab = grep { isExt2($_) } @$fstab;
+ @fstab = grep { !isSwap($_) } @$fstab if @fstab == 0;
+ @fstab = @$fstab if @fstab == 0;
+ die _("no available partitions") if @fstab == 0;
+
+ if (@fstab == 1) {
+ $fstab[0]->{mntpoint} = '/';
+ } elsif ($::beginner) {
+ my %l; $l{"$_->{device} " . _("(%dMb)", $_->{size} / 1024 / 2)} = $_ foreach @fstab;
+ my $e = $o->ask_from_list('',
+ _("Which partition do you want to use as your root partition"),
+ [ keys %l ]);
+ (fsedit::get_root($fstab) || {})->{mntpoint} = '';
+ $l{$e}{mntpoint} = '/';
+ } else {
+ $o->ask_from_entries_ref('',
+ _("Choose the mount points"),
+ [ map { $_->{device} } @fstab ],
+ [ map { \$_->{mntpoint} } @fstab ]);
+ }
+ #- assure type is at least ext2
+ (fsedit::get_root($fstab) || {})->{type} = 0x83;
+
+ $_->{mntpoint} && $_->{mntpoint} =~ m|^/|
+ && !isDos($_) && !isWin($_)
+ and $_->{type} = 0x83 foreach @$fstab;
+}
+
#------------------------------------------------------------------------------
sub rebootNeeded($) {
my ($o) = @_;
@@ -130,6 +162,7 @@ sub choosePartitionsToFormat($$) {
$o->SUPER::choosePartitionsToFormat($fstab);
my @l = grep { $_->{mntpoint} && !($::beginner && isSwap($_)) } @$fstab;
+ $_->{toFormat} = 1 foreach grep { $::beginner && isSwap($_) } @$fstab;
return if $::beginner && 0 == grep { ! $_->{toFormat} } @l;
@@ -300,7 +333,7 @@ name and directory should be used for this queue?"),
$o->{printer}{str_type} =
$o->ask_from_list_(_("Select Printer Connection"),
_("How is the printer connected?"),
- [keys %printer::printer_type],
+ [ keys %printer::printer_type ],
${$o->{printer}}{str_type},
);
$o->{printer}{TYPE} = $printer::printer_type{$o->{printer}{str_type}};
@@ -308,7 +341,7 @@ name and directory should be used for this queue?"),
if ($o->{printer}{TYPE} eq "LOCAL") {
{
my $w = $o->wait_message(_("Test ports"), _("Detecting devices..."));
- eval { modules::load("lp");modules::load("parport_probe"); };
+ eval { modules::load("parport_pc"); modules::load("parport_probe"); modules::load("lp"); };
}
my @port = ();
@@ -601,7 +634,7 @@ You can add some more or change the existent ones."),
);
$c eq "Done" and last;
- my $e = {};
+ my $e = { type => 'other' };
my $name = '';
if ($c ne "Add") {
@@ -679,7 +712,18 @@ install chapter of the Official Linux-Mandrake User's Guide.")) if $alldone;
#-######################################################################################
#- Misc Steps Functions
#-######################################################################################
-sub loadModule {
+
+#--------------------------------------------------------------------------------
+sub wait_load_module {
+ my ($o, $type, $text, $module) = @_;
+ $o->wait_message('',
+ [ _("Installing driver for %s card %s", $type, $text),
+ $::beginner ? () : _("(module %s)", $module)
+ ]);
+}
+
+
+sub load_module {
my ($o, $type) = @_;
my @options;
@@ -713,7 +757,10 @@ For instance, ``io=0x300 irq=7''", $l),
);
}
}
- eval { modules::load($m, $type, @options) };
+ eval {
+ my $w = wait_load_module($o, $type, $l, $m);
+ modules::load($m, $type, @options);
+ };
if ($@) {
$o->ask_yesorno('',
_("Loading module %s failed.
@@ -726,13 +773,11 @@ Do you want to try again with other parameters?", $l), 1) or return;
#------------------------------------------------------------------------------
sub load_thiskind {
my ($o, $type) = @_;
- my ($pcmcia, $w) = $o->{pcmcia} unless $::expert && modules::pcmcia_need_config($o->{pcmcia}) && $o->ask_yesorno('', _("Skip PCMCIA probing", 1));
- modules::load_thiskind($type, sub {
- $w = $o->wait_message('',
- [ _("Installing driver for %s card %s", $type, $_->[0]),
- $::beginner ? () : _("(module %s)", $_->[1])
- ]);
- }, $pcmcia);
+ my $w; #- needed to make the wait_message stay alive
+ my $pcmcia = $o->{pcmcia}
+ unless $::expert && modules::pcmcia_need_config($o->{pcmcia}) &&
+ $o->ask_yesorno('', _("Skip PCMCIA probing", 1));
+ modules::load_thiskind($type, sub { $w = wait_load_module($o, $type, @_) }, $pcmcia);
}
#------------------------------------------------------------------------------
@@ -752,7 +797,7 @@ sub setup_thiskind {
$r = $o->ask_from_list_('', $msg, $opt, "No") unless $at_least_one && @l == 0;
if ($r eq "No") { return }
elsif ($r eq "Yes") {
- my @r = $o->loadModule($type) or return;
+ my @r = $o->load_module($type) or return;
push @l, \@r;
} else {
$o->ask_warn('', [ pci_probing::main::list() ]);
diff --git a/perl-install/modules.pm b/perl-install/modules.pm
index 60ca503b2..40b7d523b 100644
--- a/perl-install/modules.pm
+++ b/perl-install/modules.pm
@@ -2,6 +2,7 @@ package modules;
use diagnostics;
use strict;
+use vars qw(%loaded);
use common qw(:common :file);
use pci_probing::main;
@@ -11,6 +12,7 @@ use log;
my %conf;
+my %loaded; #- array of loaded modules for each types (scsi/net/...)
my $scsi = 0;
my %deps = ();
@@ -168,6 +170,7 @@ sub load($;$@) {
load($_, 'prereq') foreach @{$deps{$name}};
load_raw($name, @options);
}
+ push @{$loaded{$type}}, $name;
$conf{'scsi_hostadapter' . ($scsi++ || '')}{alias} = $name
if $type && $type eq 'scsi';
@@ -287,7 +290,7 @@ sub load_thiskind($;&$) {
&$f($text, $mod) if $f;
load($mod, $type);
}
- @devs;
+ @devs, map { [ $_, $_ ] } @{$loaded{$type} || []};
}
sub pcmcia_need_config($) {
@@ -333,5 +336,3 @@ sub get_pcmcia_devices($$) {
#- removeModule($m[0]);
#- 1;
#-}
-
-
diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm
index d10d66fc3..7cb61a371 100644
--- a/perl-install/partition_table_raw.pm
+++ b/perl-install/partition_table_raw.pm
@@ -3,7 +3,7 @@ package partition_table_raw;
use diagnostics;
use strict;
-use common qw(:common :system);
+use common qw(:common :system :file);
use devices;
use c;
@@ -20,6 +20,8 @@ my @MBR_signatures = (
[ 'dos', 0xa0, "\x25\x03\x4E\x02\xCD\x13" ],
);
+sub typeOfMBR($) { typeFromMagic(devices::make($_[0]), @MBR_signatures) }
+
sub compute_CHS($$) {
my ($hd, $e) = @_;
my @l = qw(cyl head sec);
@@ -112,19 +114,6 @@ sub zero_MBR($) {
delete $hd->{extended};
}
-sub typeOfMBR($) {
- my $dev = devices::make($_[0]);
- local *F; sysopen F, $dev, 0 or return;
-
- my $tmp;
- foreach (@MBR_signatures) {
- my ($name, $offset, $signature) = @$_;
- sysseek(F, $offset, 0) or next;
- sysread(F, $tmp, length $signature);
- $tmp eq $signature and return $name;
- }
- undef;
-}
sub isFatFormatted($) {
my $dev = devices::make($_[0]);
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index 8570e2e07..51cf3f0f7 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -116,7 +116,7 @@ sub psUsingDirectory() {
log::l("scanning $dirname for packages");
foreach (all("$dirname")) {
- my ($name, $version, $release) = /(.*)-([^-]+)-([^-.]+)\.[^.]+\.rpm/ or log::l("skipping $_"), next;
+ my ($name, $version, $release) = /(.*)-([^-]+)-([^-]+)\.[^.]+\.rpm/ or log::l("skipping $_"), next;
$packages{$name} = {
name => $name, version => $version, release => $release,
@@ -151,7 +151,7 @@ sub psUsingHdlist() {
}
sub chop_version($) {
- first($_[0] =~ /(.*)-[^-]+-[^-.]+/) || $_[0];
+ first($_[0] =~ /(.*)-[^-]+-[^-]+/) || $_[0];
}
sub getDeps($) {
@@ -420,6 +420,7 @@ sub install($$) {
$p->{file} ||= sprintf "%s-%s-%s.%s.rpm",
$p->{name}, $p->{version}, $p->{release},
c::headerGetEntry(getHeader($p), 'arch');
+ print $p->{file}, "\n";
c::rpmtransAddPackage($trans, getHeader($p), $p->{file}, $p->{name} !~ /kernel/); #- TODO: replace `named kernel' by `provides kernel'
# c::rpmtransAddPackage($trans, getHeader($p), $p->{file}, 1); #- TODO: replace `named kernel' by `provides kernel'
$nb++;
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index 2f66e01ab..d5efa27ca 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -44,6 +44,7 @@ use Data::Dumper;
=cut
+use common qw(:common);
use commands;
#-#####################################################################################
@@ -240,13 +241,13 @@ my $PRINTER_FILTER_DIR = "/usr/lib/rhs/rhs-printfilters";
#-#####################################################################################
%printer_type = (
- "local" => "LOCAL",
- "Remote lpd" => "REMOTE",
- "SMB/Windows 95/NT" => "SMB",
- "NetWare" => "NCP",
+ __("Local printer") => "LOCAL",
+ __("Remote lpd") => "REMOTE",
+ __("SMB/Windows 95/NT") => "SMB",
+ __("NetWare") => "NCP",
);
%printer_type_inv = reverse %printer_type;
-$printer_type_default = "local";
+$printer_type_default = "Local printer";
%fields = (
STANDARD => [qw(QUEUE SPOOLDIR IF)],