From 137cba98aa58448cc48aac6ab5d7179d048cbcf0 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 2 Aug 2004 08:01:14 +0000 Subject: - move package_needed_for_partition_type() from fsedit to fs::format - create check_package_is_installed() in fs::format and use it --- perl-install/diskdrake/interactive.pm | 8 +------- perl-install/fs/format.pm | 35 ++++++++++++++++++++++++----------- perl-install/fsedit.pm | 10 ---------- perl-install/install_any.pm | 2 +- 4 files changed, 26 insertions(+), 29 deletions(-) diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index def668bb7..97c3d8a11 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -1027,13 +1027,7 @@ sub check_type { return; } if ($::isStandalone) { - if (my $pkg = fsedit::package_needed_for_partition_type($type)) { - if (!-x "/sbin/mkfs.$type->{fs_type}") { - $in->ask_yesorno('', N("The package %s is needed. Install it?", $pkg), 1) or return; - $in->do_pkgs->install($pkg); - } - -x "/sbin/mkfs.$type->{fs_type}" or $in->ask_warn('', "Mandatory package $pkg is missing"), return; - } + fs::format::check_package_is_installed($in->do_pkgs, $type->{fs_type}) or return; } 1; } diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm index d41a98ccc..fb948b6b5 100644 --- a/perl-install/fs/format.pm +++ b/perl-install/fs/format.pm @@ -9,17 +9,30 @@ use fs::type; use log; my %cmds = ( - ext2 => 'mke2fs -F', - ext3 => 'mke2fs -F -j', - reiserfs => 'mkreiserfs -ff', - xfs => 'mkfs.xfs -f -q', - jfs => 'mkfs.jfs -f', - hfs => 'hformat', - dos => 'mkdosfs', - vfat => 'mkdosfs -F 32', - swap => 'mkswap', + ext2 => [ 'e2fsprogs', 'mke2fs', '-F' ], + ext3 => [ 'e2fsprogs', 'mke2fs', '-F', '-j' ], + reiserfs => [ 'reiserfsprogs', 'mkreiserfs', '-ff' ], + xfs => [ 'xfsprogs', 'mkfs.xfs', '-f', '-q' ], + jfs => [ 'jfsprogs', 'mkfs.jfs', '-f' ], + hfs => [ 'hfsutils', 'hformat' ], + dos => [ 'dosfstools', 'mkdosfs' ], + vfat => [ 'dosfstools', 'mkdosfs', '-F', '32' ], + swap => [ 'util-linux', 'mkswap' ], ); +sub package_needed_for_partition_type { + my ($part) = @_; + my $l = $cmds{$part->{fs_type}} or return; + $l->[0]; +} + +sub check_package_is_installed { + my ($do_pkgs, $fs_type) = @_; + + my ($pkg, $binary) = @{$cmds{$fs_type} || return}; + $do_pkgs->ensure_binary_is_installed($pkg, $binary); +} + sub part { my ($raids, $part, $prefix, $wait_message) = @_; if (isRAID($part)) { @@ -61,9 +74,9 @@ sub part_raw { push @options, '-l', 'bootstrap'; } - my $cmd = $cmds{$fs_type} or die N("I don't know how to format %s in type %s", $part->{device}, $part->{fs_type}); + my ($pkg, $cmd, @first_options) = @{$cmds{$fs_type} || die N("I don't know how to format %s in type %s", $part->{device}, $part->{fs_type})}; - run_program::raw({ timeout => 60 * 60 }, split(' ', $cmd), @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev); + run_program::raw({ timeout => 60 * 60 }, $cmd, @first_options, @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev); if ($fs_type eq 'ext3') { disable_forced_fsck($dev); diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index b4eeda85e..39797a773 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -523,16 +523,6 @@ sub check_fs_type { $fs_type eq "reiserfs" && $part->{size} < 32 << 11 and die N("You can't use ReiserFS for partitions smaller than 32MB"); } -sub package_needed_for_partition_type { - my ($part) = @_; - my %l = ( - reiserfs => 'reiserfsprogs', - xfs => 'xfsprogs', - jfs => 'jfsprogs', - ); - $l{$part->{fs_type}}; -} - #- you can do this before modifying $part->{mntpoint} #- so $part->{mntpoint} should not be used here, use $mntpoint instead sub check_mntpoint { diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 49dd76a57..5c30dcf40 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -477,7 +477,7 @@ sub setDefaultPackages { push @{$o->{default_packages}}, "lvm2" if !is_empty_array_ref($o->{all_hds}{lvms}); push @{$o->{default_packages}}, "alsa", "alsa-utils" if any { $o->{modules_conf}->get_alias("sound-slot-$_") =~ /^snd-/ } 0 .. 4; push @{$o->{default_packages}}, "grub" if isLoopback(fsedit::get_root($o->{fstab})); - push @{$o->{default_packages}}, uniq(grep { $_ } map { fsedit::package_needed_for_partition_type($_) } @{$o->{fstab}}); + push @{$o->{default_packages}}, uniq(grep { $_ } map { fs::format::package_needed_for_partition_type($_) } @{$o->{fstab}}); #- if no cleaning needed, populate by default, clean is used for second or more call to this function. unless ($b_clean) { -- cgit v1.2.1