From 4125fe431ee17c41f05e3154263b0bb197615578 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 3 Nov 2003 10:02:28 +0000 Subject: need script replacing mdk_move_change_loop --- move/tree/mdk_move_loop | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 move/tree/mdk_move_loop (limited to 'move/tree') diff --git a/move/tree/mdk_move_loop b/move/tree/mdk_move_loop new file mode 100755 index 000000000..6b239316b --- /dev/null +++ b/move/tree/mdk_move_loop @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +my %loop = (boot => 'loop0', always => 'loop1', totem => 'loop2'); + +sub check { + my ($loop, $file) = @_; + `sudo losetup /dev/$loop 2>/dev/null` =~ m!/$file!; +} + +sub name2file { + my ($name) = @_; + "live_tree_$name.clp"; +} + +sub to_memory { + my ($loop, $file) = @_; + + return if -e "/tmp/$file"; + + if (-e "/$file") { + system("sudo mv /$file /tmp"); + } else { + system("sudo cp /image_raw/$file /tmp"); + } + system("sudo losetup /dev/$loop /tmp/$file"); +} + +sub to_cdrom { + my ($loop, $file) = @_; + my $f = -e "/$file" ? "/$file" : -e "/tmp/$file" ? "/tmp/$file" : return; + system("sudo losetup /dev/$loop /image_raw/$file"); + system("sudo rm $f"); +} + +sub usage() { die "usage: mdk_move_loop [names ...]\n" } + +my ($direction, @names) = @ARGV; +my $f = $direction eq 'to_memory' && \&to_memory || $direction eq 'to_cdrom' && \&to_cdrom; +$f && @names or usage(); + +foreach my $name (@names) { + my $loop = $loop{$name} or die "unknown name $name\n"; + my $file = name2file($name); + check($loop, $file) or next; + $f->($loop, $file); +} -- cgit v1.2.1