1 | #!/usr/bin/perl |
---|
2 | # |
---|
3 | # to prepare, create and burn iso images |
---|
4 | # |
---|
5 | |
---|
6 | use strict; |
---|
7 | use File::Path; |
---|
8 | use File::NCopy qw(copy); |
---|
9 | |
---|
10 | my @config; |
---|
11 | # FIXME nedd to remove this |
---|
12 | my $config = \@config; |
---|
13 | my $fast = 0; |
---|
14 | my @func; |
---|
15 | my $topdir = `pwd`; |
---|
16 | chop $topdir; |
---|
17 | my $deps; |
---|
18 | my $auto=0; |
---|
19 | my $tag; |
---|
20 | my $filetag; |
---|
21 | my $log=0; |
---|
22 | my $distrib = "72"; |
---|
23 | my $tmp = $ENV{TMPDIR} || "/tmp" ; |
---|
24 | |
---|
25 | my @params = ([ "l", "lists-check", 0 , "","check the lists.", \&check, "Checking of the lists"], |
---|
26 | [ "f", "fast", 0 , "", "fast mode.", sub {$fast = 1}, "Fast mode"], |
---|
27 | [ "d", "depslist-creation", 0 , "", "rebuild the desplist.ordered file before checking the list.", sub {$deps=1}, "Depslist creation switch"], |
---|
28 | [ "", "distrib", 1, "", "specify the target distrib.", sub {$distrib=shift}, "Specifying target distrib"], |
---|
29 | [ "a", "auto", 0, "", "Automated mode, add dependencies.", sub {$auto=1}, "Auto mode switch"], |
---|
30 | [ "m", "make", 1, "<cds number>", "Build the CDs.", \&make, "Building the CDs"], |
---|
31 | [ "s", "score", 0, "", "Score the lists.", \&score, "Scoring the lists"], |
---|
32 | [ "c", "catto", 1, "<log file>", "Log file.", sub {$log = pop @_; open LOG,">$log" or die "unable to open $log\n"}, "Log file"], |
---|
33 | [ "i", "init", 1, "<top dir>", "Initialise the architecture.", sub {init(pop @_)}, "Initialising the architecture"], |
---|
34 | [ "t", "topdir", 1, "<top dir>", "Top dir.", sub {$topdir = pop @_}, "Setting the top dir"], |
---|
35 | [ "o", "outname", 1, "<tag>", "Tag added to the VERSION file.", sub {$tag = pop @_}, "Setting the top dir"], |
---|
36 | [ "h", "check", -1, "<dir 1> <dir 2> ... <dir n>", "Check the hdlists, depslist and RPMS coherency.", sub { checkcds([0,@_])}, "Checking the hdlists, depslist and RPMs coherency"], |
---|
37 | [ "g", "getdeps", -2, "<depslist.ordered directory> <package 1> <package 2> ... <package n>","Generate the dependencies list of a list of packages.", sub { getdeps(shift,[@_])}, "Generating dependencies list of the packages"], |
---|
38 | [ "k", "checkcu", -1, "<dir 1> <dir 2> ... <dir n>", "Checking the compssUser.", sub { checkcompssUser([0,@_])}, "Checking the compssUser"] |
---|
39 | ); |
---|
40 | |
---|
41 | my %params; |
---|
42 | foreach (@params) { |
---|
43 | $_->[0] and $params{$_->[0]} = $_; |
---|
44 | $_->[1] and $params{$_->[1]} = $_ |
---|
45 | } |
---|
46 | |
---|
47 | my $params; |
---|
48 | foreach (@params) { $params .= $_->[0]} |
---|
49 | |
---|
50 | @ARGV or usage(); |
---|
51 | |
---|
52 | my @todo; |
---|
53 | local *LOG; |
---|
54 | open LOG,">&STDOUT"; |
---|
55 | |
---|
56 | #while ($_ = shift @ARGV){ |
---|
57 | # if(/^-([$params]+)/){ |
---|
58 | # my @letter = split / */, $1; |
---|
59 | # foreach my $l (@letter){ |
---|
60 | # for (my $p=0; $p < @params; $p++){ |
---|
61 | # if ($l =~ /$params[$p]->[0]/){ |
---|
62 | # my $i=$params[$p]->[2]; |
---|
63 | # $i == -1 and do { &{$params[$p]->[5]}(@ARGV) ; exit}; |
---|
64 | # my @tmp; |
---|
65 | # while ($i--) { push @tmp, (shift @ARGV or usage())}; |
---|
66 | # print "$p $params[$p]->[4] $params[$p]->[2] -- @tmp\n"; |
---|
67 | # push @todo, [$p, \@tmp] } |
---|
68 | # } |
---|
69 | # } |
---|
70 | # }elsif (/^--(.*)/) { |
---|
71 | # for (my $p=0; $p < @params; $p++){ |
---|
72 | # if (/$params[$p]->[1]$/) { |
---|
73 | # my $i=$params[$p]->[2]; |
---|
74 | # $i == -1 and do { &{$params[$p]->[5]}(@ARGV) ; exit}; |
---|
75 | # my @tmp; |
---|
76 | # while ($i--) { push @tmp, (shift @ARGV or usage())}; |
---|
77 | # print "$p $params[$p]->[4] $params[$p]->[2] -- @tmp\n"; |
---|
78 | # push @todo, [$p, \@tmp] } |
---|
79 | # } |
---|
80 | # } else { print "Loading configuration file\n"; @config=config($_) } |
---|
81 | #} |
---|
82 | # |
---|
83 | #@config or usage(); |
---|
84 | # |
---|
85 | #foreach (@todo){ |
---|
86 | # &{$params[$_->[0]]->[5]}(\@config, $fast,$topdir,$deps,$tag,@{$_->[1]}) or print "ERROR: $params[$_->[0]]->[5]\n"; |
---|
87 | #} |
---|
88 | #exit; |
---|
89 | |
---|
90 | while ($_ = shift @ARGV){ |
---|
91 | my @cur; |
---|
92 | if(/^-([$params]+)/){ |
---|
93 | my @letter = split / */, $1; |
---|
94 | push @cur, @letter; |
---|
95 | }elsif (/^--(.*)/) { push @cur, $1; } |
---|
96 | else { print "Loading configuration file\n"; @config=config($_) } |
---|
97 | foreach (@cur){ |
---|
98 | $params{$_} or usage(); |
---|
99 | my $i=$params{$_}->[2]; |
---|
100 | my @tmp; |
---|
101 | $i < 0 and do { while ($i++) { push @tmp, (shift @ARGV or usage()) } push @tmp, @ARGV} |
---|
102 | or do { while ($i--) { push @tmp, (shift @ARGV or usage()) } }; |
---|
103 | print "DEBUG $_ $params{$_}->[4] $params{$_}->[2] -- @tmp\n"; |
---|
104 | push @todo, [$_, \@tmp] |
---|
105 | } |
---|
106 | } |
---|
107 | |
---|
108 | # @config or usage(); |
---|
109 | |
---|
110 | foreach (@todo){ |
---|
111 | &{$params{$_->[0]}->[5]}(@{$_->[1]}) or print "ERROR: $params{$_->[0]}->[6]\n"; |
---|
112 | } |
---|
113 | exit; |
---|
114 | |
---|
115 | |
---|
116 | sub usage{ |
---|
117 | print "usage |
---|
118 | $0 [options] arguments |
---|
119 | options:\n"; |
---|
120 | foreach (@params) { |
---|
121 | $_->[0] and print "\t\t-$_->[0], --$_->[1] $_->[3]\n\t\t\t$_->[4]\n" and next; |
---|
122 | $_->[1] and print "\t\t--$_->[1] $_->[3]\n\t\t\t$_->[4]\n" and next; |
---|
123 | } |
---|
124 | print "\n"; |
---|
125 | exit |
---|
126 | } |
---|
127 | |
---|
128 | #while ($_ = shift @ARGV){ |
---|
129 | # if(/^--check$/) { checkcds((0,@ARGV)); exit} |
---|
130 | # elsif(/^--checkcu$/) { checkcompssUser((0,@ARGV)); exit} |
---|
131 | # elsif(/^-+g/) { getdeps(shift @ARGV or usage(), \@ARGV); exit} |
---|
132 | # elsif (/^[-]+[alfsdm]+/){ |
---|
133 | # if(/l/){ push @func, \&check} |
---|
134 | # if(/f/){ $fast = 1} |
---|
135 | # if(/d/){ $deps = 1} |
---|
136 | # if(/a/){ $auto = 1} |
---|
137 | # if(/m/){ push @func, \&make} |
---|
138 | # if(/s/){ push @func, \&score} |
---|
139 | # }elsif(/^[-]+t/){ $topdir = shift @ARGV} |
---|
140 | # elsif(/^[-]+o/){ $tag = shift @ARGV;} |
---|
141 | # elsif(/^[-]+c/){ $log = shift @ARGV} |
---|
142 | # elsif(/^[-]+i/){ init(shift @ARGV or "."); exit } |
---|
143 | # else { @config=config($_)} |
---|
144 | #} |
---|
145 | |
---|
146 | my %must_be_on_cd1 = ( |
---|
147 | 'freetype' => 1, |
---|
148 | 'ipxutils' => 1, |
---|
149 | 'XFree86-Mono' => 1, |
---|
150 | 'XFree86-server-common' => 1, |
---|
151 | 'gdbm' => 1, |
---|
152 | 'Device3Dfx' => 1, |
---|
153 | 'rp-pppoe' => 1, |
---|
154 | 'XFree86-SVGA' => 1, |
---|
155 | 'libjpeg' => 1, |
---|
156 | 'dhcpcd' => 1, |
---|
157 | 'chkfontpath' => 1, |
---|
158 | 'isdn4net' => 1, |
---|
159 | 'ypbind' => 1, |
---|
160 | 'XFree86-FBDev' => 1, |
---|
161 | 'lpr' => 1, |
---|
162 | 'ghostscript-fonts' => 1, |
---|
163 | 'XFree86' => 1, |
---|
164 | 'menu' => 1, |
---|
165 | 'xinitrc' => 1, |
---|
166 | 'gtk+' => 1, |
---|
167 | 'ghostscript' => 1, |
---|
168 | 'pppoe-linuxconf' => 1, |
---|
169 | 'linuxconf' => 1, |
---|
170 | 'Glide_V3-DRI' => 1, |
---|
171 | 'XFree86-AGX' => 1, |
---|
172 | 'XFree86' => 1, |
---|
173 | 'libtiff' => 1, |
---|
174 | 'XFree86-xfs' => 1, |
---|
175 | 'ppp' => 1, |
---|
176 | 'samba-common' => 1, |
---|
177 | 'Mesa' => 1, |
---|
178 | 'XFree86-glide-module' => 1, |
---|
179 | 'cups-drivers' => 1, |
---|
180 | 'urw-fonts' => 1, |
---|
181 | 'XFree86-S3' => 1, |
---|
182 | 'Glide_V5' => 1, |
---|
183 | 'xpm' => 1, |
---|
184 | 'isdn4k-utils' => 1, |
---|
185 | 'libpng' => 1, |
---|
186 | 'XFree86-I128' => 1, |
---|
187 | 'pptp-adsl-fr' => 1, |
---|
188 | 'mpage' => 1, |
---|
189 | 'ncpfs' => 1, |
---|
190 | 'tcsh' => 1, |
---|
191 | 'yp-tools' => 1, |
---|
192 | 'XFree86-W32' => 1, |
---|
193 | 'XFree86-libs' => 1, |
---|
194 | 'XFree86-Mach64' => 1, |
---|
195 | 'XFree86-P9000' => 1, |
---|
196 | 'samba' => 1, |
---|
197 | 'dhcpxd' => 1, |
---|
198 | 'XFree86-Mach8' => 1, |
---|
199 | 'dhcp-client' => 1, |
---|
200 | 'portmap' => 1, |
---|
201 | 'cups' => 1, |
---|
202 | 'XFree86-VGA16' => 1, |
---|
203 | 'rhs-printfilters' => 1, |
---|
204 | 'XFree86-S3V' => 1, |
---|
205 | 'XFree86-Mach32' => 1, |
---|
206 | 'gcc-cpp' => 1, |
---|
207 | 'Mesa-common' => 1, |
---|
208 | 'XFree86-3DLabs' => 1, |
---|
209 | 'pump' => 1, |
---|
210 | 'tcl' => 1, |
---|
211 | 'XFree86-server' => 1, |
---|
212 | 'file' => 1 |
---|
213 | ); |
---|
214 | |
---|
215 | #if (@func && @config) { |
---|
216 | # foreach my $f (@func){ |
---|
217 | # $f->(\@config, $fast,$topdir,$deps,$tag)} |
---|
218 | # exit |
---|
219 | #} |
---|
220 | #usage(); |
---|
221 | # |
---|
222 | #sub usage{ |
---|
223 | # print "usage: |
---|
224 | # $0 -i <dir> : initialise environment |
---|
225 | # $0 [-lfdmato] configfile <topdir> |
---|
226 | # $0 [--check --checkcu] topdir |
---|
227 | # $0 -g --gendeps topdir packages_list |
---|
228 | # options: |
---|
229 | # -l: check the CDs lists |
---|
230 | # -a: auto, do more things |
---|
231 | # -f: fast mode, do less things |
---|
232 | # -d: rebuild the dependencies list before checking lists |
---|
233 | # -m: create the isos |
---|
234 | # -t <dir>: top directory, vurre |
---|
235 | # -o <name>: tag added to images name and in the VERSION file |
---|
236 | # -s: score the current lists |
---|
237 | # --check: check that depslist.ordered, hdlist*.cz and RPMS dir are synched |
---|
238 | # --checkcu: check that compssUser contains all the packages |
---|
239 | # -g --gendeps: generate the dependencies of a list of packages\n"; |
---|
240 | # exit |
---|
241 | #} |
---|
242 | |
---|
243 | sub score{ |
---|
244 | # my ($config, $fast,$topdir,$deps,$tag) = @_; |
---|
245 | print "Scoring lists\n"; |
---|
246 | |
---|
247 | my ($reps, $sreps, $lists) = getreps($config); |
---|
248 | my ($pkg,$name,$deps,$rdeps) = gendeps("$topdir/tmp/$config->[0]->[3]",$reps,$deps); |
---|
249 | local *C; |
---|
250 | my %pkg; |
---|
251 | my @cds; |
---|
252 | foreach my $i (1..$#$lists){ |
---|
253 | open C,"$topdir/input/$lists->[$i]"; |
---|
254 | while (<C>){ |
---|
255 | chomp; |
---|
256 | s/^\s*(\w+)\s*$/$1/; |
---|
257 | if ($_ && !$must_be_on_cd1{$_}){ |
---|
258 | $pkg{$_}=$i; |
---|
259 | push @{$cds[$i]}, $_ |
---|
260 | } |
---|
261 | } |
---|
262 | close C; |
---|
263 | } |
---|
264 | foreach my $c (@$config){ |
---|
265 | for(my $j = 0; $j < (@{$c}-2); $j+=2){ |
---|
266 | if ($c->[2+$j] =~ /installation/) { |
---|
267 | my $i=0; |
---|
268 | while ($c->[3+$j]->[$i]){ |
---|
269 | my $install; |
---|
270 | if ($c->[3+$j]->[$i] =~ /^[-]+i/){ |
---|
271 | my @score; |
---|
272 | $install = $c->[3+$j]->[++$i]; |
---|
273 | print "Install $install\n"; |
---|
274 | # take the compsslist |
---|
275 | open C,"$topdir/$install/Mandrake/base/compssList"; |
---|
276 | my $line = <C>; |
---|
277 | my @type = split " ",$line; |
---|
278 | push @type, "all"; |
---|
279 | my %cl; |
---|
280 | while (<C>){ |
---|
281 | chomp; |
---|
282 | if ($_){ |
---|
283 | my ($name,@weight) = split; |
---|
284 | $cl{$name}=\@weight; |
---|
285 | my $t; |
---|
286 | foreach my $w (@weight) { $t += $w} |
---|
287 | push @{$cl{$name}}, sprintf "%.2f",$t/@weight; |
---|
288 | if ($pkg{$name}) { |
---|
289 | for(my $k; $k < $#type; $k++){ |
---|
290 | if ( $weight[$k] >= 0 ){ |
---|
291 | $score[$k]->[$pkg{$name}]->[0] += $weight[$k]; |
---|
292 | $score[$k]->[$pkg{$name}]->[1]++; |
---|
293 | $score[$#type]->[$pkg{$name}]->[0] += $weight[$k]; |
---|
294 | } |
---|
295 | } |
---|
296 | } |
---|
297 | } |
---|
298 | } |
---|
299 | # add 10 to packages in the compss |
---|
300 | close C; |
---|
301 | # open C,"$topdir/$install/Mandrake/base/compss"; |
---|
302 | # while (<C>){ |
---|
303 | # chomp; |
---|
304 | # if ($_){ |
---|
305 | # my ($name) = /\t(.*)/; |
---|
306 | # if ($pkg{$name}) { |
---|
307 | # foreach my $k (0..$#type){ |
---|
308 | # if ($name =~ /^k/) { |
---|
309 | # $score[$k]->[$pkg{$name}]->[0] += 1; |
---|
310 | # } else { |
---|
311 | # $score[$k]->[$pkg{$name}]->[0] += 10; |
---|
312 | # } |
---|
313 | # } |
---|
314 | # } |
---|
315 | # } |
---|
316 | # } |
---|
317 | |
---|
318 | foreach my $c (1..@cds){ |
---|
319 | for(my $k; $k < $#type; $k++){ |
---|
320 | $score[$#type]->[$c]->[1] += $score[$k]->[$c]->[1]; |
---|
321 | } |
---|
322 | } |
---|
323 | my @av; |
---|
324 | foreach (0 .. $#score){ |
---|
325 | print "$type[$_]: "; |
---|
326 | my $i; |
---|
327 | while (my $s = $score[$_]->[++$i]->[0]){ |
---|
328 | $av[$_]->[$i] = sprintf "%.2f",$s / $score[$_]->[$i]->[1]; |
---|
329 | printf "\tCD$i $s ($av[$_]->[$i])"; |
---|
330 | } |
---|
331 | print "\n"; |
---|
332 | } |
---|
333 | my @sort; |
---|
334 | foreach (1 .. @cds){ |
---|
335 | foreach my $p (@{$cds[$_]}){ |
---|
336 | if (!$cl{$p}) { print "COMPSSLIST $p not in compsslist\n"; next} |
---|
337 | foreach my $k (0 .. $#score){ |
---|
338 | if ($cl{$p}->[$k] < 0) {next} |
---|
339 | if ($rdeps->[$pkg->{$p}]) {next} |
---|
340 | if ($_ < @cds){ if ( $cl{$p}->[$k] < $av[$k]->[$_+1] ) { |
---|
341 | # push $prop[$_], [$p, $cl{$p}->[$k], 1]; |
---|
342 | push @{$sort[$k]},[$type[$k],$_,$_+1,$cl{$p}->[$k],$p]}} |
---|
343 | # print "SCORE CD$_ CD",$_+1," $cl{$p}->[$k]\t$type[$k]\t$p\n" |
---|
344 | if ($_ > 1) { if ( $cl{$p}->[$k] > $av[$k]->[$_-1] ) { |
---|
345 | push @{$sort[$k]},[$type[$k],$_,$_-1,$cl{$p}->[$k],$p] }} |
---|
346 | # push $prop[$_], [$p, $cl{$p}->[$k], 0]; |
---|
347 | # print "SCORE CD$_ CD",$_-1," $cl{$p}->[$k]\t$type[$k]\t$p\n" |
---|
348 | } |
---|
349 | } |
---|
350 | } |
---|
351 | foreach my $t (@sort){ |
---|
352 | foreach my $r (sort {$b->[3] <=> $a->[3]} @$t){ |
---|
353 | print "SCORE $r->[0] $r->[1] $r->[2] $r->[3] $r->[4]\n" |
---|
354 | } |
---|
355 | } |
---|
356 | } |
---|
357 | $i++ |
---|
358 | } |
---|
359 | } |
---|
360 | } |
---|
361 | } |
---|
362 | return 1 |
---|
363 | } |
---|
364 | |
---|
365 | sub init{ |
---|
366 | # my ($topdir) = @_; |
---|
367 | print "Initialise architecture\n"; |
---|
368 | !($topdir eq "." and ( -d $topdir) or mkdir $topdir or die "cannot create $topdir\n"); |
---|
369 | mkdir "$topdir/build" and mkdir "$topdir/pieces" and mkdir "$topdir/config" and mkdir "$topdir/tmp/" and mkdir "$topdir/input" and mkdir "$topdir/iso" and mkdir "$topdir/bin" and mkdir "$topdir/log" or die "cannot create directories $topdir/*\n"; |
---|
370 | # for (my $i = 1; $i < @$config; $i++){ |
---|
371 | # $_ = $config->[$i]->[1]; |
---|
372 | # if ($_){ mkdir "$topdir/build/$_" or die "cannot create build/$_\n"} |
---|
373 | # } |
---|
374 | return 1 |
---|
375 | } |
---|
376 | |
---|
377 | sub config{ |
---|
378 | my ($file) = @_; |
---|
379 | open F,$file or die "cannot open $file\n"; |
---|
380 | my @config; |
---|
381 | while (<F>){ chomp ; /^#/ or !$_ or last} |
---|
382 | chomp; |
---|
383 | $config[0]->[3] = (split)[0]; |
---|
384 | $config[0]->[5] = $_; |
---|
385 | while (<F>){ chomp; /^#/ or !$_ or last} |
---|
386 | chomp; |
---|
387 | s/#.*//; |
---|
388 | my $i = 0; |
---|
389 | my $j = 0; |
---|
390 | my $k = 1; |
---|
391 | my $l = 0; |
---|
392 | my $fast = 0; |
---|
393 | my @reps; |
---|
394 | my @sreps; |
---|
395 | my @lists; |
---|
396 | my @args = split " "; |
---|
397 | print "ARGS @args\n"; |
---|
398 | my $i=0; |
---|
399 | while ($args[$i]){ |
---|
400 | if ($args[$i] =~ /^[-]+r/){ $i++; push @{$config[0]->[0]}, $args[$i]} |
---|
401 | elsif ($args[$i] =~ /^[-]+s/){ $i++; push @{$config[0]->[1]}, $args[$i]} |
---|
402 | elsif ($args[$i] =~ /^[-]+k/){ $i++; push @{$config[0]->[6]}, $args[$i]} |
---|
403 | elsif ($args[$i] =~ /^-/) { die "unrecognized option $_"} |
---|
404 | else { $args[$i] =~ s/,([,\d]*)// ; my @size = split ",",$1; push @{$config[0]->[2]}, $args[$i]; push @{$config[0]->[4]}, \@size } |
---|
405 | $i++; |
---|
406 | } |
---|
407 | my $cd; |
---|
408 | while (<F>){ |
---|
409 | /^#/ and next; |
---|
410 | chomp; |
---|
411 | $_ or next; |
---|
412 | s/#.*//; |
---|
413 | if (/^(\d+)\s+CD([\d]+)\s+(\S+)\s+(.*)/) { |
---|
414 | push @{$config[$1]},$2,$3,$4; |
---|
415 | $cd = $1; |
---|
416 | print "CD $1 $2 $3 $4\n"; |
---|
417 | }else{ |
---|
418 | my ($prog,@args) = split; |
---|
419 | push @{$config[$cd]} , $prog, \@args; |
---|
420 | } |
---|
421 | } |
---|
422 | return @config; |
---|
423 | } |
---|
424 | |
---|
425 | sub getTracks{ |
---|
426 | my ($tracks) = @_; |
---|
427 | my @tracks = split ',',$tracks; |
---|
428 | my @t; |
---|
429 | foreach (@tracks){ |
---|
430 | /(\d+)/ and push @t, $1; |
---|
431 | /(\d+)-(\d+)/ and push @t, $1..$2 |
---|
432 | } |
---|
433 | my @tracks; |
---|
434 | my %done; |
---|
435 | for(my $i = $#t; $i >= 0; $i-- ){ |
---|
436 | push @tracks, $t[$i] if !$done{$t[$i]}; |
---|
437 | $done{$t[$i]}=1 |
---|
438 | } |
---|
439 | return \@tracks; |
---|
440 | } |
---|
441 | |
---|
442 | sub make{ |
---|
443 | my ($cd2burn) = @_; |
---|
444 | my $cd2burn = getTracks($cd2burn); |
---|
445 | my @mkiso; |
---|
446 | # for(my $i=@$config - 1; $i > 0 ; $i--){ |
---|
447 | foreach my $i (@$cd2burn){ |
---|
448 | if ($config[$i]){ |
---|
449 | my $mkiso; |
---|
450 | print LOG "Making CD $i - $config->[$i]->[0] - $config->[$i]->[1] - $config->[$i]->[2]\n"; |
---|
451 | rmtree "$topdir/build/$config->[0]->[3]/$i"; |
---|
452 | if (! -d "$topdir/build/$config->[0]->[3]/$i") {mkpath "$topdir/build/$config->[0]->[3]/$i", 1} |
---|
453 | for(my $j = 3; $j < $#{$config->[$i]}; $j+=2){ |
---|
454 | my $name = $config->[$i]->[$j]; |
---|
455 | # print "$j $config->[$i]->[$j] -- $config->[$i]->[$j+1]\n"; |
---|
456 | if ($name =~ /^installation$/) { $mkiso = installation($topdir,$i,$tag,$config->[$i]->[1+$j],\@config, $config->[0]->[3], $config->[0]->[5])} |
---|
457 | if ($name =~ /^installation_8$/) { $mkiso = installation_8($topdir,$i,$tag,$config->[$i]->[1+$j],\@config, $config->[0]->[3], $config->[0]->[5])} |
---|
458 | elsif (defined $::{$name}) { &{$::{$name}}($topdir,$i,$config->[$i]->[1+$j], $config->[0]->[3])} |
---|
459 | else {die "unrecognized function name $name\n"} |
---|
460 | } |
---|
461 | if (!$fast){ |
---|
462 | if ($mkiso) { push @mkiso, "mkisofs $mkiso"} |
---|
463 | else { push @mkiso, qq{mkisofs -r -J -nobak -V $config->[$i]->[1] -o "$topdir/iso/$config->[0]->[3]/$i-$config->[0]->[3]"} . ($tag ? "-$tag" : "") . qq{.iso "$topdir/build/$config->[0]->[3]/$i"}} |
---|
464 | } |
---|
465 | } |
---|
466 | } |
---|
467 | if (!$fast){ |
---|
468 | -d "$topdir/iso/$config->[0]->[3]" or mkdir "$topdir/iso/$config->[0]->[3]"; |
---|
469 | foreach (@mkiso){ |
---|
470 | print "$_"; |
---|
471 | system $_ |
---|
472 | } |
---|
473 | } |
---|
474 | return 1 |
---|
475 | } |
---|
476 | |
---|
477 | sub generic{ |
---|
478 | my ($topdir,$name,$args,$prod) = @_; |
---|
479 | my $i=0; |
---|
480 | my @rep; |
---|
481 | my $dir; |
---|
482 | my @list; |
---|
483 | print "@$args\n"; |
---|
484 | while ($args->[$i]){ |
---|
485 | $_ = $args->[$i]; |
---|
486 | print "$_\n"; |
---|
487 | if (/^[-]+d/){ $dir = $args->[++$i]} |
---|
488 | elsif (/^[-]+r/){ push @rep, $args->[++$i]} |
---|
489 | else { push @list, $_} |
---|
490 | $i++ |
---|
491 | } |
---|
492 | print "LISTS @list\n"; |
---|
493 | if (! -d "$topdir/build/$prod/$name/$dir") {mkpath "$topdir/build/$prod/$name/$dir", 1} |
---|
494 | # my @dir = split "/", $dir; |
---|
495 | # my $d; |
---|
496 | # foreach (@:wdir){ |
---|
497 | # $d .= "/$_"; |
---|
498 | # if (! -d "$topdir/build/$name/$d" ) {mkdir "$topdir/build/$name/$d" or die "cannot create $topdir/build/$name/$d\n"; } |
---|
499 | # } |
---|
500 | foreach (@list){ |
---|
501 | open A, "$topdir/config/$_"; |
---|
502 | my $d; |
---|
503 | while (<A>){ |
---|
504 | chomp; |
---|
505 | foreach my $r (@rep){ |
---|
506 | if (-f "$r/$_"){ |
---|
507 | my $err = link "$r/$_", "$topdir/build/$prod/$name/$dir/$_"; |
---|
508 | if (!$err) { print LOG "Linking failed $_: $! "; print "copy $r/$_ $topdir/build/$prod/$name/$dir/$_\n"; copy "$r/$_","$topdir/build/$prod/$name/$dir/$_"} |
---|
509 | $d = 1; |
---|
510 | } |
---|
511 | } |
---|
512 | if (!$d) {print LOG "ERROR Unable to find $_\n"} |
---|
513 | } |
---|
514 | } |
---|
515 | } |
---|
516 | |
---|
517 | sub cdcom{ |
---|
518 | my ($topdir,$name,$args,$prod) = @_; |
---|
519 | my $i=0; |
---|
520 | my @rep; |
---|
521 | my $dir; |
---|
522 | my $src; |
---|
523 | print "@$args\n"; |
---|
524 | while ($args->[$i]){ |
---|
525 | $_ = $args->[$i]; |
---|
526 | print "$_\n"; |
---|
527 | if (/^[-]+d/){ $dir = $args->[++$i]} |
---|
528 | else { $src = $_} |
---|
529 | $i++ |
---|
530 | } |
---|
531 | my $top; |
---|
532 | $src =~ /^\// or $top = $topdir; |
---|
533 | print LOG "cdcom $top/$src $topdir/build/$prod/$name\n"; |
---|
534 | -e "$top/$src" or print LOG "ERROR: $top/$src does not exist\n" and return 0; |
---|
535 | cpal("$top/$src","","$topdir/build/$prod/$name","$top/$src/Mandrake/RPMS"); |
---|
536 | #cpal("$topdir/$src","","$topdir/build/$prod/$name"); |
---|
537 | -d "$topdir/build/$prod/$name/$dir" or mkpath "$topdir/build/$prod/$name/$dir"; |
---|
538 | cpal("$top/$src/Mandrake/RPMS","","$topdir/build/$prod/$name/$dir") |
---|
539 | } |
---|
540 | |
---|
541 | sub cp{ |
---|
542 | my ($topdir,$name,$args,$prod) = @_; |
---|
543 | my $i=0; |
---|
544 | my @rep; |
---|
545 | my $dest = pop @$args; |
---|
546 | my $top; |
---|
547 | if (! -d "$topdir/build/$prod/$name/$dest") {mkpath "$topdir/build/$prod/$name/$dest", 1} |
---|
548 | foreach (@$args){ |
---|
549 | $_ =~ /^\// or $top = $topdir; |
---|
550 | print LOG "cp $top/$_ $topdir/build/$prod/$name/$dest\n"; |
---|
551 | -e "$top/$_" or print LOG "ERROR: $topdir/$_ does not exist\n" and next; |
---|
552 | cpal("$top/$_","","$topdir/build/$prod/$name/$dest"); |
---|
553 | #cpal("$topdir/$_","","$topdir/build/$prod/$name/$dest"); |
---|
554 | } |
---|
555 | } |
---|
556 | |
---|
557 | sub advertising { |
---|
558 | my ($topdir,$name,$args,$prod) = @_; |
---|
559 | my $lang; |
---|
560 | my $dir; |
---|
561 | my @img; |
---|
562 | my $i; |
---|
563 | while ($args->[$i]){ |
---|
564 | $_ = $args->[$i]; |
---|
565 | print "$_\n"; |
---|
566 | if (/^[-]+l/){ $lang = $args->[++$i]} |
---|
567 | elsif (/^[-]+d/){ $dir = $args->[++$i]} |
---|
568 | else { push @img, $_} |
---|
569 | $i++ |
---|
570 | } |
---|
571 | print LOG "Creating advertising images directory\n"; |
---|
572 | my $arep = "$topdir/build/$prod/$name/Mandrake/share/advertising" . ($lang ? ".$lang" : ""); |
---|
573 | -d "$arep" or mkpath "$arep"; |
---|
574 | local *L; open L, ">$arep/list"; |
---|
575 | foreach (@img){ |
---|
576 | cpal("$topdir/$dir/$_","","$arep/"); |
---|
577 | -f "$arep/$_" and print L "$_\n" |
---|
578 | } |
---|
579 | close L; |
---|
580 | 1 |
---|
581 | } |
---|
582 | |
---|
583 | |
---|
584 | sub installation{ |
---|
585 | my ($topdir, $name, $tag, $args, $config, $prod, $versionname) = @_; |
---|
586 | my $i=0; |
---|
587 | my $install; |
---|
588 | my $img; |
---|
589 | my @lists = [0]; |
---|
590 | print "@$args\n"; |
---|
591 | while ($args->[$i]){ |
---|
592 | $_ = $args->[$i]; |
---|
593 | print "$_\n"; |
---|
594 | if (/^[-]+b/){ $img = $args->[++$i]} |
---|
595 | elsif (/^[-]+i/){ $install = $args->[++$i]} |
---|
596 | else { s/,(\d*)// ; push @lists, [$_,$1]} |
---|
597 | $i++ |
---|
598 | } |
---|
599 | print "LISTS @lists\n"; |
---|
600 | rmtree "$topdir/build/images"; |
---|
601 | if (! -d "$topdir/build/images/images" ) {mkpath "$topdir/build/images/images" or die "cannot create $topdir/build/images/images\n" } |
---|
602 | cpal("$topdir/$install/images","","$topdir/build/images/images","MD5SUM"); |
---|
603 | local *D, opendir D, "$topdir/build/images/images"; |
---|
604 | readdir D; readdir D; |
---|
605 | foreach (readdir D){ /\.img$/ and print "md5sum $_ ",`md5sum $topdir/build/images/images/$_ >> $topdir/build/images/images/MD5SUM` ,"\n"} |
---|
606 | cpal("$topdir/$install/","","$topdir/build/$prod/$name","($install/+Mandrake/+RPMS|$install/+images|$install/+Mandrake/+share)"); #($topdir\/$install\/Mandrake\/RPMS|$topdir\/$install\/images\/)"); |
---|
607 | |
---|
608 | my $err = unlink <$topdir/build/$prod/$name/Mandrake/base/hdlist*>; |
---|
609 | my $err = unlink "$topdir/build/$prod/$name/Mandrake/base/compss", |
---|
610 | "$topdir/build/$prod/$name/Mandrake/base/filelist", |
---|
611 | "$topdir/build/$prod/$name/Mandrake/base/provides", |
---|
612 | # "$topdir/build/$prod/$name/Mandrake/base/rpmslist"; |
---|
613 | my $err = unlink <$topdir/build/$prod/$name/Mandrake/base/depslist*>; |
---|
614 | # my $cmddep = "gendepslist2 -o $topdir/build/$name/Mandrake/base/depslist "; |
---|
615 | my $cmddep = qq{genbasefiles "$topdir/build/$prod/$name/Mandrake/base/" }; |
---|
616 | my $cmdfile = "genfilelist "; |
---|
617 | my @hdlists; |
---|
618 | my @check; |
---|
619 | local *A; open A, ">$topdir/build/$prod/$name/Mandrake/base/hdlists"; |
---|
620 | |
---|
621 | for(my $i=1; $i<@lists; $i++){ |
---|
622 | $lists[$i]->[0] =~ /^(\d+)\/(.*)/ or die "could not parse list $lists[$i]->[0]\n"; |
---|
623 | my $cd = $config->[$1]->[0]; |
---|
624 | system(qq{genhdlist_cz2 --noclean -o "$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz" "$topdir/build/$prod/$lists[$i]->[0]"}); |
---|
625 | print A "hdlist$cd.cz $2 CD $cd $config->[$1]->[1]\n"; |
---|
626 | $check[$cd] = qq{$topdir/build/$prod/$1/}; |
---|
627 | $cmddep .= qq{"$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz" }; |
---|
628 | $cmdfile .= qq{"$topdir/build/$prod/$lists[$i]->[0]" }; |
---|
629 | push @hdlists , qq{"$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz"}; |
---|
630 | } |
---|
631 | system($cmddep); |
---|
632 | system(qq{$cmdfile > "$topdir/build/$prod/$name/Mandrake/base/filelist"}); |
---|
633 | # gencompss("$topdir/build/$name/Mandrake/base/compss",@hdlists); |
---|
634 | my $depslist = qq{"$topdir/build/$prod/$name/Mandrake/base/depslist.ordered"}; |
---|
635 | |
---|
636 | for(my $i=1; $i<@lists; $i++){ |
---|
637 | my $command = "genhdlist_cz2 --noclean"; |
---|
638 | $lists[$i]->[0] =~ /^(\d+)\/(.*)/ or die "could not parse list $lists[$i]->[0]\n"; |
---|
639 | my $cd = $config->[$1]->[0]; |
---|
640 | -e $depslist and $command .= " --ordered-depslist $depslist"; |
---|
641 | $command .= qq{ -o "$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz" "$topdir/build/$prod/$lists[$i]->[0]"}; |
---|
642 | system($command); |
---|
643 | } |
---|
644 | |
---|
645 | # generate new compssList |
---|
646 | open C,"$topdir/$install/Mandrake/base/compssList"; |
---|
647 | my $clheader = <C>; |
---|
648 | my %cl; |
---|
649 | while (<C>){ |
---|
650 | chomp; |
---|
651 | $_ and do { |
---|
652 | my ($name,@weight) = split; |
---|
653 | $cl{$name}=\@weight |
---|
654 | } |
---|
655 | } |
---|
656 | my $err = unlink "$topdir/build/$prod/$name/Mandrake/base/compssList"; |
---|
657 | local *A; open A, ">$topdir/build/$prod/$name/Mandrake/base/compssList"; |
---|
658 | print A "$clheader\n\n"; |
---|
659 | for(my $i=1; $i<@lists; $i++){ |
---|
660 | $lists[$i]->[0] =~ /^(\d+)\/(.*)/ or die "could not parse list $lists[$i]->[0]\n"; |
---|
661 | my $cd = $config->[$1]->[0]; |
---|
662 | local *L; opendir L, "$topdir/build/$prod/$lists[$i]->[0]"; |
---|
663 | my @a; |
---|
664 | push @a, (sort readdir L); |
---|
665 | map s/-[^-]*-[^-]*\.[^-]*\.rpm//, @a; |
---|
666 | print A "\n#CD $cd\n"; |
---|
667 | foreach (@a){ $cl{$_} and do { defined $lists[$i]->[1] and map $_ = $lists[$i]->[1],@{$cl{$_}}; |
---|
668 | printf A "%-50s\t@{$cl{$_}}\n",$_ }} |
---|
669 | } |
---|
670 | close A; |
---|
671 | |
---|
672 | #" |
---|
673 | unlink "$topdir/build/$prod/$name/VERSION"; |
---|
674 | open A, ">$topdir/build/$prod/$name/VERSION"; |
---|
675 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
---|
676 | $year += 1900; |
---|
677 | printf A "Linux-Mandrake $versionname $tag %04d%02d%02d $hour:%02d\n", $year, $mon+1, $mday, $min; |
---|
678 | # open A, ">$topdir/build/$prod/$name/Mandrake/base/rpmslist"; |
---|
679 | # local *D, opendir D, "$topdir/build/$prod/$name/Mandrake/RPMS"; |
---|
680 | # readdir D; readdir D; |
---|
681 | # print A sort map $_="$_\n", readdir D; |
---|
682 | checkcds(\@check,$config->[$name]->[0]) or die "depslist.ordered, hdlists and RPMS mismatch\n"; |
---|
683 | return qq{-r -J -nobak -V $config->[$name]->[1] -b images/} . ($img ? "$img" : "all.img") . qq{ -c images/boot.cat -o "$topdir/iso/$prod/$name-$prod"} . ($tag ? "-$tag" : "") . qq{.iso "$topdir/build/images/" "$topdir/build/$prod/$name"} |
---|
684 | } |
---|
685 | |
---|
686 | sub installation_8{ |
---|
687 | my ($topdir, $name, $tag, $args, $config, $prod, $versionname) = @_; |
---|
688 | my $i=0; |
---|
689 | my $install; |
---|
690 | my $img; |
---|
691 | my @lists = [0]; |
---|
692 | print "@$args\n"; |
---|
693 | while ($args->[$i]){ |
---|
694 | $_ = $args->[$i]; |
---|
695 | print "$_\n"; |
---|
696 | if (/^[-]+b/){ $img = $args->[++$i]} |
---|
697 | elsif (/^[-]+i/){ $install = $args->[++$i]} |
---|
698 | else { s/,(\d*)// ; push @lists, [$_,$1]} |
---|
699 | $i++ |
---|
700 | } |
---|
701 | print "LISTS @lists\n"; |
---|
702 | # cpal("$topdir/$install/images","","$images/images","MD5SUM"); |
---|
703 | cpal("$topdir/$install/","","$topdir/build/$prod/$name","(hdlist|provides|filelist|depslist|base/+.*cooker.*|$install/+Mandrake/+RPMS|$install/+Mandrake/+share)"); |
---|
704 | |
---|
705 | my $images = "$topdir/build/$prod/$name/images"; |
---|
706 | local *D, opendir D, "$images/images"; |
---|
707 | readdir D; readdir D; |
---|
708 | foreach (readdir D){ /\.img/ and print "md5sum $_ ",`md5sum $images/images/$_ >> $images/images/MD5SUM` ,"\n"} |
---|
709 | local *D, opendir D, "$images/images/alternatives"; |
---|
710 | readdir D; readdir D; |
---|
711 | foreach (readdir D){ /\.img/ and print "md5sum $_ ",`md5sum $images/images/alternatives/$_ >> $images/images/alternatives/MD5SUM` ,"\n"} |
---|
712 | |
---|
713 | my $image = "$topdir/build/$prod/images"; |
---|
714 | rmtree $image; |
---|
715 | if (! -d "$image/Boot" ) {mkpath "$image/Boot" or die "cannot create $image/Boot\n" } |
---|
716 | my $bootimg = $img ? "$img" : "cdrom.img"; |
---|
717 | my $err = link "$images/$img","$image/Boot/$bootimg"; |
---|
718 | if (!$err) { print "Linking failed $images/$img: $!\n"} else { unlink "$images/$bootimg" ; symlink "../Boot/$bootimg", "$images/$bootimg"} |
---|
719 | |
---|
720 | my $err = unlink "$topdir/build/$prod/$name/Mandrake/base/compss", |
---|
721 | my $cmddep = qq{gendistrib --noclean --distrib "$topdir/build/$prod/$name" }; |
---|
722 | my @hdlists; |
---|
723 | my @check; |
---|
724 | local *A; open A, ">$topdir/build/$prod/$name/Mandrake/base/hdlists"; |
---|
725 | |
---|
726 | for(my $i=1; $i<@lists; $i++){ |
---|
727 | $lists[$i]->[0] =~ /^(\d+)\/(.*)/ or die "could not parse list $lists[$i]->[0]\n"; |
---|
728 | my $cd = $config->[$1]->[0]; |
---|
729 | #system(qq{genhdlist_cz2 --noclean -o "$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz" "$topdir/build/$prod/$lists[$i]->[0]"}); |
---|
730 | print A "hdlist$cd.cz $2 CD $cd $config->[$1]->[2]\n"; |
---|
731 | $check[$cd] = qq{$topdir/build/$prod/$1/}; |
---|
732 | #$cmddep .= qq{"$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz" }; |
---|
733 | $cmddep .= qq{ "$topdir/build/$prod/$1" }; |
---|
734 | push @hdlists , qq{"$topdir/build/$prod/$name/Mandrake/base/hdlist$cd.cz"}; |
---|
735 | } |
---|
736 | print "CMDDEP $cmddep\n"; |
---|
737 | system($cmddep); |
---|
738 | system($cmddep); |
---|
739 | |
---|
740 | unlink "$topdir/build/$prod/$name/VERSION"; |
---|
741 | open A, ">$topdir/build/$prod/$name/VERSION"; |
---|
742 | my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); |
---|
743 | $year += 1900; |
---|
744 | printf A "Linux-Mandrake $versionname $tag %04d%02d%02d $hour:%02d\n", $year, $mon+1, $mday, $min; |
---|
745 | # open A, ">$topdir/build/$prod/$name/Mandrake/base/rpmslist"; |
---|
746 | # local *D, opendir D, "$topdir/build/$prod/$name/Mandrake/RPMS"; |
---|
747 | # readdir D; readdir D; |
---|
748 | # print A sort map $_="$_\n", readdir D; |
---|
749 | checkcds(\@check,$config->[$name]->[0]) or die "depslist.ordered, hdlists and RPMS mismatch\n"; |
---|
750 | # |
---|
751 | # sort file does not seem to work |
---|
752 | # open A, ">$topdir/tmp/sort_file"; |
---|
753 | # print A "$topdir/build/$prod/images/", ($img ? "$img" : "cdrom.img") . " 1"; |
---|
754 | # close A; |
---|
755 | return qq{-r -J -nobak -V $config->[$name]->[1] -b Boot/$bootimg -c Boot/boot.cat -o "$topdir/iso/$prod/$name-$prod"} . ($tag ? "-$tag" : "") . qq{.iso "$topdir/build/$prod/images/" "$topdir/build/$prod/$name"} |
---|
756 | } |
---|
757 | |
---|
758 | sub cpal{ |
---|
759 | my ($source,$path,$dest,$exclude) = @_; |
---|
760 | if (-d $source){ |
---|
761 | opendir O, $source; |
---|
762 | readdir O; |
---|
763 | readdir O; |
---|
764 | foreach (readdir O){ |
---|
765 | if (! ($exclude && "$source/$_" =~ /$exclude/)){ |
---|
766 | if (-l "$source/$_") { |
---|
767 | my $err = link "$source/$_","$dest/$path/$_"; |
---|
768 | if (!$err) {print "Linking failed $_: $!\n"; print "copy $source/$_ $dest/$path/$_"; copy "$source/$_","$dest/$path/$_"} |
---|
769 | }elsif (-d "$source/$_") { |
---|
770 | mkdir "$dest/$path/$_"; |
---|
771 | cpal("$source/$_","$path/$_",$dest,$exclude) |
---|
772 | }else { |
---|
773 | my $err = link "$source/$_","$dest/$path/$_"; |
---|
774 | if (!$err) { print "Linking failed $_: $!\n"; print "copy $source/$_ $dest/$path/$_"; copy "$source/$_","$dest/$path/$_"} |
---|
775 | } |
---|
776 | } |
---|
777 | } |
---|
778 | }else { |
---|
779 | $source =~ /.*\/(.*)/; |
---|
780 | my $err = link "$source","$dest/$path/$1"; |
---|
781 | if (!$err) { print "Linking failed $source: $!\n"; print "copy $source $dest/$path/$_";copy "$source","$dest/$path/$_"} |
---|
782 | } |
---|
783 | } |
---|
784 | |
---|
785 | sub gencompss{ |
---|
786 | my ($file, @hdlists) = @_; |
---|
787 | open F, "bzip2 -dc @hdlists 2>/dev/null | hdlist2groups - |"; |
---|
788 | my %l; |
---|
789 | foreach (<F>) { |
---|
790 | chop; |
---|
791 | /(.*):(.*)/; |
---|
792 | push @{$l{$2}}, $1; |
---|
793 | } |
---|
794 | close F or die; |
---|
795 | open A, ">$file"; |
---|
796 | foreach (sort keys %l) { |
---|
797 | print A "$_\n"; |
---|
798 | print A "\t$_\n" foreach sort @{$l{$_}}; |
---|
799 | print A "\n"; |
---|
800 | } |
---|
801 | } |
---|
802 | |
---|
803 | sub gendepslist72{ |
---|
804 | my ($reps, $topdir) = @_; |
---|
805 | genHdlist($reps,"$topdir/hdlist.cz"); |
---|
806 | system("genbasefiles $topdir/ $topdir/hdlist.cz") |
---|
807 | } |
---|
808 | |
---|
809 | sub gendepslist80{ |
---|
810 | my ($reps, $top) = @_; |
---|
811 | use rpmtools; |
---|
812 | my $params = new rpmtools(); |
---|
813 | my $pwd = `pwd`; chop $pwd; |
---|
814 | my @map = @$reps; |
---|
815 | $params->build_hdlist(1, 9,"$tmp/.mkcd_build_hdlist", "$top/hdlist.cz", map (glob, map( { $_ and ($_ =~ /^\// and $_ .= "/*.rpm" ) or $_ = "$pwd/$_/*.rpm"} @map))); |
---|
816 | print LOG "generating base files\n"; |
---|
817 | if (-r "$top/provides") { |
---|
818 | open F, "$top/provides"; |
---|
819 | $params->read_provides_files(\*F); |
---|
820 | close F; |
---|
821 | } |
---|
822 | |
---|
823 | $params->read_hdlists("$top/hdlist.cz"); |
---|
824 | $params->compute_depslist(); |
---|
825 | |
---|
826 | my @unresolved = $params->get_unresolved_provides_files(); |
---|
827 | if (@unresolved > 0) { |
---|
828 | $params->clean(); |
---|
829 | |
---|
830 | $params->read_hdlists("$top/hdlist.cz"); |
---|
831 | $params->keep_only_cleaned_provides_files(); |
---|
832 | $params->read_hdlists("$top/hdlist.cz"); |
---|
833 | $params->compute_depslist(); |
---|
834 | } |
---|
835 | print LOG "writing $top/depslits.ordered\n"; |
---|
836 | open F, ">$top/depslist.ordered" or die "unable to write depslist file $top/depslist.ordered\n"; |
---|
837 | $params->write_depslist(\*F); |
---|
838 | close F; |
---|
839 | print LOG "writing $top/provides\n"; |
---|
840 | open F, ">$top/provides" or die "unable to write provides file $top/provides\n"; |
---|
841 | $params->write_provides(\*F); |
---|
842 | close F; |
---|
843 | } |
---|
844 | |
---|
845 | sub gendeps{ |
---|
846 | my ($topdir,$reps,$deps) = @_; |
---|
847 | my %log; |
---|
848 | -d $topdir or mkpath $topdir or die "Could not create $topdir\n"; |
---|
849 | if ($deps || ! -f "$topdir/depslist.ordered") { |
---|
850 | print LOG "generating depslist $distrib\n"; |
---|
851 | if (defined $::{"gendepslist$distrib"}) { |
---|
852 | &{$::{"gendepslist$distrib"}}($reps, $topdir); |
---|
853 | }else{ |
---|
854 | die "ERROR: gendepslist$distrib does not exist\n" |
---|
855 | } |
---|
856 | } |
---|
857 | open DEP, "$topdir/depslist.ordered" or die "Could not open $topdir/depslist.ordered\n"; |
---|
858 | print LOG "getting dependencies\n"; |
---|
859 | my @deps; |
---|
860 | my @rdeps; |
---|
861 | my %pkg; |
---|
862 | my $i = 0; |
---|
863 | my @name; |
---|
864 | foreach (<DEP>){ |
---|
865 | chomp; |
---|
866 | my ($name, $size, @de) = split " ", $_; |
---|
867 | ($name, my $version, my $release) = $name =~ /(.*)-([^-]*)-([^-]*)/; |
---|
868 | if ($name){ |
---|
869 | foreach my $d (@de) { |
---|
870 | if ($d =~ s/^NOTFOUND_//) { |
---|
871 | push @{$log{"$name"}}, $d; |
---|
872 | }else{ |
---|
873 | if ($d =~ /\|/){ |
---|
874 | my @t = split '\|',$d ; my @u; |
---|
875 | foreach my $t (@t) { if ($t =~ s/NOTFOUND_//) {push @{$log{"$name"}}, $d} else { push @u, $t; push @{$rdeps[$t]}, $i} } |
---|
876 | push @{$deps[$i]}, \@u |
---|
877 | }else { push @{$deps[$i]}, $d; push @{$rdeps[$d]}, $i} |
---|
878 | } |
---|
879 | } |
---|
880 | $name[$i] = $name; |
---|
881 | $pkg{$name} = $i; |
---|
882 | $i++; |
---|
883 | } |
---|
884 | } |
---|
885 | print LOG "FAILING DEPS\n"; |
---|
886 | foreach my $k (keys %log){ |
---|
887 | print LOG "$k @{$log{$k}}\n"; |
---|
888 | } |
---|
889 | return (\%pkg,\@name,\@deps,\@rdeps) |
---|
890 | } |
---|
891 | |
---|
892 | sub genHdlist { |
---|
893 | my ($reps, $hdlist) = @_; |
---|
894 | my $tmpdir = $ENV{TMPDIR} || "/tmp"; |
---|
895 | my $work_dir = "$tmpdir/.build_hdlist"; |
---|
896 | |
---|
897 | -e $work_dir && !-d $work_dir and unlink($work_dir) || die "cannot use $work_dir as a working directory"; |
---|
898 | chmod 0755, $work_dir or system("rm -rf $work_dir"); |
---|
899 | -d $work_dir or mkdir $work_dir, 0755 or die "cannot create working directory $work_dir\n"; |
---|
900 | chdir $work_dir; |
---|
901 | |
---|
902 | my (%keys); |
---|
903 | |
---|
904 | print LOG "Generating hdlist.cz"; |
---|
905 | foreach my $dir (@$reps){ |
---|
906 | print LOG " $dir"; |
---|
907 | $dir = "$topdir/$dir"; |
---|
908 | opendir DIR, $dir or die "unable to opendir $dir: $!\n"; |
---|
909 | while ($_ = readdir DIR) { |
---|
910 | my ($key, $arch) = /(.*)\.(.*)\.rpm$/ or next; |
---|
911 | system("rpm2header $dir/$_ > $_") unless -e $_; |
---|
912 | $? == 0 or unlink($_), die "bad rpm $dir/$_\n"; |
---|
913 | -s $_ or unlink($_), die "bad rpm $dir/$_\n"; |
---|
914 | if ($keys{$key}) { |
---|
915 | my ($name, $tail) = $key =~ /(.*)(-[^-]*-[^-]*)/; |
---|
916 | $keys{"$name($keys{$key})$tail"} = $keys{$key}; unlink "$name($keys{$key})$tail"; link "$key.$keys{$key}.rpm", "$name($keys{$key})$tail"; |
---|
917 | $keys{"$name($arch)$tail"} = $arch; unlink "$name($arch)$tail"; link $_, "$name($arch)$tail"; |
---|
918 | delete $keys{$key}; |
---|
919 | } else { |
---|
920 | $keys{$key} = $arch; unlink $key; link $_, $key; |
---|
921 | } |
---|
922 | } |
---|
923 | } |
---|
924 | print "\n"; |
---|
925 | open B, "| packdrake -b9s $hdlist 400000"; |
---|
926 | foreach (keys %keys) { print B "$_\n" } |
---|
927 | close B or die "packdrake failed\n"; |
---|
928 | chdir $topdir; |
---|
929 | } |
---|
930 | |
---|
931 | sub getreps{ |
---|
932 | my ($config) = @_; |
---|
933 | my @reps; |
---|
934 | my @sreps; |
---|
935 | my @lists; |
---|
936 | my @sizes; |
---|
937 | my @kill; |
---|
938 | my $i = 0; |
---|
939 | foreach my $d (@{$config->[0]->[0]}){ |
---|
940 | $reps[$i++] = $d; |
---|
941 | print "REP $d\n"; |
---|
942 | } |
---|
943 | $i = 0; |
---|
944 | foreach my $d (@{$config->[0]->[1]}){ |
---|
945 | $sreps[$i++] = $d; |
---|
946 | print "SREP $d\n"; |
---|
947 | } |
---|
948 | $i = 1; |
---|
949 | foreach my $d (@{$config->[0]->[2]}){ |
---|
950 | $lists[$i++] = "$d"; |
---|
951 | print "LIST $d\n"; |
---|
952 | } |
---|
953 | $i = 1; |
---|
954 | foreach my $d (@{$config->[0]->[4]}){ |
---|
955 | $sizes[$i++] = $d; |
---|
956 | print "SIZE @$d\n"; |
---|
957 | } |
---|
958 | $i = 0; |
---|
959 | foreach my $d (@{$config->[0]->[6]}){ |
---|
960 | $kill[$i++] = $d; |
---|
961 | print "KILLFILE $d\n"; |
---|
962 | } |
---|
963 | return (\@reps,\@sreps,\@lists,\@sizes,\@kill) |
---|
964 | } |
---|
965 | |
---|
966 | sub check(){ |
---|
967 | # my ($config,$fast,$topdir,$deps) = @_; |
---|
968 | |
---|
969 | my ($reps, $sreps, $lists, $sizes, $kill) = getreps($config); |
---|
970 | print "Packages\n"; |
---|
971 | my %rep; |
---|
972 | foreach (@$reps){ |
---|
973 | print "getting $_ rpms\n"; |
---|
974 | %rep = %{$fast ? getrpms2($_, \%rep) : getrpms($_,\%rep)}; |
---|
975 | } |
---|
976 | |
---|
977 | # foreach (keys %rep){ |
---|
978 | # print "KEYS $_\n"; |
---|
979 | # } |
---|
980 | |
---|
981 | my %srep; |
---|
982 | if (!$fast){ |
---|
983 | foreach (@$sreps){ |
---|
984 | print "getting $_ srpms\n"; |
---|
985 | %srep = %{getsrpms($_,\%srep)}; |
---|
986 | } |
---|
987 | } |
---|
988 | |
---|
989 | # foreach (keys %srep){ |
---|
990 | # print "SKEYS $_\n"; |
---|
991 | # } |
---|
992 | |
---|
993 | # check that rpms in the list of cd1 are in the repository |
---|
994 | |
---|
995 | my %log; |
---|
996 | |
---|
997 | print "Dependencies and size\n"; |
---|
998 | my ($pkg,$name,$deps) = gendeps("$topdir/tmp/$config->[0]->[3]",$reps,$deps); |
---|
999 | print "size\n"; |
---|
1000 | |
---|
1001 | my @listrpms; |
---|
1002 | for(my $i = 1; $i < @$lists; $i++){ |
---|
1003 | local *L; open L, "$topdir/input/$lists->[$i]"; |
---|
1004 | push @{$listrpms[$i]}, (<L>); |
---|
1005 | map chomp, @{$listrpms[$i]}; |
---|
1006 | } |
---|
1007 | my %killlist; |
---|
1008 | for(my $i = 0; $i < @$kill; $i++){ |
---|
1009 | local *L; open L, "$topdir/input/$kill->[$i]"; |
---|
1010 | while (<L>){ chomp; $killlist{$_} = 1} |
---|
1011 | } |
---|
1012 | |
---|
1013 | if ($auto){ |
---|
1014 | @listrpms = @{deps($pkg,$name,$deps,\@listrpms)}; |
---|
1015 | } |
---|
1016 | |
---|
1017 | my $rpmdone; |
---|
1018 | my $srpmdone; |
---|
1019 | my $i=1; |
---|
1020 | my (@cdlist, @cdhash, @s, @ss, @cdshash); |
---|
1021 | my ($rpmdone, $srpmdone); |
---|
1022 | for(my $i = 1; $i < @listrpms; $i++){ |
---|
1023 | ($cdlist[$i],$cdhash[$i],$s[$i], $ss[$i], $cdshash[$i], $rpmdone, $srpmdone) = $fast ? checkcd2($pkg,$i,$listrpms[$i],\%rep, $reps, $rpmdone) : checkcd($pkg,$i,$listrpms[$i],\%rep, \%srep, $reps, $sreps, $rpmdone, $srpmdone, $sizes->[$i],\%killlist); |
---|
1024 | print "CD$i rpms size: $s[$i]\n"; |
---|
1025 | if (! $fast) {print "CD$i srpms size: $ss[$i]\n"} |
---|
1026 | } |
---|
1027 | |
---|
1028 | print LOG "PACKAGES NOT IN LIST\n"; |
---|
1029 | if ($fast) { foreach (keys %rep){ if ($rep{$_} and ! ($rpmdone->[$pkg->{$_}])) { print LOG "$_\n" }}} |
---|
1030 | else {foreach (keys %rep){if ($rep{$_}->[0] and ! ($rpmdone->[$pkg->{$_}])) { print LOG "$_\n" }}} |
---|
1031 | |
---|
1032 | # check dependencies |
---|
1033 | |
---|
1034 | print LOG "DEPS\n"; |
---|
1035 | for(my $i = 0; $i < @$rpmdone; $i++){ |
---|
1036 | if ($rpmdone->[$i]){ |
---|
1037 | foreach (@{$deps->[$i]}){ |
---|
1038 | if (ref){ |
---|
1039 | my $ch = @$_; |
---|
1040 | my $chc = $ch; |
---|
1041 | my @pre; |
---|
1042 | foreach my $d (@$_){ |
---|
1043 | if ($rpmdone->[$d]){ |
---|
1044 | if ($rpmdone->[$i] < $rpmdone->[$d]){ $chc--; push @pre, $d } |
---|
1045 | }else {$ch--} |
---|
1046 | if (!$chc){ print LOG "$name->[$i] (CD $rpmdone->[$i]) requires one of \n"; |
---|
1047 | foreach (@pre){ print LOG "$name->[$_] (CD $rpmdone->[$d])\n" } |
---|
1048 | } |
---|
1049 | } |
---|
1050 | if (! $ch) { |
---|
1051 | print LOG "$name->[$i] (CD $rpmdone->[$i]) requires one of "; |
---|
1052 | foreach my $d (@$_){ print LOG "$name->[$d] "} |
---|
1053 | print LOG "\n" |
---|
1054 | } |
---|
1055 | }elsif (! $rpmdone->[$_]) {print LOG "$name->[$i] (CD $rpmdone->[$i]) requires $name->[$_] (not in lists)\n"} |
---|
1056 | elsif ($rpmdone->[$i] < $rpmdone->[$_]) {print LOG "$name->[$i] (CD $rpmdone->[$i]) requires $name->[$_] (CD $rpmdone->[$_])\n"} |
---|
1057 | } |
---|
1058 | } |
---|
1059 | } |
---|
1060 | |
---|
1061 | print "Files\n"; |
---|
1062 | -f "$topdir/config" or mkdir "$topdir/config"; |
---|
1063 | for(my $i = 1; $i < @$lists; $i++){ |
---|
1064 | my $name = "$topdir/config/$lists->[$i]"; |
---|
1065 | print_sorted("$topdir/input/$lists->[$i]"); |
---|
1066 | if ($fast){ printfile2($cdhash[$i],\%rep, "$name","$name" . ".rpm")} |
---|
1067 | else { printfile($cdhash[$i],\%rep, "$name","$name" . ".rpm"); |
---|
1068 | printfile($cdshash[$i],\%srep, "$name" . "s", "$name" . ".srpm")} |
---|
1069 | } |
---|
1070 | return 1 |
---|
1071 | } |
---|
1072 | |
---|
1073 | sub deps{ |
---|
1074 | my ($pkg,$name,$deps,$listrpms,$alt) = @_; |
---|
1075 | my @listlin; |
---|
1076 | my %listalt; |
---|
1077 | for(my $i=1; $i < @$listrpms; $i++){ |
---|
1078 | foreach my $p (@{$listrpms->[$i]}){ |
---|
1079 | $listlin[$pkg->{$p}] = $i; |
---|
1080 | } |
---|
1081 | } |
---|
1082 | $listlin[$pkg->{"basesystem"}] = 1; |
---|
1083 | my $n=1; |
---|
1084 | my $lo=0; |
---|
1085 | while ($n){ |
---|
1086 | $lo++; |
---|
1087 | $n=0; |
---|
1088 | for(my $i = 0; $i < @listlin; $i++){ |
---|
1089 | if ($listlin[$i]){ |
---|
1090 | foreach (@{$deps->[$i]}){ |
---|
1091 | if (!ref) { if ((! $listlin[$_]) or ($listlin[$i] < $listlin[$_])) { $listlin[$_] = $listlin[$i] ; $n = 1} } |
---|
1092 | elsif ($alt){ |
---|
1093 | my $ok; |
---|
1094 | foreach (@{$_}){ |
---|
1095 | if ($listlin[$_] and ($listlin[$i] > $listlin[$_])) { $ok=1; last} |
---|
1096 | } |
---|
1097 | !$ok and do { |
---|
1098 | my $l = [map $name->[$_],@{$_}]; |
---|
1099 | if (!$listalt{"@$l"} or $listalt{"@$l"}->[0] > $listlin[$i]){ |
---|
1100 | $listalt{"@$l"} = [$listlin[$i],$l] |
---|
1101 | } |
---|
1102 | } |
---|
1103 | } |
---|
1104 | } |
---|
1105 | } |
---|
1106 | } |
---|
1107 | } |
---|
1108 | for(my $i = 0; $i < @listlin; $i++){ |
---|
1109 | $listlin[$i] and push @{$listrpms->[$listlin[$i]]}, $name->[$i] |
---|
1110 | } |
---|
1111 | if ($alt) { |
---|
1112 | foreach (keys %listalt){ |
---|
1113 | push @{$listrpms->[$listalt{$_}->[0]]}, $listalt{$_}->[1]; |
---|
1114 | } |
---|
1115 | } |
---|
1116 | return $listrpms; |
---|
1117 | } |
---|
1118 | |
---|
1119 | sub getdeps{ |
---|
1120 | my ($topdir,$listrpms) = @_; |
---|
1121 | my ($pkg,$name,$deps) = gendeps($topdir); |
---|
1122 | foreach (@$listrpms) { $pkg->{$_} or print "WARNING: $_ not found in depslist.ordered\n"} |
---|
1123 | $listrpms = deps($pkg,$name,$deps,[0,$listrpms],1); |
---|
1124 | foreach (@{$listrpms->[1]}) { ref $_ and print "@$_\n" or print "$_\n"} |
---|
1125 | return 1; |
---|
1126 | } |
---|
1127 | |
---|
1128 | sub print_sorted(){ |
---|
1129 | my ($cd) = @_; |
---|
1130 | my @t; |
---|
1131 | local *A; |
---|
1132 | open A, "$cd"; |
---|
1133 | foreach (<A>) { chomp; s/^\s*(\S+)\s*.*/$1/; push @t, $_ } |
---|
1134 | open A, ">$cd"; |
---|
1135 | my %uniq; |
---|
1136 | foreach (sort @t) { $uniq{$_} or print A "$_\n"; $uniq{$_} = 1} |
---|
1137 | } |
---|
1138 | |
---|
1139 | sub printfile { |
---|
1140 | my ($cdhash, $rep, $namefile, $rpmfile) = @_; |
---|
1141 | local *A; open A, ">$namefile"or die "Could not open $namefile for writing\n"; |
---|
1142 | local *B; open B, ">$rpmfile" or die "Could not open $rpmfile for writing\n"; |
---|
1143 | my @file; |
---|
1144 | foreach (sort keys %{$cdhash}) { |
---|
1145 | push @{$file[$cdhash->{$_}]}, $_; |
---|
1146 | if ($_) { print A "$_\n"; |
---|
1147 | print B "$rep->{$_}->[0]\n"} |
---|
1148 | } |
---|
1149 | @file > 2 or return; |
---|
1150 | for (my $i = 1; $i < @file; $i++) { |
---|
1151 | open A, ">$namefile.$i"; |
---|
1152 | open B, ">$rpmfile.$i"; |
---|
1153 | foreach (sort @{$file[$i]}){ |
---|
1154 | if ($_) { print A "$_\n"; |
---|
1155 | print B "$rep->{$_}->[0]\n"} |
---|
1156 | } |
---|
1157 | } |
---|
1158 | } |
---|
1159 | sub printfile2 { |
---|
1160 | my ($cdhash, $rep, $namefile, $rpmfile) = @_; |
---|
1161 | local *A; open A, ">$namefile" or die "Could not open $namefile for writing\n"; |
---|
1162 | local *B; open B, ">$rpmfile" or die "Could not open $rpmfile for writing\n"; |
---|
1163 | foreach (sort keys %{$cdhash}){ |
---|
1164 | if ($_) { print A "$_\n"; |
---|
1165 | print B "$rep->{$_}\n"} |
---|
1166 | } |
---|
1167 | } |
---|
1168 | |
---|
1169 | sub getrpms { |
---|
1170 | my ($loc, $rep) = @_; |
---|
1171 | opendir MAIN, $loc; |
---|
1172 | readdir MAIN; |
---|
1173 | readdir MAIN; |
---|
1174 | print LOG "DUPLICATE RPM $loc\n"; |
---|
1175 | foreach (readdir MAIN){ |
---|
1176 | if (/^[^\.].*rpm$/) { |
---|
1177 | my $file = $_; |
---|
1178 | my ($srpm_name, $srpm_version, $srpm_release) = `rpm -qip $loc/$_` =~ /.*Source RPM\s*: (.*)-([^-]*)-([^-]*)\.src.rpm\n/; |
---|
1179 | my($name, $version, $release) = /(.*)-([^-]*)-([^-]*)\.[^-]*\.rpm/; |
---|
1180 | if (!$rep->{$name}) {$rep->{$name} = [$file, $version, $release, $srpm_name, $srpm_version, $srpm_release ] } |
---|
1181 | else{print LOG "$name\n"} |
---|
1182 | } |
---|
1183 | } |
---|
1184 | closedir MAIN; |
---|
1185 | return $rep; |
---|
1186 | } |
---|
1187 | |
---|
1188 | sub getrpms2 { |
---|
1189 | my ($loc,$rep) = @_; |
---|
1190 | opendir MAIN, $loc; |
---|
1191 | readdir MAIN; |
---|
1192 | readdir MAIN; |
---|
1193 | print LOG "DUPLICATE RPM $loc\n"; |
---|
1194 | foreach (readdir MAIN){ if (/^[^\.].*rpm$/) { /(.*)-[^-]*-[^-]*\.[^-]*\.rpm/; if (! $rep->{$1}) {$rep->{$1} = $_}else {print LOG "$_\n"}}} |
---|
1195 | closedir MAIN; |
---|
1196 | return $rep; |
---|
1197 | } |
---|
1198 | |
---|
1199 | sub getsrpms { |
---|
1200 | my ($loc, $rep) = @_; |
---|
1201 | opendir MAIN, $loc; |
---|
1202 | readdir MAIN; |
---|
1203 | readdir MAIN; |
---|
1204 | print LOG "DUPLICATE SRPM $loc\n"; |
---|
1205 | foreach (readdir MAIN){ |
---|
1206 | if (/^[^\.].*.src.rpm$/) { |
---|
1207 | my $file = $_; |
---|
1208 | my ($name, $version, $release) = /(.*)-([^-]*)-([^-]*)\.src.rpm/; |
---|
1209 | if (! $rep->{$name}) { $rep->{$name} = [$file, $version, $release,]} |
---|
1210 | else {print LOG "$name\n"} |
---|
1211 | } |
---|
1212 | } |
---|
1213 | closedir MAIN; |
---|
1214 | return $rep; |
---|
1215 | } |
---|
1216 | |
---|
1217 | sub checkcd { |
---|
1218 | my ($pkg,$num,$cd, $rep, $srpmrep, $loc, $sloc, $rpmdone, $srpmdone,$size, $killlist) = @_; |
---|
1219 | my $s; |
---|
1220 | my $ss; |
---|
1221 | my @cd; |
---|
1222 | my %cd; |
---|
1223 | my %cds; |
---|
1224 | my %log; |
---|
1225 | my $i=1; |
---|
1226 | my $t; |
---|
1227 | my @sst; |
---|
1228 | print LOG "NOT IN REPOSITORIES CD $num\n"; |
---|
1229 | foreach (@$cd){ |
---|
1230 | s/^\s*(\w+)\s*$/$1/; |
---|
1231 | if ($_){ |
---|
1232 | if (!$rep->{$_}->[0]) { print LOG "$_\n"; next} |
---|
1233 | my $n = $pkg->{$_}; |
---|
1234 | if (!$srpmrep->{$rep->{$_}->[3]}) { push @{$log{'RS'}}, [$_,$rep->{$_}->[3]]} |
---|
1235 | elsif (!( "$srpmrep->{$rep->{$_}->[3]}->[1]-$srpmrep->{$rep->{$_}->[3]}->[2]" eq "$rep->{$_}->[4]-$rep->{$_}->[5]") ){ push @{$log{'V'}}, ["$_-$rep->{$_}->[1]-$rep->{$_}->[2]", "$rep->{$_}->[3]-$rep->{$_}->[4]-$rep->{$_}->[5]", "$rep->{$_}->[3]-$srpmrep->{$rep->{$_}->[3]}->[1]-$srpmrep->{$rep->{$_}->[3]}->[2]"] } |
---|
1236 | if (!$rpmdone->[$n]){ |
---|
1237 | foreach $loc (@{$loc}){ |
---|
1238 | $s += ((stat("$loc/$rep->{$_}->[0]"))[7] or next); |
---|
1239 | last; |
---|
1240 | } |
---|
1241 | push @cd, $_; |
---|
1242 | $cd{$_} = 1; |
---|
1243 | if (!$srpmdone->{"$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"}){ |
---|
1244 | if (!$killlist->{$rep->{$_}->[3]}){ |
---|
1245 | my $j; |
---|
1246 | foreach $sloc (@{$sloc}){ |
---|
1247 | $t = ((stat("$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"))[7] or next); |
---|
1248 | $ss += $t; |
---|
1249 | $size or last; |
---|
1250 | for(; $j < $i; $j++){ |
---|
1251 | $size->[$j] or last; |
---|
1252 | ($sst[$j] + $t > $size->[$j]) and next; |
---|
1253 | $sst[$j] += $t and last; |
---|
1254 | } |
---|
1255 | $j < $i or do {$sst[$i]+=$t; $i++}; |
---|
1256 | last; |
---|
1257 | } |
---|
1258 | $cds{$rep->{$_}->[3]} = $j + 1 |
---|
1259 | } |
---|
1260 | } |
---|
1261 | $srpmdone->{"$sloc/$srpmrep->{$rep->{$_}->[3]}->[0]"} = $num; |
---|
1262 | $rpmdone->[$n] = $num; |
---|
1263 | }else { push @{$log{'d'}}, $_} |
---|
1264 | } |
---|
1265 | } |
---|
1266 | print LOG "SRPMS NOT IN REPOSITORY CD $num\n"; |
---|
1267 | foreach my $k (@{$log{"RS"}}){ |
---|
1268 | print LOG "$k->[0] $k->[1]\n"; |
---|
1269 | } |
---|
1270 | print LOG "BAD SRPMS VERSION CD $num\n"; |
---|
1271 | foreach my $k (@{$log{"V"}}){ |
---|
1272 | print LOG "$k->[0] $k->[1]\n"; |
---|
1273 | } |
---|
1274 | print LOG "DUPLICATE RPMS CD $num\n"; |
---|
1275 | foreach my $k (@{$log{"d"}}){ |
---|
1276 | print LOG "$k\n"; |
---|
1277 | } |
---|
1278 | return (\@cd, \%cd, $s, $ss, \%cds, $rpmdone, $srpmdone); |
---|
1279 | } |
---|
1280 | |
---|
1281 | sub checkcd2 { |
---|
1282 | my ($pkg,$num,$cd, $rep, $loc, $rpmdone) = @_; |
---|
1283 | my $s; |
---|
1284 | my @cd; |
---|
1285 | my %cd; |
---|
1286 | my @log; |
---|
1287 | print LOG "NOT IN REPOSITORIES CD $num\n"; |
---|
1288 | foreach (@$cd){ |
---|
1289 | s/^\s*(\w+)\s*$/$1/; |
---|
1290 | if ($_){ |
---|
1291 | if (!$rep->{$_}) { print "$_\n"; next} |
---|
1292 | my $n = $pkg->{$_}; |
---|
1293 | if (!$rpmdone->[$n]){ |
---|
1294 | foreach $loc (@{$loc}){ |
---|
1295 | $s += ((stat("$loc/$rep->{$_}"))[7] or next); |
---|
1296 | last; |
---|
1297 | } |
---|
1298 | push @cd, $_; |
---|
1299 | $cd{$_} = 1; |
---|
1300 | $rpmdone->[$n] = $num |
---|
1301 | }else { push @log, $_} |
---|
1302 | } |
---|
1303 | } |
---|
1304 | print LOG "DUPLICATE RPMS CD $num\n"; |
---|
1305 | foreach my $k (@log){ |
---|
1306 | print LOG "$k\n"; |
---|
1307 | } |
---|
1308 | return (\@cd, \%cd, $s, 0, 0,$rpmdone); |
---|
1309 | } |
---|
1310 | |
---|
1311 | # |
---|
1312 | # check depslist, depslists.ordered and hdlists |
---|
1313 | # |
---|
1314 | sub checkcds{ |
---|
1315 | my ($tops,$first) = @_; |
---|
1316 | my $i; |
---|
1317 | my $top; |
---|
1318 | |
---|
1319 | if ($first) { $top = $tops->[$first]} else { while (!$tops->[$i]){$i++}; $top = $tops->[$i]} ; |
---|
1320 | |
---|
1321 | local *A; open A, "$top/Mandrake/base/depslist.ordered" or die "unable to open $top/Mandrake/base/depslist.ordered"; |
---|
1322 | my %depspackages; |
---|
1323 | my %dup; |
---|
1324 | my $ok = 1; |
---|
1325 | my $OK=1; |
---|
1326 | print "Duplicate version: "; |
---|
1327 | while (<A>){ |
---|
1328 | my ($name, $pkg) = ((split)[0]) =~ /((.*)-[^-]+-[^-.]+(?:\.[^:]+)?)/; |
---|
1329 | $dup{$pkg} and do { print "\n$pkg"; $ok=0 ; $OK=0}; |
---|
1330 | $depspackages{$name} = 1; |
---|
1331 | $dup{$pkg} = 1; |
---|
1332 | } |
---|
1333 | $ok and print " OK\n"; |
---|
1334 | |
---|
1335 | my %hdlist; |
---|
1336 | my %rep; |
---|
1337 | local *A; open A, "$top/Mandrake/base/hdlists" or die "unable to open $top/Mandrake/base/hdlists"; |
---|
1338 | while (<A>){ |
---|
1339 | my ($hdlist, $dir, $cd, $num) = split; |
---|
1340 | local *B; open B, "packdrake $top/Mandrake/base/$hdlist|" or die "unable to open packdrake $top/Mandrake/base/$hdlist|"; |
---|
1341 | <B>; |
---|
1342 | print "\nIn $hdlist, not in depslist:"; |
---|
1343 | my $ok = 1; |
---|
1344 | my $p; |
---|
1345 | while (<B>){ |
---|
1346 | $p = (split)[2]; |
---|
1347 | # $p =~ s/(\.(i386|i486|i586|i686|noarch))?$//; |
---|
1348 | my ($old) = $p =~ /(.*)\.[^.]+$/; |
---|
1349 | $hdlist{$p} = 1; |
---|
1350 | $hdlist{$old} = 1; |
---|
1351 | if (!($depspackages{$p} || $depspackages{$old})) {print "\n$p"; $ok=0; $OK=0} |
---|
1352 | } |
---|
1353 | $p or do { print "$hdlist is empty\n" ; $OK=0}; |
---|
1354 | $ok and print " OK\n"; |
---|
1355 | local *C; |
---|
1356 | (($num =~ /\d+/) and opendir C, "$tops->[$num]/$dir") or opendir C, "$top/$dir"; |
---|
1357 | my $ok = 1; |
---|
1358 | print "\n\nIn $dir, not in depslist:"; |
---|
1359 | readdir C; |
---|
1360 | readdir C; |
---|
1361 | foreach (readdir C){ |
---|
1362 | s/\.rpm//; |
---|
1363 | my ($old) = /(.*)\.[^.]/; # FIXME compatibility for old depslist and hdlist format (<= 8.0) |
---|
1364 | $rep{$_} = 1; |
---|
1365 | $rep{$old} = 1; |
---|
1366 | if (! ($depspackages{$_} || $depspackages{$old})) {print "\n$_"; $ok=0; $OK = 0} |
---|
1367 | } |
---|
1368 | $ok and print " OK\n"; |
---|
1369 | } |
---|
1370 | |
---|
1371 | print "\n\nIn depslist, not in hdlist*.cz:"; |
---|
1372 | my $ok = 1; |
---|
1373 | foreach (keys %depspackages){ |
---|
1374 | if (!($hdlist{$_})) {print "\n$_"; $ok=0; $OK=0} |
---|
1375 | } |
---|
1376 | $ok and print " OK\n"; |
---|
1377 | |
---|
1378 | print "\n\nIn depslist, not in RPMS*:"; |
---|
1379 | my $ok = 1; |
---|
1380 | foreach (keys %depspackages){ |
---|
1381 | if (!$rep{$_}) {print "\n$_"; $ok=0; $OK=0} |
---|
1382 | } |
---|
1383 | $ok and print " OK\n"; |
---|
1384 | print "\n"; |
---|
1385 | return $OK; |
---|
1386 | } |
---|
1387 | |
---|
1388 | # |
---|
1389 | # check that all the groups and rpm are listed in the compssUsers |
---|
1390 | # |
---|
1391 | |
---|
1392 | sub checkcompssUser{ |
---|
1393 | my ($tops) = @_; |
---|
1394 | my $top = $tops->[1]; |
---|
1395 | local *A; open A, "$top/Mandrake/base/hdlists" or die "unable to open $top/Mandrake/base/hdlists"; |
---|
1396 | my %groups; |
---|
1397 | my %rpms; |
---|
1398 | while (<A>){ |
---|
1399 | my ($hdlist, $dir, $cd, $num) = split; |
---|
1400 | local *C; |
---|
1401 | my $topdir; |
---|
1402 | (($num =~ /\d+/) and $topdir = "$tops->[$num]/$dir") or $topdir = "$top/$dir"; |
---|
1403 | opendir C, "$topdir"; |
---|
1404 | print "Getting RPMS in $topdir\n"; |
---|
1405 | readdir C; |
---|
1406 | readdir C; |
---|
1407 | foreach (readdir C){ |
---|
1408 | /.*rpm/ or next; |
---|
1409 | my $g = `rpm -qp --queryformat "%{group}" $topdir/$_`; |
---|
1410 | push @{$groups{$g}}, $_; |
---|
1411 | $rpms{$_} = $g; |
---|
1412 | } |
---|
1413 | } |
---|
1414 | local *B, opendir B, "$top/Mandrake/base"; |
---|
1415 | foreach (readdir B){ |
---|
1416 | !/^compssUser/ and next; |
---|
1417 | print "\nCheckink $_\n"; |
---|
1418 | local *A; open A, "$top/Mandrake/base/$_" or die "unable to open $top/Mandrake/base/$_"; |
---|
1419 | print "Getting groups\n"; |
---|
1420 | my @compssUser; |
---|
1421 | while (<A>){ |
---|
1422 | chomp; |
---|
1423 | /^\s+(.*)/ and $compssUser[0]->{$1}++ and next; |
---|
1424 | /^\s+\+(.*)/ and $compssUser[1]->{$1}++ and next; |
---|
1425 | } |
---|
1426 | |
---|
1427 | print "\nUnlisted groups\n"; |
---|
1428 | foreach (keys %groups){ |
---|
1429 | my @gr = split "/"; |
---|
1430 | my $gr; |
---|
1431 | foreach my $g (@gr){ |
---|
1432 | $gr .= "$g"; |
---|
1433 | $compssUser[0]->{$gr} and last; |
---|
1434 | $gr .= "/" |
---|
1435 | } |
---|
1436 | $compssUser[0]->{$gr} and next; |
---|
1437 | print "$_\n" |
---|
1438 | } |
---|
1439 | |
---|
1440 | print "\nUnlisted RPMS\n"; |
---|
1441 | foreach (keys %rpms){ |
---|
1442 | my @gr = split "/", $rpms{$_}; |
---|
1443 | my $gr; |
---|
1444 | foreach my $g (@gr){ |
---|
1445 | $gr .= "$g"; |
---|
1446 | $compssUser[0]->{$gr} and last; |
---|
1447 | $gr .= "/" |
---|
1448 | } |
---|
1449 | $compssUser[0]->{$gr} and next; |
---|
1450 | $compssUser[1]->{$_} or print "$_\n"; |
---|
1451 | } |
---|
1452 | } |
---|
1453 | } |
---|