From 445348796f67ee14f85d84291877d766834237a9 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 28 Oct 2008 23:52:39 +0000 Subject: move device_allocate_file and device_mkfs in MDV::Draklive::Utils --- draklive | 27 +++++---------------------- lib/MDV/Draklive/Utils.pm | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/draklive b/draklive index 3066715..a9d0316 100755 --- a/draklive +++ b/draklive @@ -245,8 +245,8 @@ my %loop; my ($live, $dir) = @_; my $dest = $live->get_builddir . $live->{prefix}{build}{loopbacks} . $dir->{path} . $loop{loopfs}{extension}; mkdir_p(dirname($dest)); - device_allocate_file($dest, $dir->{pre_allocate}); - device_mkfs($dest, $dir->{fs}) if !defined $dir->{min_size}; + MDV::Draklive::Utils::device_allocate_file($dest, $dir->{pre_allocate}); + MDV::Draklive::Utils::device_mkfs($dest, $dir->{fs}) if !defined $dir->{min_size}; }, mount => sub { my ($live, $dir) = @_; @@ -1039,23 +1039,6 @@ sub create_classical_bootloader { output_p($live->get_system_root . '/boot/grub/menu.lst', build_grub_cfg_raw($live, $live->{media}, "/initrd.img", {}, $part_nb)); } -sub device_allocate_file { - my ($device, $size) = @_; - run_('dd', "of=$device", 'count=0', 'bs=1', "seek=" . removeXiBSuffix($size)); -} - -#- format $device as type $type -sub device_mkfs { - my ($device, $type) = @_; - if ($type eq 'vfat') { - run_('mkfs.vfat', $device); - } elsif (member($type, 'ext2', 'ext3')) { - run_("mkfs.$type", "-m", 0, if_(!-b $device, '-F'), $device); - } else { - die "unable to mkfs for unsupported media type $type\n"; - } -} - sub set_device_label { my ($device, $type, $label) = @_; if ($type eq 'vfat') { @@ -1147,7 +1130,7 @@ sub allocate_master { my $disk_size = $size + $track_size; my $cylinders = int($disk_size / $cylinder_size); - device_allocate_file($dest, $disk_size); + MDV::Draklive::Utils::device_allocate_file($dest, $disk_size); #- FIXME: use parted? require fs::type; @@ -1174,7 +1157,7 @@ EOF my $loop = devices::find_free_loop(); run_('losetup', '-o', $part_start * $sector_size, '-s', $part_nb_sectors * $sector_size, $loop, $dest) or die "unable to setup loop device"; - device_mkfs($loop, $fs) or die "unable to format $dest\n"; + MDV::Draklive::Utils::device_mkfs($loop, $fs) or die "unable to format $dest\n"; return $loop; } @@ -1222,7 +1205,7 @@ sub format_usb_device { my ($live, $opts) = @_; my $device = get_media_device($live, $opts); maybe_umount_device($device); - device_mkfs($device, $live->{media}->get_media_setting('fs')) + MDV::Draklive::Utils::device_mkfs($device, $live->{media}->get_media_setting('fs')) or die "unable to format device $device\n"; } diff --git a/lib/MDV/Draklive/Utils.pm b/lib/MDV/Draklive/Utils.pm index d1b98e3..3fae6a9 100644 --- a/lib/MDV/Draklive/Utils.pm +++ b/lib/MDV/Draklive/Utils.pm @@ -51,4 +51,21 @@ sub mtools_run_ { &run_; } +sub device_allocate_file { + my ($device, $size) = @_; + run_('dd', "of=$device", 'count=0', 'bs=1', "seek=" . removeXiBSuffix($size)); +} + +#- format $device as type $type +sub device_mkfs { + my ($device, $type) = @_; + if ($type eq 'vfat') { + run_('mkfs.vfat', $device); + } elsif (member($type, 'ext2', 'ext3')) { + run_("mkfs.$type", "-m", 0, if_(!-b $device, '-F'), $device); + } else { + die "unable to mkfs for unsupported media type $type\n"; + } +} + 1; -- cgit v1.2.1