summaryrefslogtreecommitdiffstats
path: root/move
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-11-03 10:02:28 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-11-03 10:02:28 +0000
commit4125fe431ee17c41f05e3154263b0bb197615578 (patch)
treecac81055dc1b2de11700f2ded5217e7e5f422edd /move
parent9ab0d2612ef64042ef3684ae4491fdca6c1af0e9 (diff)
downloaddrakx-backup-do-not-use-4125fe431ee17c41f05e3154263b0bb197615578.tar
drakx-backup-do-not-use-4125fe431ee17c41f05e3154263b0bb197615578.tar.gz
drakx-backup-do-not-use-4125fe431ee17c41f05e3154263b0bb197615578.tar.bz2
drakx-backup-do-not-use-4125fe431ee17c41f05e3154263b0bb197615578.tar.xz
drakx-backup-do-not-use-4125fe431ee17c41f05e3154263b0bb197615578.zip
need script replacing mdk_move_change_loop
Diffstat (limited to 'move')
-rwxr-xr-xmove/tree/mdk_move_loop46
1 files changed, 46 insertions, 0 deletions
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 <to_cdrom | to_memory> [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);
+}