1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
#!/usr/bin/perl
use MDK::Common;
my $prefix = '/tmp/live_tree';
sub create_light_tree {
my ($live_name, $list) = @_;
my $light_prefix = $prefix . '_' . $live_name;
-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|;
mkdir_p(dirname($dest));
if (-l $orig) {
symlink readlink($orig), $dest;
} else {
my $link = $orig;
$link =~ s|^$prefix|/image_$live_name|;
rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
symlink $link, $orig or die "symlinking from $dest to $orig failed: $!\n";
}
}
}
sub create_totem_links {
my ($live_name, $list) = @_;
my $light_prefix = $prefix . '_' . $live_name;
#- creating all the dirs, even when things are in the "always" tree
foreach my $orig (@$list) {
my $dest = $orig;
$dest =~ s|^$prefix|$light_prefix|;
mkdir_p(dirname($dest)) if ! (-e $dest || -l $dest);
if (-l $orig) {
symlink readlink($orig), $dest;
}
}
foreach my $dir (chomp_(`cd $light_prefix ; find usr -type d`)) {
foreach my $f (all("$prefix/$dir")) {
my $file = "$prefix/$dir/$f";
my $link = readlink($file) =~ /^\w/ ? readlink($file) : "/image/$dir/$f";
symlink $link, "$light_prefix/$dir/$f";
}
}
}
sub remove_light_tree {
my ($live_name, $list) = @_;
my $light_prefix = $prefix . '_' . $live_name;
-d $light_prefix or return;
foreach my $dest (@$list) {
my $orig = $dest;
$orig =~ s|^$prefix|$light_prefix|;
if (-l $orig) {
unlink $orig;
} elsif (-e $orig) {
if (-e $dest && -s $dest != -s $orig) {
warn "ERROR: $dest already exist, skipping\n";
} elsif (!-d $dest || -l $dest) {
unlink $dest or die "removing $dest failed: $!\n";
rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
}
}
}
rmdir($_) foreach reverse(chomp_(`find $light_prefix -type d`));
if (-e $light_prefix) {
unlink($_) foreach chomp_(`find $light_prefix -type l`);
foreach my $orig (chomp_(`find $light_prefix -type f`)) {
my $dest = $orig;
$dest =~ s|^$light_prefix|$prefix|;
if (my $orig2 = readlink($dest)) {
$orig2 =~ s!/image_$live_name/!$light_prefix/! or next;
$orig2 eq $orig or next;
} else {
next if -e $dest && -s $dest != -s $orig;
}
unlink $dest or die "removing $dest failed: $!\n";
rename $orig, $dest or die "moving $orig to $dest failed: $!\n";
}
system("rm -rf $light_prefix/usr/bin/stage2/*.pm");
system("rm -rf $light_prefix/usr/lib/libDrakX/*.pm");
system("rm -rf $light_prefix/usr/share/langs/*.png");
rmdir($_) foreach reverse(chomp_(`find $light_prefix -type d`));
}
if (-e $light_prefix) {
print "still there:\n";
system('find', $light_prefix);
}
}
my @always_list = chomp_(cat_('data/always.list'));
my @boot_list_orig = chomp_(cat_('data/boot.list'));
my @totem_list_orig = chomp_(cat_('data/totem.list'));
@always_list = uniq(@always_list, intersection(\@boot_list_orig, \@totem_list_orig));
my @boot_list = difference2(\@boot_list_orig, \@always_list);
my @totem_list = difference2(\@totem_list_orig, \@always_list);
remove_light_tree('always', \@always_list);
remove_light_tree('boot', \@boot_list);
remove_light_tree('totem', \@totem_list);
if (!@ARGV) {
create_light_tree('always', \@always_list);
create_light_tree('boot', \@boot_list);
create_light_tree('totem', \@totem_list);
create_totem_links('totem', \@totem_list_orig);
}
|