source: soft/build_system/build_system/mkcd/tags/V4_0_8_1mdk/mkcd @ 1

Last change on this file since 1 was 1, checked in by fasma, 12 years ago

Initial Import from Mandriva's soft revision 224062 and package revision 45733

File size: 24.1 KB
Line 
1#!/usr/bin/perl -I /home/warly/files/cvs/mdk/soft/mkcd/pm/
2#
3# Copyright (C) 2000,2001,2002,2003,2004 Mandrakesoft
4#
5# Author: Florent Villard <warly@mandraesoft.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20#
21# to prepare, create and burn iso images
22#
23
24my $VERSION = "4.0.7";
25
26use strict;
27use File::NCopy qw(copy);       
28use Mkcd::Commandline qw(parseCommandLine usage);
29use Mkcd::Tools qw(printTable getTracks du cpal checkcds cleanrpmsrate config compute_md5 include_md5 convert_size);
30use Mkcd::Group;
31use Mkcd::Package qw(check_rpmsrate packageOutOfRpmsrate getLeaves list_hdlist mkcd_build_hdlist %ARCH genDeps);
32use MDK::Common qw(all);
33use packdrake;
34
35#
36# FIXME not up to date
37#
38# config structure
39#
40# $config{name} = name for the product
41#
42# $config{list} = list data
43#   $config{list}[list number]{name} = list name
44#                             {filelist} = ( file list location 1, file list location 2, ..., file list location n )
45#
46#   $config{list}[list number]{packages}[location i] = (RPMS location i, SRPMS location i)
47#
48#   $config{list}[list number]{done}
49#                             {empty}
50#                             {auto}
51#                             {cd}
52#                             {sources}
53#
54#   $config{list}[list number]{disc} = { cd => { rep => { options }}  }
55#
56# $config{disc} = disc data
57#   $config{disc}[disc number]{size} = size in bytes
58#   $config{disc}[disc number]{serial} = serial number
59#   $config{disc}[disc number]{name} = disc number irl
60#   $config{disc}[disc number]{longname} = disc long name
61#   $config{disc}[disc number]{fastgeneric} = [ generic data 1, generic data 2, ..., generic data n]
62#
63#   $config{disc}[disc number]{function}{list}[function number] = (function name, { data })
64#
65#   $config{disc}[disc number]{function}{data}{dir}{repository identifier} = $config[2][cd number][1][function number]
66#
67#   $config{disc}[disc number]{function}{data}{'installation'} = $config[2][cd number][1][function number]  it should have only one installation by disc, anyway
68#
69#   $config{disc}[disc number]{function}{data}[2]{'advertising'} = $config[2][cd number][1][function number]
70#
71#   $config{disc}[disc number]{steps} = function to execute to build the disc
72#
73#
74# $config other values:
75#
76#    discMax = higher real disc number
77#    configfile = config file use for this session
78#    lists
79#    fast
80#    nodeps
81#    verbose
82#    print
83#    printscript
84#    nolive
85#    noiso
86#    deps
87#    nosrcfit
88#    product
89#    bugzilla
90#    builddir
91#    topdir
92#    discsize
93#    isodir
94#    filetag
95#    log
96#    mkisoopt
97#    tmp
98#
99
100#
101# Availaible functions
102#
103#   see Functions.pm
104#
105
106# old -> new schema
107#
108# config structure
109#
110# $config[0][0] -> $config{name}
111#
112# $config[1] -> $config{list}
113#   $config[1][list number][0] ->  $config{list}[list number]{filelist}
114#
115#   $config[1][list number][1][location i] -> $config{list}[list number]{packages}[location i]
116#
117#   $config[1][list number][2] -> $config{list}[list number]{done}, $config{list}[list number]{empty} $config{list}[list number]{cd}$config{list}[list number]{auto}
118#
119#   $config[1][list number][3] -> $config{list}[list number]{disc}
120#
121# $config[2] -> $config{disc}
122#   $config[2][cd number][0] -> $config{disc}[disc number]{size}, $config{disc}[disc number]{serial}, $config{disc}[disc number]{name}, $config{disc}[disc number]{longname}, $config{disc}[disc number]{fastgeneric}
123#
124#   $config[2][cd number][1][function number] -> $config{disc}[disc number]{function}{list}[function number]
125#
126#   $config[2][cd number][2]{dir}{repository identifier} -> $config{disc}[disc number]{function}{data}{dir}{repository identifier}
127#
128#   $config[2][cd number][2]{'installation'} -> $config{disc}[disc number]{function}{data}{'installation'}
129#
130#   $config[2][cd number][2]{'advertising'} -> $config{disc}[disc number]{function}{data}[2]{'advertising'}
131#
132#   $config[2][cd number][3] -> $config{disc}[disc number]{steps}
133#
134#
135# $config[3] -> $config{discMax}, $config{configfile}
136#
137#
138
139our %FUNCTIONS;
140our $functions;
141our $optimize;
142our $LOG;
143
144our $topdir = `pwd`;
145chop $topdir;
146our %config = (
147    lists => [],
148    fast => 0,
149    nodeps => 0,
150    verbose => 0,
151    print => 0,
152    printscript => 0,
153    nolive => 0,
154    noiso => 0,
155    deps => 0,
156    nosrcfit => 0,
157    nosrc => 0,
158    product => 0,
159    bugzilla => 0,
160    builddir => 0,
161    topdir => $topdir,
162    discsize => 681000000,
163    isodir => 0,
164    filetag => 0,
165    log => 0,
166    mkisoopt => "-r -J -hide-rr-moved -nobak -cache-inodes",
167    tmp => $ENV{TMPDIR} || "$topdir/tmp",
168    disc_building_tries => 3,
169    rejected_options => { 
170        config => "Could not comply with packages filter directives",
171        no_disc => "Could not add more disc for this package",
172        no_space => "Not enough space",
173        deps => "Missing dependencies",
174        old_version => "More recent version found",
175        deps_rejected => "Some needed dependencies rejected",
176        excluded => "Explicitely excluded",
177        order_pb => "Needed dependency could not be put before",
178        sequential => "Could not add interlist dependencies in sequential mode",
179        autodeps => "not selected in rpm lists"
180    },
181    optimize_space => 1,
182    ARCH => \%ARCH,
183    struct => { 
184        '10.0' => { 
185            install => 'Mandrake',
186            media_hdlist => '',
187            media_info => 'Mandrake/base',
188            medium_media_info => '',
189            media => 'Mandrake/RPMS',
190            media_base => 'Mandrake',
191            srpm_media => 'Mandrake/SRPMS',
192            isolinux => 'isolinux',
193            images => 'images',
194            extra => 'Mandrake/share',
195            patch => 'Mandrake/base',
196            stage2 => 'Mandrake/mdkinst',
197            compssUsers => 'compssUsers',
198        },
199        '10.1' => {
200            install => 'install',
201            media_hdlist => 'media_info',
202            media_info => 'media/media_info',
203            medium_media_info => 'media_info',
204            media => 'media/main',
205            media_base => 'media',
206            srpm_media => 'SRPMS/main',
207            isolinux => 'isolinux',
208            images => 'install/images',
209            extra => 'install/extra',
210            patch => 'install',
211            stage2 => 'install/stage2',
212            compssUsers => 'compssUsers.pl',
213        }
214    },
215    struct_version => 10.1,
216);
217
218$config{group} = new Mkcd::Group(\%config);
219$functions = $config{group}{disc}{functions}{functions};
220my $arg = @ARGV;
221our @params;
222@params = ( 
223    #    [ "one letter option", "long name option", "number of args (-X means Žat least XŽ)", "help text", "function to call", "log info"]
224    [ "", "mkcd", 0, "<options>", 
225    "mkcd Mandrakelinux Disc maker", 
226    sub { $arg or usage('mkcd', \@params) }, "" ],
227    [ "a", "auto", [
228        ["", "auto", -1, "<repository> <extra RPMS directory 1> <extra RPMS directory 2> ... <extra RPMS directory n>", 
229        "Auto mode configuration", 
230        sub {   
231            my ($tmp, @arg) = @_;
232            $tmp->[0] ||= {};
233            push @$tmp, @arg;
234            1
235        }, "Setting auto mode arguments"],
236        ["c", "cd", 1, "<number of discs>", 
237        "Max number of discs", 
238        sub { my ($tmp, $cd) = @_; if ($cd =~ /\d+/) { $tmp->[0]{cd} = $cd } else { return 0 }; 1 }, "Setting max number of discs"],
239        ["s", "sources", [
240          [ "", "sources", 0, "<options>", 
241          "Sources mode options", 
242            sub {   my ($tmp) = @_;
243                $tmp->[0] ||= {};
244                1
245            }, "Setting source mode options" ],
246          [ "s", "separate", 0, "", 
247          "Separate binaries discs from sources discs", 
248          sub { my ($tmp) = @_; $tmp->[0]{separate} = 1 }, "Setting source mode separate option" ]
249        ], "", 
250        "Create SRPMS discs too", 
251        sub { my ($tmp, $opt) = @_; $tmp->[0]{sources} = $opt }, "Setting source mode"],
252        ["", "noisolinux", 0, "", 
253        "Do not use a isolinux boot", 
254        sub { my ($tmp) = @_; $tmp->[0]{noisolinux} = 1 }, "Setting noisolinux option"]
255], "[options] <repository> <extra RPMS directory 1> <extra RPMS directory 2> ... <extra RPMS directory n>", 
256"Automated mode, build discs from a repository.", \&auto_mode, "Auto mode" ],
257    [ "", "addmd5", 1, "<iso file>", 
258    "Add md5sum to iso header.", 
259    sub { my $err = include_md5(pop, 1, 1); print $err }, "Adding md5 to ISO header" ],
260    [ "k", "checkmd5", 1, "<iso file>", 
261    "Checking md5sum of iso header.", 
262    sub { my $err = include_md5(pop, 0, 1); print $err }, "Checking md5 of ISO header" ],
263    [ "", "bugzilla", 0, "", 
264    "Use bugzilla as information source.", 
265    sub { $config{bugzilla} = 1 }, "Using Bugzilla" ],
266    [ "b", "builddir", 1, "<build dir>", 
267    "Where live iso image are created (default current dir).", 
268    sub { $config{builddir} = pop @_ }, "Setting the build directory" ],
269    [ "", "buildhdlist", -1, "<rpms dir 1> <rpms dir 2> ... <rpms dir n>", "Build hdlist.cz files for given directories.", 
270    sub {
271        my $i;
272        mkcd_build_hdlist(int @_, 
273                [ 0, 
274                map { 
275                    $i++;
276                    if (/(.*)(hdlist.*\.cz)$/) { 
277                        { done => 1, hdlist => $_, synthesis => "$1synthesis.$2" } 
278                    } else {
279                        { rpms => [ glob "$_/*.rpm" ], hdlist => "./hdlist$i.cz", synthesis => "./synthesis.hdlist$i.cz" } 
280                    }
281                } @_ ], "$config{tmp}/.build_hdlist", 'depslist.ordered', 'provides', 'compss')
282    }, "building hdlist files" ],
283    [ "", "batch", 2, "<discs list> <batch file>", 
284    "batch mode to rebuilt discs from a previous session.",  \&batchMode, "Batch mode" ],
285    [ "c", "catto", 1, "<log file>", 
286    "Log file.", 
287    sub { 
288        $config{log} = pop @_; 
289        open $LOG, ">$config{log}" or die "unable to open $config{log}\n";
290        print $LOG, "command line: @ARGV\n"
291    }, "Log file" ],
292    [ "", "checkdeps", -1, "<RPMS dir 1> <RPMS dir 2> ... <RPMS dir n>", 
293    "Check coherency of a set of directories.", \&check_deps, "Checking dependencies" ],
294    [ "", "cpu", 1, "<cpu number>", 
295    "Force cpu number", 
296    sub { $config{cpu} = shift }, "Setting cpu number" ],
297    [ "", "listrpmsrate", 1, "<rpmsrate file>", 
298    "List the package in the rpmsrate file", \&packageOutOfRpmsrate, "Listing rpmsrate file" ],
299    [ "", "checkrpmsrate", -2, "<rpmsrate file> <rpms dir 1> <rpms dir 2> ... <rpms dir n>", 
300    "List the package in the rpmsrate file and not in the given repositories", \&check_rpmsrate, "Checking rpmsrate file" ],
301    [ "d", "depslist-creation", 0 , "", 
302    "rebuild the desplist.ordered file before checking the list.", 
303    sub { $config{deps} = 1 }, "Depslist creation switch" ],
304    [ "", "discsize", 1 , "<disc size in bytes>", 
305    "Select a custom disc size (default $config{discsize}).", 
306    sub { $config{discsize} = convert_size(pop, $config{discsize}, $config{LOG}) }, "Custom disc size selection" ],
307    [ "f", "fast", 0 , "", "fast mode.", sub { 
308        $config{fast} = 1;
309        $config{disc_building_tries} = 1;
310        $optimize = 0;
311        $config{optimize_space} = 0;
312        1
313    }, "Fast mode" ],
314    [ "", "getleaves", 1, "<depslist file>", 
315    "Getting leaves from a depslist.ordered file", \&getLeaves, "Getting leaves from a depslist.ordered" ],
316# FIXME function help should take 0 or one argument, but this is not possible with this structure
317    [ "h", "help", -1, "<path> <to> <the> <function>", 
318    "Display help, eg. mkcd -h installation fixed. Type mkcd -h config for configuration files options.", 
319    sub { 
320        my (@function) = @_; 
321        if (@function) { 
322            my $key = join '/', @function; 
323            if (ref $FUNCTIONS{$key}) {
324                usage($key, $FUNCTIONS{$key})
325            }
326        }
327        usage("mkcd", \@params);
328        }, "" ],
329    [ "", "check", -1, "<dir 1> <dir 2> ... <dir n>", 
330    "Check the hdlists, depslist and RPMS consistency.", 
331    sub { checkcds(@_) }, "Checking the hdlists, depslist and RPMs consistency" ],
332    [ "K", "checkdisc", 2, "<ISO mount point> <md5 file>", 
333    "Check the disc.", 
334    sub { check_discs(@_) }, "Checking the disc" ],
335    [ "i", "isodir", 1, "<iso dir>", 
336    "Where ISOs are built (default ./iso/product_name/).", 
337    sub { $config{isodir} = pop @_ }, "Setting the iso directory" ],
338    [ "l", "lists", 1 , "", 
339    "lists of discs taken into account.", 
340    sub { $config{lists} = getTracks(pop @_) }, "Using given disc list" ],
341    [ "m", "make", 1, "<cds number>", 
342    "Build the discs.", \&make , "Building the discs" ],
343    [ "", "nodeps", 0, "", 
344    "Do not include automatically dependencies of packages", 
345    sub { $config{nodeps} = 1 }, "Setting nodeps flag" ],
346    [ "", "nofork", 0, "", 
347    "Do not fork", 
348    sub { $config{nofork} = 1 }, "Setting nofork flag" ],
349    [ "", "nolive", 0, "", 
350    "Do not create live image of the discs.", 
351    sub { $config{nolive} = 1 }, "Setting nolive option" ],
352    [ "", "noiso", 0, "", 
353    "Do not create iso images of the discs.", 
354    sub { $config{noiso} = 1 }, "Setting noiso option" ],
355    [ "", "nosrcfit", 0, "", 
356    "Do not stop if sources discs are full", 
357    sub { $config{nosrcfit} = 1 }, "Setting nosrcfit option" ],
358    [ "", "nosrc", 0, "", 
359    "Do not include sources", 
360    sub { $config{nosrc} = 1 }, "Setting nosrc option" ],
361    [ "", "oem", -1, "<root of disc 1> <root of disc 2> ... <root of disc n>", 
362    "Build a OEM installation CD based on the given disc", \&oem, "Building oem disc" ],
363    [ "", "struct", 1 , "<struct>", 
364    "Build ISO with a specific structure", 
365    sub { $config{struct_version} = shift }, "Selecting the structure version" ],
366    [ "p", "printscript", 1, "<script file>", 
367    "Print the script that can be use to rebuild the discs", 
368    sub { $config{printscript} = shift }, "Printing script" ],
369    [ "", "printdiscsfiles", 1, "<file>", 
370    "Print the contains of each disc", 
371    sub { $config{print} = shift }, "Printing disc contains" ],
372    [ "", "pl", -1, "<hdlist 1> <hdlist 2> ... <hdlist n>", 
373    "Do a packdrake -l on the hdlists", 
374    sub { list_hdlist(\@_,1) }, "Printing hdlist contents" ],
375    [ "s", "spec", 1, "<config file>", 
376    "Configuration file", 
377    sub { config(shift, \%config, $functions, \%FUNCTIONS) } , "Loading configuration file" ],
378    [ "t", "topdir", 1, "<top dir>", 
379    "Where files are created (default current dir).", 
380    sub { $config{topdir} = pop @_; $config{tmp} = $ENV{TMPDIR} || "$config{$topdir}/tmp" }, "Setting the top directory" ],
381    [ "", "testlist", 3, "<config file> <list number> <rpmsrate_file>", 
382    "Perform a rapide resolution of the file list.", \&test_list, "Testing the file list" ],
383    [ "", "update-rpmsrate", -2, "<rpmsrate> <rpms directory 1> <rpms directory 2> ... <rpms directory n>", 
384    "Add major to libraries in rpmsrate", 
385        sub { 
386            my %rpm;
387            my $rpmsrate = shift @_;
388            foreach my $d (@_) { $rpm{$d} = [ map { s,$d/?(.*)\.rpm$,$1,; $_ } glob "$d/*.rpm" ] };
389            cleanrpmsrate($rpmsrate, 0, 0, \%rpm)
390        }, "Adding major to libraries in rpmsrate" ],
391    [ "", "verbose", 1 , "<log level>",
392    "Print more messages (the higher the more, 5 is the higher)",
393    sub { $config{verbose} = shift; 1 }, "Setting the verbose flag" ],
394    [ "v", "version", 0, "", "Print program version", 
395        sub {
396            print_fh($config{LOG}, "\nmkcd version $VERSION\n");
397            1 }, "" ],
398    [ "", "disc_building_tries", 1 , "<maximum number of iteration to build correct ISO size>",
399    "Set the number of iterations when trying to adjust ISO size",
400    sub { $config{disc_building_tries} = shift; $optimize = 1; 1 }, "Setting the disc_building_tries value" ],
401    [ "", "use_optimize_space", 1 , "<number of disc building tries>",
402    "Use optimize_space algorythm",
403    sub {
404        my $t = shift;
405        $config{disc_building_tries} = $t;
406        $optimize = 1;
407        $config{optimize_space} = $t
408        }, "Setting the disc_building_tries value" ],
409    [ "P", "Publisher", 1 , "<publisher name>",
410    "Set the publisher name for ISO header publisher_id (128 char max)",
411    sub { $config{Publisher} = substr shift, 0, 128 }, "Setting the publisher ID flag" ],
412#    [ "", "test", 0 , "", "Set the publisher name for ISO header publisher_id (128 char max)", sub { print "ARCH ", keys %{$config{ARCH}} , "\n\n" }, "Setting the publisher ID flag"],
413);
414
415# FIXME this permit to have specific help
416foreach (@params) {
417    $FUNCTIONS{$_->[1]} = ref($_->[2]) ? $_->[2] : [ $_ ]
418}
419
420$FUNCTIONS{mkcd} = \@params;
421foreach my $k (keys %$functions) {
422    $FUNCTIONS{$k} = $functions->{$k};
423    foreach (@{$functions->{$k}}) {
424        $FUNCTIONS{"$k/$_->[1]"} = ref($_->[2]) ? $_->[2] : [ $_ ]
425    }
426    push @{$FUNCTIONS{config}} , $functions->{$k}[0]
427}
428
429open($LOG, ">&STDERR");
430$config{LOG} = $LOG;
431
432my $todo = parseCommandLine("mkcd", \@ARGV, \@params);
433@ARGV and usage("mkcd", \@params, "@ARGV, too many arguments");
434foreach my $t (@$todo)  {
435    print $LOG "mkcd: $t->[2]\n";
436    &{$t->[0]}(@{$t->[1]}) or print $LOG "ERROR: $t->[2]\n";
437}
438
439# FIXME only to make perl_checker happy
440sub print_fh {
441    my ($fh, $text) = @_;
442    print $fh $text
443}
444
445sub batchMode {
446    my ($cds, $file) = @_;
447    config($file, \%config, $functions, \%FUNCTIONS);
448    my ($discsFiles, $cd) = readBatchFile($file);
449    (my $lists,$cds) = getDiscsList($cds);
450    my @mkisos;
451    my @size;
452    Mkcd::Disc::makeDiscs(0,$lists,$cds, \@size, \@mkisos,$discsFiles);
453    Mkcd::Disc::makeDiscs(1,$lists,$cds, \@size, \@mkisos,$discsFiles,$cd);
454}
455
456sub getDiscsList {
457    my ($cds) = @_;
458    $cds = getTracks($cds);
459    print $LOG "getDiscList: discs @$cds\n";
460    my %list;
461    $cds = [grep { if (ref $config{disc}[$_]) { $list{$_} = 2; push @{$config{lists}}, $_; 1 } else { print $LOG "WARNING: disc $_ not defined\n"; 0 } } @$cds];
462    $config{lists} ||= $cds;
463    $config{lists} = [ grep { $list{$_} or ref $config{disc}[$_] and $list{$_} = 1 or print $LOG "WARNING: disc $_ not defined\n" and 0 } @{$config{lists}}];
464    foreach (@{$config{virtual_disc}}) {
465        $list{$_} = 1;
466        push @{$config{lists}}, $_
467    }
468    return \%list,$cds
469}
470
471sub auto_mode {
472    my ($opt, $repository, @rpms) = @_;
473    $config{nolive} = 1;
474    $config{nosrcfit} = 1;
475    $config{deps} = 1;
476    if (!$optimize) {
477        $config{disc_building_tries} = 1;
478        $config{optimize_space} = 0;
479    }
480    my $struct_v = $config{struct_version};
481    my $install_dir = $config{struct}{$struct_v}{install};
482    my $media_dir = $config{struct}{$struct_v}{media_base};
483    -d "$repository/$media_dir" or print "ERROR: $repository/$media_dir does not exist\n" and return 0;
484    my $dir = "$repository/$media_dir";
485    opendir my $DIR, $dir;
486    foreach (readdir $DIR) {
487        -d "$dir/$_" or next;
488        m/^(media_info|\..*)$/ and next;
489        print $LOG "auto_mode: adding $dir/$_\n";
490        unshift @rpms, "$dir/$_"
491    }
492    my ($name, $tag);
493    if (-f "$repository/VERSION") {
494        open my $A, "$repository/VERSION";
495        local $_;
496        <$A> and /^Mandrakelinux (.*) \d{8} \d{2}:\d{2}$/ and ($name,$tag) = split ' ', $1;
497        close $A
498    }
499    $name ||= "Cooker-download";
500    $config{name} = $name;
501    foreach (keys %$opt) { $config{list}[1]{$_} = $opt->{$_} }
502    $config{list}[1]{auto} = 1;
503    my $media_info_dir = "$repository/$config{struct}{$struct_v}{media_info}";
504    if (-d $media_info_dir) {
505        opendir my $basedir, $media_info_dir;
506        foreach my $file (readdir $basedir) {
507            $file =~ /^pubkey/ or next;
508            push @{$config{list}[1]{keyfiles}}, "$media_info_dir/$file"
509        }
510        closedir $basedir
511    }
512    foreach (keys %{$config{list}[1]}) { print $LOG "auto_mode: list options $_ -> $config{list}[1]{$_}\n" }
513    foreach (@rpms) {
514        #       $size += du($_);
515        push @{$config{list}[1]{packages}}, { rpm => [ $_ ], srpm => \@rpms }
516    }
517    my %cd = (1 => 2);
518    my @cd = 1;
519    #print $LOG "Total RPMS $size\n";
520    $config{disc}[1]{size} = $config{discsize};
521    $config{disc}[1]{serial} = "${name}-disc1";
522    $config{disc}[1]{name} = 1;
523    $config{disc}[1]{longname} = "Mandrakelinux $name";
524    $config{disc}[1]{appname} = "Mandrakelinux $name disc 1";
525    $config{disc}[1]{label} = substr "Mandrakelinux-$name-Disc1", 0, 32;
526    my $idx = 1;
527    my %idx;
528    &{$functions->{dir}[0][5]}(1,$idx, "rpms", $config{struct}{$struct_v}{media});
529    $idx++;
530    &{$functions->{generic}[0][5]}(1,$idx, "rpms",1);
531    &{$functions->{generic}[2][5]}(1,$idx);
532    $idx++;
533    $idx{installation} = $idx;
534    &{$functions->{installation}[0][5]}(1,$idx);
535    &{$functions->{installation}[5][5]}(1,$idx, $repository);
536    &{$functions->{installation}[10][5]}(1,$idx, $tag);
537    &{$functions->{installation}[14][5]}(1,$idx);
538    &{$functions->{installation}[18][5]}(1,$idx, "1/rpms");
539    $idx++;
540    &{$functions->{boot}[0][5]}(1,$idx);
541    my $isolinux_dir = $config{struct}{$struct_v}{isolinux};
542    my $images_dir = $config{struct}{$struct_v}{images};
543    if (-w "$repository/$isolinux_dir/isolinux.bin" && !$opt->{noisolinux}) {
544        &{$functions->{boot}[1][5]}(1,$idx, { isolinux => 1 });
545        &{$functions->{boot}[2][5]}(1,$idx, { bootimg => 1 }, "$isolinux_dir/isolinux.bin");
546        &{$functions->{boot}[3][5]}(1,$idx, { first => 1 }, "$repository/$isolinux_dir");
547        &{$functions->{boot}[3][5]}(1,$idx, { } ,"$repository/$images_dir", "$images_dir/");
548    } else {
549        &{$functions->{boot}[2][5]}(1,$idx, { bootimg => 1, dir => "Boot" }, "$images_dir/cdrom.img");
550        &{$functions->{boot}[3][5]}(1,$idx, { first => 1, dest => "$install_dir"}, "$repository/$images_dir");
551    }
552    if ($opt->{sources}) {
553        $config{nosrcfit} = 0;
554        if ($opt->{sources}{separate}) {
555            $config{disc}[2]{size} = $config{discsize};
556            $config{disc}[2]{serial} = "${name}-2-src";
557            $config{disc}[2]{name} = 2;
558            $config{disc}[2]{longname} = "Mandrakelinux $name sources";
559            $config{disc}[1]{appname} = "Mandrakelinux $name sources disc 2";
560            push @cd,2;
561            $cd{2} = 2;
562            &{$functions->{dir}[0][5]}(2,1, "srpms", $config{struct}{$struct_v}{srpm_media});
563            &{$functions->{generic}[0][5]}(2,2, "srpms",1);
564            &{$functions->{generic}[1][5]}(2,2, { source => 1 });
565            &{$functions->{installation}[17][5]}(1, $idx{installation}, "2/srpms")
566        } else {
567            $idx++;
568            &{$functions->{dir}[0][5]}(1,$idx, "srpms", $config{struct}{$struct_v}{srpm_media});
569            $idx++;
570            &{$functions->{generic}[0][5]}(1,$idx, "srpms",1);
571            &{$functions->{generic}[1][5]}(1,$idx, { source => 1 });
572            &{$functions->{installation}[17][5]}(1, $idx{installation}, "1/srpms")
573        }
574    } else {
575        &{$functions->{installation}[6][5]}(1,$idx)
576    }
577    printTable(\%config);
578    $config{group}->makeWithGroups(\%cd, \@cd);
579    1   
580}
581
582sub make {
583    my ($cds) = @_;
584    $config{group}->makeWithGroups(getDiscsList($cds));
585    1
586}               
587
588sub oem {
589    my (@cds) = @_;
590}
591
592sub check_discs {
593    my ($mntpt, $mdfile) = @_;
594    local *A; open A, $mdfile;
595    my %ignore;
596    my $sum;
597    local $_;
598    while (<A>) {
599        chomp;
600        last if ($sum) = /^(.*) - /;
601        my $t = "/$_";
602        $t =~ s,//+,/,g;
603        $ignore{$t} = 1
604    }
605    close A;
606    my $hexdigest = compute_md5([[ "/", $mntpt ]], \%ignore);
607    if ($hexdigest eq $sum) {
608        print "\nOK ($hexdigest)\n"
609    } else {
610        print "\nFAILED (computed $hexdigest <> expected $sum)\n";
611        return 0
612    }
613    1
614}
615
616sub check_deps {
617    my (@rep) = @_;
618    my %group;
619    my $tmpdir = "$config{tmp}/mkcd_check_deps";
620    -d $tmpdir or mkdir $tmpdir or die "FATAL: could not create $tmpdir";
621    foreach (@rep) { push @{$group{rep_pkg}{$_}}, grep { s/\.rpm$// } all $_  }
622    $group{urpm} = genDeps($tmpdir, $group{rep_pkg}, 0, $config{verbose}, $config{tmp});
623    $group{option} = {};
624    $group{rejected} = {};
625    Mkcd::List::reverseDepslist({}, \%group, {});
626    foreach my $rpm (sort keys %{$group{rejected}}) {
627        print "$rpm ", join (' ', map { map { $_->[1] } @$_ } values %{$group{rejected}{$rpm}}), "\n"
628    }
629}
630
631sub test_list {
632    my ($config_file, $list, $rpmsrate) = @_;
633    config($config_file, \%config, $functions, \%FUNCTIONS);
634    my $class = $config{group};
635    my $discs_files;
636    my $rpmlist;
637    my %group = (
638        list => {
639            $list => { },
640        },
641        orderedlist => { rpm => [ $list ] },
642    );
643    Mkcd::Group::getGroupReps(\%config, \%group, $discs_files);
644    # fake rpm list
645    foreach my $dir (keys %{$group{rep_pkg}{rpm}}) {
646        foreach my $rpm (@{$group{rep_pkg}{rpm}{$dir}}) {
647            $group{urpm}{rpm}{$rpm} = 1;
648            $group{size}{$rpm}{$list}[2] = 0;
649            push @{$group{listrpm}{$list}}, $rpm
650        }
651    }
652    ($group{filelist}, my $norpmsrate) = $class->{list}->getList(\%group, $discs_files);
653    $group{rpmsrate} = cleanrpmsrate($rpmsrate, "$config{tmp}/rpmsrate", $norpmsrate, $group{rep_pkg}{rpm}, $group{urpm});
654    $class->{list}->build_list(\%group, 1);
655    1
656}
Note: See TracBrowser for help on using the repository browser.