summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-01-19 14:31:44 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-01-19 14:31:44 +0000
commit47a390d1a20b72a9a87e4f89e6a94eadad4ba818 (patch)
treeebc3a8b071318d505bb47e430e4884695ea2f9bf
parent0b243c6d1dd0234af94666d8b0751e1bf487b174 (diff)
downloaddrakx-backup-do-not-use-47a390d1a20b72a9a87e4f89e6a94eadad4ba818.tar
drakx-backup-do-not-use-47a390d1a20b72a9a87e4f89e6a94eadad4ba818.tar.gz
drakx-backup-do-not-use-47a390d1a20b72a9a87e4f89e6a94eadad4ba818.tar.bz2
drakx-backup-do-not-use-47a390d1a20b72a9a87e4f89e6a94eadad4ba818.tar.xz
drakx-backup-do-not-use-47a390d1a20b72a9a87e4f89e6a94eadad4ba818.zip
- factorize kernel regexp in analyse_kernel_name()
- remove special kernel choosing in packageCallbackChoices()
-rw-r--r--perl-install/do_pkgs.pm23
-rw-r--r--perl-install/pkgs.pm46
2 files changed, 41 insertions, 28 deletions
diff --git a/perl-install/do_pkgs.pm b/perl-install/do_pkgs.pm
index bbcacb620..3bdfe7501 100644
--- a/perl-install/do_pkgs.pm
+++ b/perl-install/do_pkgs.pm
@@ -62,17 +62,18 @@ sub check_kernel_module_packages {
my ($do, $base_name, $o_ext_name) = @_;
if (!$o_ext_name || pkgs::packageByName($do->{o}{packages}, $o_ext_name)) {
- my @rpms;
- foreach my $p (@{$do->{o}{packages}{depslist}}) {
- my ($ext, $version_release) = $p->name =~ /kernel[^\-]*(-smp|-enterprise|-secure|-i686-up-4GB)?(?:-([^\-]+))?$/
- or next;
- $p->flag_available or next;
- my $name = "$base_name$ext-$version_release";
- pkgs::packageByName($do->{o}{packages}, $name) or next;
- log::l("found kernel module packages $name");
- push @rpms, $name;
- }
- @rpms > 0 and return [ @rpms, if_($o_ext_name, $o_ext_name) ];
+ my @rpms = map {
+ my ($p, $ext, $version) = @$_;
+ my $name = "$base_name$ext-$version";
+ if ($p->flag_available && pkgs::packageByName($do->{o}{packages}, $name)) {
+ log::l("found kernel module packages $name");
+ $name;
+ } else {
+ ();
+ }
+ } pkgs::packages2kernels($do->{o}{packages});
+
+ @rpms and return [ @rpms, if_($o_ext_name, $o_ext_name) ];
}
return undef;
}
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index 1198bb5db..7df5063cf 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -164,19 +164,39 @@ sub packageById {
$pkg->is_arch_compat && $pkg;
}
+sub analyse_kernel_name {
+ $_[0] =~ /kernel[^\-]*(-enterprise|-i686-up-4GB|-p3-smp-64GB|-secure|-smp)?(?:-([^\-]+))?$/;
+}
+
+sub packages2kernels {
+ my ($packages) = @_;
+
+ map {
+ my $pkg = $packages->{depslist}[$_];
+ if (my ($ext, $version) = analyse_kernel_name($pkg->name)) {
+ [ $pkg, $ext, $version ];
+ } else {
+ log::l("ERROR: unknown package " . $pkg->name . " providing kernel");
+ ();
+ }
+ } keys %{$packages->{provides}{kernel}};
+}
+
sub bestKernelPackage {
my ($packages) = @_;
- my ($best, $best2, $best3);
- foreach (keys %{$packages->{provides}{kernel}}) {
- my $pkg = $packages->{depslist}[$_] or next;
- $pkg->name =~ /kernel-\d/ and $best = $pkg;
- $pkg->name =~ /kernel-i686/ and $best2 = $pkg;
- $pkg->name =~ /kernel-enterprise/ and $best3 = $pkg;
+ my @kernels = packages2kernels($packages) or internal_error('no kernel available');
+ my ($version_BOOT) = c::kernel_version() =~ /^(\d+\.\d+)/;
+ if (my @l = grep { $_->[2] =~ /\Q$version_BOOT/ } @kernels) {
+ #- favour versions corresponding to current BOOT version
+ @kernels = @l;
}
- log::l("bestKernelPackage's: " . join(' ', map { if_($_, $_->name) } $best, $best2, $best3));
-
- $best || $best2 || $best3;
+ if (my @l = grep { $_->[1] eq '' } @kernels) {
+ @kernels = @l;
+ }
+
+ log::l("bestKernelPackage: " . join(' ', map { $_->[0]->name } @kernels) . (@kernels > 1 ? ' (choosing the first)' : ''));
+ $kernels[0][0];
}
sub packagesOfMedium {
@@ -226,14 +246,6 @@ sub packageCallbackChoices {
$prefer;
} else {
my @l = grep {
- #- or if a kernel has to be chosen, chose the basic one.
- if ($_->arch ne 'src') {
- if ($_->name =~ /kernel-\d/ || $_->name =~ /kernel-i686/) {
- log::l("packageCallbackChoices: chosen " . $_->name);
- return $_;
- }
- }
-
#- or even if a package requires a specific locales which
#- is already selected.
find {