From 0dfaff54e2d3291735d610c446dd0253f7294094 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Fri, 7 Aug 2009 21:31:50 +0000 Subject: adapt to main device being disk instead of partition --- draklive | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/draklive b/draklive index abdc17b..6f0ae5f 100755 --- a/draklive +++ b/draklive @@ -922,12 +922,20 @@ sub record_usb_master { if (my $label = !$opts->{boot_only} && $opts->{device} && $media->get_media_label) { set_device_label($opts->{device}, $media->get_media_setting('fs'), $label); } - my $device = get_media_device($live, $opts) + my $main_device = get_media_device($live, $opts) or die "unable to find recording device (missing label? try with --device )\n"; + my $hd = get_hd_from_file($media, $main_device); + guess_media_partitions_start($media, $hd); + + my $slash_idx = $media->find_partition_index('/'); + my $slash = $media->{partitions}[$slash_idx]; + set_part_real_device($hd, $slash); + mkdir_p($live->{mnt}); - run_('mount', $device, $live->{mnt}) - or die "unable to mount $device\n"; + run_('mount', $slash->{real_device}, $live->{mnt}) + or die "unable to mount $slash->{real_device}\n"; + rm_rf($live->{mnt} . $media_boot) if -e $live->{mnt} . $media_boot; cp_af($live->get_builddir . $live->{prefix}{build}{boot}, $live->{mnt} . $media_boot); @@ -945,8 +953,9 @@ sub record_usb_master { ); unlink $list_file; if (!$r) { - run_('umount', $live->{mnt}); - maybe_umount_device($device); + run_('umount', $slash->{real_device}); + maybe_umount_device($slash->{real_device}); + devices::del_loop($slash->{real_device}) if -f $hd->{file}; die "unable to copy loopback files\n"; } @@ -955,14 +964,16 @@ sub record_usb_master { my @hidden_files = map { basename($_) } glob_($live->{mnt} . "/.*"), glob_($live->{mnt} . "/autorun.*"); - run_('umount', $live->{mnt}); - maybe_umount_device($device); + run_('umount', $slash->{real_device}); + maybe_umount_device($slash->{real_device}); if ($media->get_media_setting('fs') eq 'vfat') { - MDV::Draklive::Utils::mtools_run_('mattrib', '+h', '-i', $device, '::' . $_) foreach @hidden_files; - MDV::Draklive::Utils::mtools_run_('mattrib', '+r', '+s', '-/', '-i', $device, '::' . $_) + MDV::Draklive::Utils::mtools_run_('mattrib', '+h', '-i', $slash->{real_device}, '::' . $_) foreach @hidden_files; + MDV::Draklive::Utils::mtools_run_('mattrib', '+r', '+s', '-/', '-i', $slash->{real_device}, '::' . $_) foreach $media_boot, $media_loopbacks; } + + devices::del_loop($slash->{real_device}) if -f $hd->{file}; } sub record_harddisk_master { -- cgit v1.2.1