#!/usr/bin/perl use MDK::Common; use lib "../perl-install"; use keyboard; $lib = (arch() =~ /x86_64/ ? "lib64" : "lib"); $tmp = "/tmp/rescue_tmp"; $mnt = "/tmp/rescue_stage2_img"; $mke2fs = "/sbin/mke2fs -q -m 0 -F -s 1"; $rescue = "rescue_stage2"; if ($>) { $sudo = "sudo"; $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; } BEGIN { undef *_; } sub __ { print @_, "\n"; system(@_); } sub _ { __ @_; $? and die; } sub install_raw { s|^/|| foreach @_; _ "tar c -C / @_ | tar x -C $tmp" if @_; } sub install_deref { s|^/|| foreach @_; _ "tar c -C / --dereference @_ | tar x -C $tmp" if @_; } sub install_l { my @l = @_; @l = uniq(map { chomp_($_) } @l); push @l, `ldd @l 2>/dev/null | grep "=>" | perl -pe 's/.*=> //; s/ .*//; s,^/lib/.*?/,/lib/,'`; my ($deref, $raw) = partition { /lib.*\.so/ || readlink("/$_") =~ m|/etc/alternatives| } uniq(map { chomp_($_) } @l); install_raw(@$raw); install_deref(@$deref); } sub installown($$) { my ($own, $dir) = @_; return if -e "$tmp$dir$own"; mkdir_p("$tmp$dir"); _ "cp -a $own $tmp$dir"; } _ "$sudo rm -rf $tmp" if -e $tmp; _ "mkdir $tmp"; _ 'find . -name "*~" | xargs rm -f'; foreach (cat_("dirs")) { chomp; mkdir_p("$tmp$_"); } _ "cp -a tree/* $tmp"; _ "find $tmp -name 'CVS*' | xargs rm -rf"; _ "perl devices.pl $tmp/dev"; install_raw(keyboard::loadkeys_files()); my %keytable_conflicts; my @less_important_keytables = qw(am_old am_phonetic no-dvorak fr_CH-latin1); foreach (keyboard::loadkeys_files()) { my ($dir, $fname) = (dirname($_), basename($_)); my ($name) = $fname =~ /(.*)\.kmap\.gz/ or next; next if member($name, @less_important_keytables); if (my ($short) = $name =~ m|(.+?)[\W_]|) { $keytable_conflicts{$short} and warn("conflict between $keytable_conflicts{$short} and $name for short name $short (choosing the first)\n"), next; $keytable_conflicts{$short} = $name; # create the short name based on the long one symlinkf($fname, "$tmp$dir/$short.kmap.gz"); } } my $perl_version = join ".", unpack "C3", $^V; @files = map { chomp; s/PERL_VERSION/$perl_version/g; s|/LIB/|/$lib/|g; $_ } (cat_("list"), cat_(`../tools/specific_arch list`)); @files = `ls -d @files`; $? == 0 or exit 1; install_l(@files); foreach (cat_("aliases")) { chomp; my ($f, $dest) = split; symlink $dest, "$tmp$f"; } -e "../kernel/all.modules" or die "use ./update_kernel in gi/kernel first\n"; chomp($main = `cat ../kernel/all.kernels/.main`); _ "cp ../kernel/all.modules/modules.cz-$main $tmp/modules/modules.cz"; _ "cp ../kernel/all.modules/$main/modules.dep $tmp/modules"; installown("drvinst", "/usr/bin"); installown("guessmounts", "/usr/bin"); installown("install_bootloader", "/usr/bin"); if (arch() =~ /^i.86/) { installown("restore_ms_boot", "/usr/bin"); } installown("lsparts", "/usr/bin"); installown("rescue-doc", "/usr/bin"); _ "cd ../mdk-stage1 && make rescue-gui"; installown("../mdk-stage1/rescue-gui", "/usr/bin"); #- note that on biarch systems, we may need to have both /lib and /lib64 __ "strip $tmp/{lib,$lib,bin,sbin}/* $tmp/usr/{bin,sbin}/* 2>/dev/null"; exit 0 if $ARGV[0]; if (arch() =~ /ppc/) { #- xfs module on PPC is 4MB! - need room to unpack it $size = `du -s $tmp | cut -f1` + 4096; #- add 4MB of free space } else { $size = `du -s $tmp | cut -f1` + 2048; #- add 2MB of free space } mkdir_p($mnt); __ "$sudo umount $rescue 2>/dev/null"; _ "dd if=/dev/zero of=$rescue bs=1k count=$size"; _ "$mke2fs $rescue"; _ "$sudo mount -t ext2 $rescue $mnt -o loop"; _ "rmdir $mnt/lost+found"; _ "$sudo chown -R root.root $tmp"; _ "$sudo cp -a $tmp/* $mnt"; _ "$sudo rm -rf $tmp"; _ "$sudo umount $rescue"; _ "rmdir $mnt"; _ "bzip2 -f -9 $rescue"; x86_64-branch Mageia Installer and base platform for many utilitiesThierry Vignaud [tv]
summaryrefslogtreecommitdiffstats
path: root/perl-install/do_pkgs.pm
blob: f0feda785f7694501a119c75dab057ea1a092ba7 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
package do_pkgs; # $Id$

sub do_pkgs {
    my ($in) = @_;
    ($::isInstall ? 'do_pkgs_during_install' : 'do_pkgs_standalone')->new($in);
}

################################################################################