summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-09-04 12:54:53 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-09-04 12:54:53 +0000
commit5fec2d5f97d21abf930f55113cab9c4caa6ee2b2 (patch)
tree1251777b93fbb33aeacd2fb4b7502be2617c2590 /perl-install
parent2464b52cfafd5bccf6cc35137748e4f008709d74 (diff)
downloaddrakx-backup-do-not-use-5fec2d5f97d21abf930f55113cab9c4caa6ee2b2.tar
drakx-backup-do-not-use-5fec2d5f97d21abf930f55113cab9c4caa6ee2b2.tar.gz
drakx-backup-do-not-use-5fec2d5f97d21abf930f55113cab9c4caa6ee2b2.tar.bz2
drakx-backup-do-not-use-5fec2d5f97d21abf930f55113cab9c4caa6ee2b2.tar.xz
drakx-backup-do-not-use-5fec2d5f97d21abf930f55113cab9c4caa6ee2b2.zip
- bootloader-config:
o add --action migrate-to-uuids
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/NEWS2
-rwxr-xr-xperl-install/standalone/bootloader-config62
2 files changed, 62 insertions, 2 deletions
diff --git a/perl-install/NEWS b/perl-install/NEWS
index c8147bbf8..66072ee62 100644
--- a/perl-install/NEWS
+++ b/perl-install/NEWS
@@ -1,3 +1,5 @@
+- bootloader-config:
+ o add --action migrate-to-uuids
- fix sizing some label (workarounding infamous 6 years old gnome bug #101968)
Version 11.33.1 - 2 September 2008
diff --git a/perl-install/standalone/bootloader-config b/perl-install/standalone/bootloader-config
index 51bfe58ed..4a4b194df 100755
--- a/perl-install/standalone/bootloader-config
+++ b/perl-install/standalone/bootloader-config
@@ -37,11 +37,11 @@ usage: bootloader-config --action add-kernel (--image <vmlinuz> | --kernel-versi
bootloader-config --action update-splash
bootloader-config --action remove-splash
-
bootloader-config --action rebuild-initrds
+ bootloader-config --action migrate-to-uuids
EOF
-my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash rebuild-initrds detectloader add-entry remove-entry add-resume2);
+my @known_actions = qw(add-kernel remove-kernel update-splash remove-splash rebuild-initrds migrate-to-uuids detectloader add-entry remove-entry add-resume2);
$action && member($action, @known_actions) or die "<action> must be one of " . join(' ', @known_actions) . "\n";
if ($image) {
@@ -234,6 +234,64 @@ sub rebuild_initrds() {
}
#-###############################################################################
+sub migrate_to_uuids() {
+ _migrate_to_uuids__fstab();
+
+ my $fstab = [ fs::get::fstab($all_hds) ];
+ my $bootloader_migrated;
+ my $may_migrate = sub {
+ my ($label, $dev_ref) = @_;
+ my $dev_ = _migrate_dev_to_uuid($fstab, $$dev_ref) or return;
+
+ log::l("migrate_to_uuids: migrating bootloader $label=$$dev_ref entry");
+ $$dev_ref = $dev_;
+ $bootloader_migrated = 1;
+ };
+ # migrate root=
+ $may_migrate->('root', \$_->{root}) foreach grep { !$_->{keep_verbatim} } @{$bootloader->{entries}};
+
+ # migrate resume=
+ bootloader::modify_append($bootloader, sub {
+ my ($_simple, $dict) = @_;
+ foreach (grep { $_->[0] eq 'resume' } @$dict) {
+ $may_migrate->($_->[0], \$_->[1]);
+ }
+ });
+
+ if ($bootloader_migrated) {
+ bootloader::action($bootloader, 'write', $all_hds);
+ bootloader::action($bootloader, 'when_config_changed');
+ }
+}
+
+sub _migrate_to_uuids__fstab() {
+ my $fstab_migrated;
+ foreach my $part (fs::get::really_all_fstab($all_hds)) {
+ if (_set_prefer_device_UUID($part)) {
+ log::l("migrate_to_uuids: migrating fstab $part->{device} entry");
+ $fstab_migrated = 1;
+ }
+ }
+ fs::write_fstab($all_hds) if $fstab_migrated;
+}
+
+sub _migrate_dev_to_uuid {
+ my ($fstab, $dev) = @_;
+ $dev && $dev =~ m!/dev/! or next;
+
+ my $part = fs::get::device2part($dev, $fstab);
+ $part && $part->{device_UUID} && "UUID=$part->{device_UUID}";
+}
+
+sub _set_prefer_device_UUID {
+ my ($part) = @_;
+ $part->{device_UUID} && !$part->{prefer_device_UUID} && !$part->{prefer_device_LABEL} or return;
+ $part->{prefer_device_UUID} = 1;
+ $part->{prefer_device} = 0;
+ 1;
+}
+
+#-###############################################################################
sub update_splash() {
bootloader::update_splash($bootloader);
bootloader::action($bootloader, 'when_config_changed') if !$no_launch;