summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2002-01-28 18:18:31 +0000
committerPascal Rigaux <pixel@mandriva.com>2002-01-28 18:18:31 +0000
commitf7e80813769b5abaffc05e5ff6c71bb941f689ec (patch)
treeb69417ff496e7956953d473c05be67c64cbad709 /perl-install
parent786aa9bcfa26bccfce2cdbbd4a26529b60db24f8 (diff)
downloaddrakx-f7e80813769b5abaffc05e5ff6c71bb941f689ec.tar
drakx-f7e80813769b5abaffc05e5ff6c71bb941f689ec.tar.gz
drakx-f7e80813769b5abaffc05e5ff6c71bb941f689ec.tar.bz2
drakx-f7e80813769b5abaffc05e5ff6c71bb941f689ec.tar.xz
drakx-f7e80813769b5abaffc05e5ff6c71bb941f689ec.zip
cleanup perImageAppend code (hopefully handling nicely the mem=nopentium case)
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/bootloader.pm36
-rw-r--r--perl-install/install_steps.pm17
2 files changed, 30 insertions, 23 deletions
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 2a3ab9905..3cbc431a8 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -181,27 +181,39 @@ sub add_kernel {
$v;
}
+sub unpack_append {
+ my ($s) = @_;
+ my @l = split(' ', $s);
+ [ grep { !/=/ } @l ], [ map { if_(/(.*?)=(.*)/, [$1, $2]) } @l ];
+}
+sub pack_append {
+ my ($simple, $dict) = @_;
+ join(' ', @$simple, map { "$_->[0]=$_->[1]" } @$dict);
+}
+
+sub append__mem_is_memsize { $_[0] =~ /^\d+[kM]?$/i }
+
sub get_append {
my ($b, $key) = @_;
- if ($key eq 'mem') {
- ($b->{perImageAppend} =~ /\bmem=(\d+[KkMm]?)(?:\s.*)?$/)[0];
- } else {
- ($b->{perImageAppend} =~ /\b$key=(\S*)/)[0];
- }
+ my (undef, $dict) = unpack_append($b->{perImageAppend});
+ my @l = map { $_->[1] } grep { $_->[0] eq $key } @$dict;
+
+ #- suppose we want the memsize
+ @l = grep { append__mem_is_memsize($_) } @l if $key eq 'mem';
+
+ log::l("more than one $key in $b->{perImageAppend}") if @l > 1;
+ $l[0];
}
sub add_append {
my ($b, $key, $val) = @_;
foreach (\$b->{perImageAppend}, map { \$_->{append} } @{$b->{entries}}) {
- if ($key eq 'mem') {
- $$_ =~ s/\bmem=(\d+[KkMm]?)(\s.*)?$/$2/;
- } else {
- $$_ =~ s/\b$key=\S*\s*//;
- }
- $$_ =~ s/\s*$/ $key=$val/ if $val;
+ my ($simple, $dict) = unpack_append($$_);
+ @$dict = grep { $_->[0] ne $key || $key eq 'mem' && append__mem_is_memsize($_->[1]) != append__mem_is_memsize($val) } @$dict;
+ push @$dict, [ $key, $val ] if $val;
+ $$_ = pack_append($simple, $dict);
log::l("add_append: $$_");
}
- log::l("add_append: $b->{perImageAppend}");
}
sub may_append {
my ($b, $key, $val) = @_;
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index a344d852d..882a17d41 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -920,24 +920,19 @@ sub miscellaneousBefore {
sub miscellaneous {
my ($o) = @_;
- local $_ = $o->{bootloader}{perImageAppend};
-
- if (my @l = detect_devices::IDEburners() and !/ide-scsi/) {
- $_ .= " " . join(" ", (map { "$_->{device}=ide-scsi" } @l),
- #- in that case, also add ide-floppy otherwise ide-scsi will be used!
- map { "$_->{device}=ide-floppy" } detect_devices::ide_zips());
+ if (my @l = detect_devices::IDEburners()) {
+ add_append($o->{bootloader}, $_->{device}, 'ide-scsi') foreach @l;
+ #- in that case, also add ide-floppy otherwise ide-scsi will be used!
+ add_append($o->{bootloader}, $_->{device}, 'ide-floppy') foreach detect_devices::ide_zips();
}
if ($o->{miscellaneous}{HDPARM}) {
- $_ .= join('', map { " $_=autotune" } grep { /ide.*/ } all("/proc/ide")) if !/ide.=autotune/;
+ add_append($o->{bootloader}, $_, 'autotune') foreach grep { /ide.*/ } all("/proc/ide");
}
if (grep { /Athlon|Duron/ } cat_("/proc/cpuinfo")) {
- $_ .= " mem=nopentium";
+ add_append($o->{bootloader}, 'mem', 'nopentium');
}
#- keep some given parameters
#-TODO
-
- log::l("perImageAppend: $_");
- $o->{bootloader}{perImageAppend} = $_;
}
#------------------------------------------------------------------------------