summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xdraklive46
-rw-r--r--lib/MDV/Draklive/StorageFS.pm56
2 files changed, 59 insertions, 43 deletions
diff --git a/draklive b/draklive
index 92b2309..c19c07c 100755
--- a/draklive
+++ b/draklive
@@ -39,6 +39,7 @@ use IO::Handle;
use MDV::Draklive::Utils;
use MDV::Draklive::Live;
use MDV::Draklive::Media;
+use MDV::Draklive::StorageFS;
my $dir_distrib_sqfs = {
mountpoint => '/distrib',
@@ -178,47 +179,6 @@ my %storage = (
},
);
-my %storage_fs;
-%storage_fs = (
- generic => {
- mount => sub {
- my ($live, $media) = @_;
- my @mount_options = (
- if_($media->get_media_setting('read_only'), "ro"),
- grep { $_ } $media->get_media_setting('mount_options'),
- );
- 'nash-mount' . if_(@mount_options, " -o " . join(",", @mount_options)) . " -t " . $media->get_media_setting('fs') .
- " " . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
- },
- },
- nfs => {
- files => [ '/sbin/ifconfig', '/bin/mount' ], #- needed to mount NFS (with nolock)
- mount => sub {
- my ($live, $media) = @_;
- '/bin/mount -n -o ro,nolock -t nfs ' . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
- }
- },
- ext2 => {
- files => [ '/sbin/fsck.ext2' ],
- mount => sub {
- my ($live, $media) = @_;
- my $fsck = "/bin/fsck.ext2";
- my $source = $media->get_media_setting('source');
- qq(sh -c '$fsck -a $source || $fsck -y $source'),
- $storage_fs{generic}{mount}->($live, $media);
- },
- },
- vfat => {
- #files => [ '/sbin/dosfsck' ],
- mount => sub {
- my ($live, $media) = @_;
- #$storage_fs{generic}{mount}->($live, $media),
- #qq(awk '\$2 == "$live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}" { system("umount " \$1 "; mount; echo dosfsck -a " \$1 "; dosfsck -a " \$1) }' /proc/mounts),
- $storage_fs{generic}{mount}->($live, $media);
- },
- },
-);
-
sub nls_modules {
my ($live) = @_;
my $fs = $live->{media}->get_media_setting('fs');
@@ -455,7 +415,7 @@ sub create_initrd_for_media {
my $fs = $media->get_media_setting('fs');
my @loop_types = uniq(map { $_->{type} } @{$live->{mount}{dirs}});
inst_initrd_bin($live->get_system_root, $initrd_tree, $_) foreach
- @{$storage_fs{$fs} && $storage_fs{$fs}{files} || []},
+ MDV::Draklive::StorageFS::get_files($fs),
(map { @{$loop{$_} && $loop{$_}{files} || []} } @loop_types);
output_p($initrd_tree . '/etc/fstab', '');
@@ -563,7 +523,7 @@ sub create_initrd_scriptlet {
if_($pre, deref_array($pre)),
"mkdevices /dev",
"showlabels --removable",
- $storage_fs{exists $storage_fs{$fs}{mount} ? $fs : 'generic'}{mount}->($live, $media),
+ MDV::Draklive::StorageFS::get_mount($fs)->($live, $media),
(map { $loop{$_->{type}}{mount}->($live, $_) } @$mount_first, @$mount_last),
($live->{mount}{overlay} ? $overlay{$live->{mount}{overlay}}{mount}->($live) : ()),
if_($live->{system}{initrd_pre_pivot}, deref_array($live->{system}{initrd_pre_pivot})),
diff --git a/lib/MDV/Draklive/StorageFS.pm b/lib/MDV/Draklive/StorageFS.pm
new file mode 100644
index 0000000..5181bae
--- /dev/null
+++ b/lib/MDV/Draklive/StorageFS.pm
@@ -0,0 +1,56 @@
+package MDV::Draklive::StorageFS;
+
+use MDK::Common;
+
+my %storage_fs;
+%storage_fs = (
+ generic => {
+ mount => sub {
+ my ($live, $media) = @_;
+ my @mount_options = (
+ if_($media->get_media_setting('read_only'), "ro"),
+ grep { $_ } $media->get_media_setting('mount_options'),
+ );
+ 'nash-mount' . if_(@mount_options, " -o " . join(",", @mount_options)) . " -t " . $media->get_media_setting('fs') .
+ " " . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
+ },
+ },
+ nfs => {
+ files => [ '/sbin/ifconfig', '/bin/mount' ], #- needed to mount NFS (with nolock)
+ mount => sub {
+ my ($live, $media) = @_;
+ '/bin/mount -n -o ro,nolock -t nfs ' . $media->get_media_source_for_nash . " $live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}";
+ }
+ },
+ ext2 => {
+ files => [ '/sbin/fsck.ext2' ],
+ mount => sub {
+ my ($live, $media) = @_;
+ my $fsck = "/bin/fsck.ext2";
+ my $source = $media->get_media_setting('source');
+ qq(sh -c '$fsck -a $source || $fsck -y $source'),
+ $storage_fs{generic}{mount}->($live, $media);
+ },
+ },
+ vfat => {
+ #files => [ '/sbin/dosfsck' ],
+ mount => sub {
+ my ($live, $media) = @_;
+ #$storage_fs{generic}{mount}->($live, $media),
+ #qq(awk '\$2 == "$live->{prefix}{live}{mnt}$live->{prefix}{media}{mnt}" { system("umount " \$1 "; mount; echo dosfsck -a " \$1 "; dosfsck -a " \$1) }' /proc/mounts),
+ $storage_fs{generic}{mount}->($live, $media);
+ },
+ },
+);
+
+sub get_files {
+ my ($fs) = @_;
+ @{$storage_fs{$fs} && $storage_fs{$fs}{files} || []};
+}
+
+sub get_mount {
+ my ($fs) = @_;
+ $storage_fs{exists $storage_fs{$fs}{mount} ? $fs : 'generic'}{mount};
+}
+
+1;