summaryrefslogtreecommitdiffstats
path: root/move/make_live_tree_boot
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2003-10-22 16:20:24 +0000
committerPascal Rigaux <pixel@mandriva.com>2003-10-22 16:20:24 +0000
commit4a5604021581abcbf0d9c8c5eb88f18cfb1c83df (patch)
tree78142e34d0052b92dad7fda17d59dc45dae19826 /move/make_live_tree_boot
parent12b36a5be288c96173918b72f2ad58afba177215 (diff)
downloaddrakx-backup-do-not-use-4a5604021581abcbf0d9c8c5eb88f18cfb1c83df.tar
drakx-backup-do-not-use-4a5604021581abcbf0d9c8c5eb88f18cfb1c83df.tar.gz
drakx-backup-do-not-use-4a5604021581abcbf0d9c8c5eb88f18cfb1c83df.tar.bz2
drakx-backup-do-not-use-4a5604021581abcbf0d9c8c5eb88f18cfb1c83df.tar.xz
drakx-backup-do-not-use-4a5604021581abcbf0d9c8c5eb88f18cfb1c83df.zip
add make_live_tree_boot
Diffstat (limited to 'move/make_live_tree_boot')
-rwxr-xr-xmove/make_live_tree_boot60
1 files changed, 60 insertions, 0 deletions
diff --git a/move/make_live_tree_boot b/move/make_live_tree_boot
new file mode 100755
index 000000000..209631472
--- /dev/null
+++ b/move/make_live_tree_boot
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+
+use MDK::Common;
+
+my $prefix = '/tmp/live_tree';
+my $boot_prefix = '/tmp/live_tree_boot';
+my $file_list = 'data/boot.list';
+
+my @list = chomp_(cat_($file_list));
+
+if (@ARGV && $ARGV[0] eq '-u') {
+ -d $boot_prefix or die "$boot_prefix doesn't exist";
+
+ foreach my $dest (@list) {
+ my $orig = $dest;
+ $orig =~ s|^$prefix|$boot_prefix|;
+
+ next if !-e $orig;
+
+ if (-e $dest && -s $dest != -s $orig) {
+ warn "ERROR: $dest already exist, skipping\n";
+ } else {
+ unlink $dest or die "removing $dest failed: $!\n";
+ rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
+ }
+ }
+ rmdir($_) foreach reverse(chomp_(`find $boot_prefix -type d`));
+
+ if (-e $boot_prefix) {
+ foreach my $dest (chomp_(`find $prefix -type l`)) {
+ my $orig = readlink($dest) or next;
+ $orig =~ s!/image_boot/!$boot_prefix/! or next;
+
+ unlink $dest or die "removing $dest failed: $!\n";
+ rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
+ }
+ rmdir($_) foreach reverse(chomp_(`find $boot_prefix -type d`));
+ }
+ if (-e $boot_prefix) {
+ print "still there:\n";
+ system('find', $boot_prefix);
+ }
+
+} else {
+ -e $boot_prefix and die "you can't make_live_tree_boot since one already exists
+Maybe you should remove it first with 'make_live_tree_boot -u'\n";
+
+ foreach my $orig (@list) {
+ my $dest = $orig;
+ $dest =~ s|^$prefix|$boot_prefix|;
+
+ my $link = $orig;
+ $link =~ s|^$prefix|/image_boot|;
+
+ mkdir_p(dirname($dest));
+ rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
+
+ symlink $link, $orig or die "symlinking from $dest to $orig failed: $!\n";
+ }
+}