From fc897b858da643419aa9cb5b4de5936d0521349b Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 30 Mar 2010 12:38:21 +0000 Subject: delete existing files on media when recording, unless --keep-files option is used --- draklive | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/draklive b/draklive index e3a6329..060a9a5 100755 --- a/draklive +++ b/draklive @@ -896,6 +896,11 @@ sub record_cdrom_master { run_('wodim', '-v', 'dev=' . $device, $src); } +sub rsync_delete_options { + my ($opts) = @_; + $opts->{keep_files} ? () : '--delete'; +} + sub install_grub_to_image { my ($live, $media, $img, $opts) = @_; my $media_boot = $live->get_media_prefix('boot', $opts->{boot}); @@ -1002,7 +1007,7 @@ sub record_usb_master { output_p($list_file, map { ".$_\n" } list_selected_loopbacks($live)); local $/ = "\r"; my $r = run_foreach(update_progress_rsync($live, $total), - 'rsync', '-vdP', '--inplace', '--files-from=' . $list_file, + 'rsync', '-vdP', '--inplace', '--files-from=' . $list_file, rsync_delete_options($opts), $loopbacks_source, $live->{mnt} . $media_loopbacks, ); unlink $list_file; @@ -1058,7 +1063,7 @@ sub record_harddisk_master { my $source = $live->get_system_root; my $total = directory_usage($source); local $/ = "\r"; - $r = run_foreach(update_progress_rsync($live, $total), 'rsync', '-a', $source . '/', $live->{mnt}) + $r = run_foreach(update_progress_rsync($live, $total), 'rsync', rsync_delete_options($opts), '-a', $source . '/', $live->{mnt}) or last; } unless $opts->{boot_only}; @@ -1543,6 +1548,7 @@ my $settings_path = $MDV::Draklive::Config::default_settings_path; GetOptions( "help" => sub { Pod::Usage::pod2usage('-verbose' => 1) }, "copy-wizard" => \$live_object->{copy_wizard}, + "keep-files" => \$opts{keep_files}, "boot-only" => \$opts{boot_only}, "boot-image=s" => sub { $opts{boot} = $_[1]; $opts{boot_only} = 1 }, "all" => sub { $_->{to_run} = 1 foreach grep { member($_->{name}, @all) } @actions }, @@ -1604,6 +1610,7 @@ draklive [options] --record record live on selected media --record-onthefly record live by creating master from loopback files on the fly + --keep-files keep existing files on media when recording --initrd build initrd only --post-install run post install only (rpms and patches installation) -- cgit v1.2.1