From 93d55c51cb90f118847bd78af400e9b41d72e1e9 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Thu, 30 Oct 2003 11:44:09 +0000 Subject: add live_tree_always --- move/make_live_tree_boot | 70 +++++++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 28 deletions(-) (limited to 'move/make_live_tree_boot') diff --git a/move/make_live_tree_boot b/move/make_live_tree_boot index a6dc47721..bea1f8224 100755 --- a/move/make_live_tree_boot +++ b/move/make_live_tree_boot @@ -2,18 +2,34 @@ use MDK::Common; -my $prefix = '/tmp/live_tree'; -my $boot_prefix = '/tmp/live_tree_boot'; -my $file_list = 'data/boot.list'; +sub create_light_tree { + my ($live_name, $prefix, $light_prefix, $list) = @_; + + -e $light_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|$light_prefix|; + + my $link = $orig; + $link =~ s|^$prefix|/image_$live_name|; + + 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"; + } +} -my @list = chomp_(cat_($file_list)); +sub remove_light_tree { + my ($live_name, $prefix, $light_prefix, $list) = @_; -if (@ARGV && $ARGV[0] eq '-u') { - -d $boot_prefix or die "$boot_prefix doesn't exist"; + -d $light_prefix or return; - foreach my $dest (@list) { + foreach my $dest (@$list) { my $orig = $dest; - $orig =~ s|^$prefix|$boot_prefix|; + $orig =~ s|^$prefix|$light_prefix|; next if !-e $orig; @@ -24,40 +40,38 @@ if (@ARGV && $ARGV[0] eq '-u') { rename $orig, $dest or die "moving $orig to $dest failed: $!\n"; } } - rmdir($_) foreach reverse(chomp_(`find $boot_prefix -type d`)); + rmdir($_) foreach reverse(chomp_(`find $light_prefix -type d`)); - if (-e $boot_prefix) { + if (-e $light_prefix) { print "still there:\n"; - system('find', $boot_prefix); + system('find', $light_prefix); foreach my $dest (chomp_(`find $prefix -type l`)) { my $orig = readlink($dest) or next; - $orig =~ s!/image_boot/!$boot_prefix/! or next; + $orig =~ s!/image_$live_name/!$light_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`)); + rmdir($_) foreach reverse(chomp_(`find $light_prefix -type d`)); } - if (-e $boot_prefix) { + if (-e $light_prefix) { print "still there:\n"; - system('find', $boot_prefix); + system('find', $light_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 $prefix = '/tmp/live_tree'; +my ($boot_prefix, $always_prefix) = ('/tmp/live_tree_boot', '/tmp/live_tree_always'); +my @boot_list = chomp_(cat_('data/boot.list')); +my @always_list = chomp_(cat_('data/always.list')); - my $link = $orig; - $link =~ s|^$prefix|/image_boot|; +@boot_list = difference2(\@boot_list, \@always_list); - mkdir_p(dirname($dest)); - rename $orig, $dest or die "moving $orig to $dest failed: $!\n"; +remove_light_tree('boot', $prefix, $boot_prefix, \@boot_list); +remove_light_tree('always', $prefix, $always_prefix, \@always_list); - symlink $link, $orig or die "symlinking from $dest to $orig failed: $!\n"; - } +if (!@ARGV) { + create_light_tree('boot', $prefix, $boot_prefix, \@boot_list); + create_light_tree('always', $prefix, $always_prefix, \@always_list); } -- cgit v1.2.1