summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-08-05 08:55:59 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-08-05 08:55:59 +0000
commit83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c (patch)
tree67082b1f4bec8938b561ab1ab65d613e74a3f4e0 /perl-install
parent1922fb769aa3deb26f7f5b6fcb14784a5ba9a0f3 (diff)
downloaddrakx-83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c.tar
drakx-83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c.tar.gz
drakx-83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c.tar.bz2
drakx-83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c.tar.xz
drakx-83f00ab2b7a1d2a4cc1d800fb1f7f98e2bc56e1c.zip
basic code for upgrading from a redhat distribution
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/any.pm11
-rw-r--r--perl-install/install_any.pm4
-rw-r--r--perl-install/install_steps.pm55
-rw-r--r--perl-install/install_steps_interactive.pm2
4 files changed, 65 insertions, 7 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index 454b6fa02..a9b099947 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -826,13 +826,18 @@ UNREGISTER ^$devfs_if\$ EXECUTE /etc/dynamic/scripts/rawdevice.script del /dev/$
");
}
-sub fix_broken_alternatives() {
+sub fix_broken_alternatives {
+ my ($force_default) = @_;
#- fix bad update-alternatives that may occurs after upgrade (and sometimes for install too).
-d "$::prefix/etc/alternatives" or return;
foreach (all("$::prefix/etc/alternatives")) {
- next if run_program::rooted($::prefix, 'test', '-e', "/etc/alternatives/$_");
- log::l("fixing broken alternative $_");
+ if ($force_default) {
+ log::l("setting alternative $_");
+ } else {
+ next if run_program::rooted($::prefix, 'test', '-e', "/etc/alternatives/$_");
+ log::l("fixing broken alternative $_");
+ }
run_program::rooted($::prefix, 'update-alternatives', '--auto', $_);
}
}
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 4c4dd0334..69aca812d 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -1085,13 +1085,13 @@ sub find_root_parts {
my ($fstab, $prefix) = @_;
map {
my $handle = any::inspect($_, $prefix);
- my $f = $handle && (find { -f $_ } map { "$handle->{dir}/etc/$_" } 'mandrake-release', 'mandrakelinux-release');
+ my $f = $handle && (find { -f $_ } map { "$handle->{dir}/etc/$_" } 'mandrakelinux-release', 'mandrake-release', 'redhat-release');
if ($f) {
my $s = cat_($f);
chomp($s);
$s =~ s/\s+for\s+\S+//;
log::l("find_root_parts found $_->{device}: $s");
- { release => $s, part => $_ };
+ { release => $s, part => $_, release_file => $f };
} else { () }
} @$fstab;
}
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index dcf215658..0db44431d 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -312,6 +312,43 @@ sub choosePackages {
$availableCorrected;
}
+sub upgrading_redhat() {
+ #- remove weird config files that bother Xconfig::* too much
+ unlink "$::prefix/etc/X11/XF86Config";
+ unlink "$::prefix/etc/X11/XF86Config-4";
+
+ sub prefering_mdk {
+ my ($lpkg, $rpkg_ver, $c) = @_;
+ my $lpkg_ver = $lpkg->version . '-' . $lpkg->release;
+ log::l($lpkg->name . ' ' . ': prefering ' . ($c == 1 ? "$lpkg_ver over $rpkg_ver" : "$rpkg_ver over $lpkg_ver"));
+ }
+
+ my $old_compare_pkg = \&URPM::Package::compare_pkg;
+ undef *URPM::Package::compare_pkg;
+ *URPM::Package::compare_pkg = sub {
+ my ($lpkg, $rpkg) = @_;
+ my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg->release =~ /mdk$/ ? 1 : 0);
+ if ($c) {
+ prefering_mdk($lpkg, $rpkg->version . '-' . $rpkg->release, $c);
+ $c;
+ } else {
+ &$old_compare_pkg;
+ }
+ };
+
+ my $old_compare = \&URPM::Package::compare;
+ undef *URPM::Package::compare;
+ *URPM::Package::compare = sub {
+ my ($lpkg, $rpkg_ver) = @_;
+ my $c = ($lpkg->release =~ /mdk$/ ? 1 : 0) - ($rpkg_ver =~ /mdk$/ ? 1 : 0);
+ if ($c) {
+ prefering_mdk($lpkg, $rpkg_ver, $c);
+ return $c;
+ }
+ &$old_compare;
+ };
+}
+
sub beforeInstallPackages {
my ($o) = @_;
@@ -328,6 +365,22 @@ sub beforeInstallPackages {
}
}
+ #- mainly for upgrading redhat packages, but it can help other
+ my @should_not_be_dirs = qw(/usr/X11R6/lib/X11/xkb /usr/share/locale/zh_TW/LC_TIME /usr/include/GL);
+ my @should_be_dirs = qw(/etc/X11/xkb);
+ foreach (@should_not_be_dirs) {
+ my $f = "$::prefix$_";
+ rm_rf($f) if !-l $f && -d $f;
+ }
+ foreach (@should_be_dirs) {
+ my $f = "$::prefix$_";
+ rm_rf($f) if -l $f || !-d $f;
+ }
+
+ if ($o->{isUpgrade} eq 'redhat') {
+ upgrading_redhat();
+ }
+
#- some packages need such files for proper installation.
install_any::write_fstab($o);
@@ -519,7 +572,7 @@ GridHeight=70
}
}
- any::fix_broken_alternatives();
+ any::fix_broken_alternatives($o->{isUpgrade} eq 'redhat');
#- update theme directly from a package (simplest).
if (-s "$o->{prefix}/usr/share/oem-theme.rpm") {
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index cda91d1eb..6e377824a 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -163,7 +163,7 @@ sub selectInstallClass {
[ { label => N("Encryption key for %s", $_->{mntpoint}),
hidden => 1, val => \$_->{encrypt_key} } ]);
}
- $o->{isUpgrade} = 1;
+ $o->{isUpgrade} = $p->{release_file} =~ /redhat/ ? 'redhat' : 'mandrake';
}
}
}