summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDieter Plaetinck <dieter@plaetinck.be>2010-12-12 13:22:27 +0100
committerDieter Plaetinck <dieter@plaetinck.be>2010-12-12 13:23:00 +0100
commitf9e823222415137f3a049dedf66438a7530632a2 (patch)
treea135e75557e998feb9bb5093aecd547b1f509534 /src
parentaca6efd29ead9796880abbaaada3b52101b1778e (diff)
refactor filesystem_packages code to use associative array definition at top
Diffstat (limited to 'src')
-rw-r--r--src/core/libs/lib-blockdevices-filesystems.sh18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/core/libs/lib-blockdevices-filesystems.sh b/src/core/libs/lib-blockdevices-filesystems.sh
index 954abdf..82d2125 100644
--- a/src/core/libs/lib-blockdevices-filesystems.sh
+++ b/src/core/libs/lib-blockdevices-filesystems.sh
@@ -77,6 +77,13 @@ fs_mountable=(ext2 ext3 ext4 nilfs2 xfs jfs vfat reiserfs)
fs_label_mandatory=('lvm-vg' 'lvm-lv' 'dm_crypt')
fs_label_optional=('ext2' 'ext3' 'ext4' 'reiserfs' 'nilfs2' 'xfs' 'jfs' 'vfat')
+# list needed packages per filesystem
+declare -A filesystem_pkg=(["lvm-pv"]="lvm2" ["xfs"]="xfsprogs" ["jfs"]="jfsutils" ["reiserfs"]="reiserfsprogs" ["nilfs2"]="nilfs-utils" ["vfat"]="dosfstools" ["dm_crypt"]="cryptsetup")
+for i in ext2 ext3 ext4
+do
+ filesystem_pkg+=([$i]=e2fsprogs)
+done
+
# returns which filesystems you can create based on the locally available utilities
get_possible_fs () {
possible_fs=
@@ -528,16 +535,7 @@ process_filesystems ()
then
debug 'FS' "$fs_id ->Already done"
else
- needs_pkg=
- [ $fs_type = 'lvm-pv' ] && needs_pkg=lvm2
- [ $fs_type = 'xfs' ] && needs_pkg=xfsprogs
- [ $fs_type = 'jfs' ] && needs_pkg=jfsutils
- [ $fs_type = 'reiserfs' ] && needs_pkg=reiserfsprogs
- [ $fs_type = 'nilfs2' ] && needs_pkg=nilfs-utils
- [[ $fs_type =~ ext.* ]] && needs_pkg=e2fsprogs
- [ $fs_type = 'vfat' ] && needs_pkg=dosfstools
- [ $fs_type = 'dm_crypt' ] && needs_pkg=cryptsetup
-
+ needs_pkg=${filesystem_pkg[$fs_type]}
[ -n "$needs_pkg" ] && check_is_in $needs_pkg "${needed_pkgs_fs[@]}" || needed_pkgs_fs+=($needs_pkg)
# We can't always do -b on the lvm VG. because the devicefile sometimes doesn't exist for a VG. vgdisplay to the rescue!