From 2e7098e56cb38236c47126e4372d0aa0ceed0dfe Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 18 Feb 2020 15:44:22 +0100 Subject: (option_to_preserve_UUID_while_formating) split it --- perl-install/fs/format.pm | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index 23f37502a..5f841163e 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -213,6 +213,22 @@ sub write_btrfs_uuid { die "failed to set UUID to '$UUID' on $dev (status=$status)" if !$status; } +=item sub option_to_preserve_UUID_while_formating($part, $fs_type) + +Return the options needed to preserve UUID while formating + +=cut + +sub option_to_preserve_UUID_while_formating { + my ($part, $fs_type) = @_; + if (member($fs_type, qw(swap ext2 ext3 ext4))) { + return '-U', $part->{device_UUID} if $part->{device_UUID}; + } elsif ($fs_type eq 'reiserfs') { + return '-u', $part->{device_UUID} if $part->{device_UUID}; + } + return (); +} + =item part_raw($part, $wait_message) Actually format the $part partition disk. $wait_message is only used when formating ext3/4. @@ -246,13 +262,8 @@ sub part_raw { push @options, '-l', 'bootstrap'; } - # Preserve UUID - if (member($fs_type, qw(swap ext2 ext3 ext4))) { - push @options, '-U', $part->{device_UUID} if $part->{device_UUID}; - } elsif ($fs_type eq 'reiserfs') { - push @options, '-u', $part->{device_UUID} if $part->{device_UUID}; - } - + push @options, option_to_preserve_UUID_while_formating($part, $fs_type); + if ($part->{device_LABEL}) { push @options, @{$LABELs{$fs_type}}[0], $part->{device_LABEL}; } -- cgit v1.2.1