#!/usr/bin/perl # # to prepare, create and burn iso images # my $VERSION = "2.8.1"; use strict; use File::NCopy qw(copy); use Mkcd::Commandline qw(parseCommandLine usage); use Mkcd::Tools qw(printTable getTracks du cpal checkcds cleanrpmsrate config); use Mkcd::Group; use Mkcd::Package qw(packageOutOfRpmsrate getLeaves getRPMsKeys); use packdrake; use RPM::Header; # # config structure # # $config{name} = name for the product # # $config{list} = list data # $config{list}[list number]{name} = list name # {filelist} = ( file list location 1, file list location 2, ..., file list location n ) # # $config{list}[list number]{packages}[location i] = (RPMS location i, SRPMS location i) # # $config{list}[list number]{done} # {empty} # {auto} # {cd} # {sources} # # $config{list}[list number]{disc} = { cd => { rep => { options }} } # # $config{disc} = disc data # $config{disc}[disc number]{size} = size in bytes # $config{disc}[disc number]{serial} = serial number # $config{disc}[disc number]{name} = disc number irl # $config{disc}[disc number]{longname} = disc long name # $config{disc}[disc number]{fastgeneric} = [ generic data 1, generic data 2, ..., generic data n] # # $config{disc}[disc number]{function}{list}[function number] = (function name, { data }) # # $config{disc}[disc number]{function}{data}{dir}{repository identifier} = $config[2][cd number][1][function number] # # $config{disc}[disc number]{function}{data}{'installation'} = $config[2][cd number][1][function number] it should have only one installation by disc, anyway # # $config{disc}[disc number]{function}{data}[2]{'advertising'} = $config[2][cd number][1][function number] # # $config{disc}[disc number]{steps} = function to execute to build the disc # # # $config other values: # # discMax = higher real disc number # configfile = config file use for this session # lists # fast # nodeps # verbose # print # printscript # nolive # noiso # deps # nosrcfit # product # bugzilla # builddir # topdir # discsize # isodir # filetag # log # mkisoopt # tmp # # # Availaible functions # # see above @functions # # old -> new schema # # config structure # # $config[0][0] -> $config{name} # # $config[1] -> $config{list} # $config[1][list number][0] -> $config{list}[list number]{filelist} # # $config[1][list number][1][location i] -> $config{list}[list number]{packages}[location i] # # $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} # # $config[1][list number][3] -> $config{list}[list number]{disc} # # $config[2] -> $config{disc} # $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} # # $config[2][cd number][1][function number] -> $config{disc}[disc number]{function}{list}[function number] # # $config[2][cd number][2]{dir}{repository identifier} -> $config{disc}[disc number]{function}{data}{dir}{repository identifier} # # $config[2][cd number][2]{'installation'} -> $config{disc}[disc number]{function}{data}{'installation'} # # $config[2][cd number][2]{'advertising'} -> $config{disc}[disc number]{function}{data}[2]{'advertising'} # # $config[2][cd number][3] -> $config{disc}[disc number]{steps} # # # $config[3] -> $config{discMax}, $config{configfile} # my $topdir = `pwd`; chop $topdir; my %config = ( lists => [], fast => 0, nodeps => 0, verbose => 0, print => 0, printscript => 0, nolive => 0, noiso => 0, deps => 0, nosrcfit => 0, product => 0, bugzilla => 0, builddir => 0, topdir => $topdir, discsize => 681000000, isodir => 0, filetag => 0, log => 0, mkisoopt => "-r -J -hide-rr-moved -nobak -cache-inodes", tmp => $ENV{TMPDIR} || "$topdir/tmp" ); my @params; my %FUNCTIONS; $config{group} = new Mkcd::Group(\%config); my $functions = $config{group}{disc}{functions}{functions}; my @params = ( # [ "one letter option", "long name option", "number of args (-X means ´at least X´)", "help text", "function to call", "log info"] [ "","mkcd", 0, "","mkcd Mandrake Linux Disc maker", sub { 1 }, ""], [ "a", "auto", [ ["", "auto", -1, " ... ","Auto mode configuration", sub { my ($tmp,@arg) = @_; $tmp->[0] ||= {}; push @$tmp, @arg; 1 },"Setting auto mode arguments"], ["c", "cd", 1, "","Max number of discs", sub { my ($tmp, $cd) = @_; if ($cd =~ /\d+/) { $tmp->[0]{cd} = $cd } else { return 0 }; 1 },"Setting max number of discs"], ["s", "sources", 0, "","Create SRPMS discs too", sub { my ($tmp, $cd) = @_; $tmp->[0]{sources} = 1 },"Setting max number of discs"], ["", "noisolinux", 0, "","Do not use a isolinux boot", sub { my ($tmp, $cd) = @_; $tmp->[0]{noisolinux} = 1 },"Setting noisolinux option"] ], "[options] ... ", "Automated mode, build discs from a repository.", \&autoMode, "Auto mode"], [ "", "bugzilla", 0, "","Use bugzilla as information source.", sub { $config{bugzilla} = 1 }, "Using Bugzilla"], [ "b", "builddir", 1, "", "Where live iso image are created (default current dir).", sub { $config{builddir} = pop @_ }, "Setting the build directory"], [ "", "batch", 2, " ", "batch mode to rebuilt discs from a previous session.", \&batchMode, "Batch mode"], [ "c", "catto", 1, "", "Log file.", sub { $config{log} = pop @_; open LOG,">$config{log}" or die "unable to open $config{log}\n"}, "Log file"], [ "", "listrpmsrate", 1,"", "List the package in the rpmsrate file", \&packageOutOfRpmsrate, "Listing rpmsrate file"], [ "d", "depslist-creation", 0 , "", "rebuild the desplist.ordered file before checking the list.", sub { $config{deps}=1 }, "Depslist creation switch"], [ "", "discsize", 1 , "", "Select a custom disc size (default $config{discsize}).", sub { $config{discsize} = pop}, "Custom disc size selection"], [ "f", "fast", 0 , "", "fast mode.", sub { $config{fast} = 1}, "Fast mode"], [ "g", "getdeps", -2, " ... ","Generate the dependencies list of a list of packages.", sub { getdeps(shift,[@_])}, "Generating dependencies list of the packages"], [ "", "getleaves", 1, "", "Getting leaves from a depslist.ordered file",\&getLeaves,"Getting leaves from a depslist.ordered"], # FIXME function help should take 0 or one argument, but this is not possible with this structure [ "h", "help", -1, " ", "Display help, eg. mkcd -h installation fixed. Type mkcd -h config for configuration files options.", sub { my (@function) = @_; if (@function) { my $key = join '/', @function; usage($key,$FUNCTIONS{$key}) } else { usage("mkcd",\@params)} 1}, ""], [ "", "check", -1, " ... ", "Check the hdlists, depslist and RPMS coherency.", sub { checkcds(@_)}, "Checking the hdlists, depslist and RPMs coherency"], [ "i", "isodir", 1, "", "Where ISOs are built (default ./iso/product_name/).", sub { $config{isodir} = pop @_ }, "Setting the iso directory"], [ "k", "checkcu", -1, " ... ", "Checking the compssUser.", sub { checkcompssUser([0,@_])}, "Checking the compssUser"], [ "l", "lists", 1 , "","lists of discs taken into account.", sub { $config{lists} = getTracks(pop @_) }, "Using given disc list"], [ "m", "make", 1, "", "Build the discs.", \&make , "Building the discs"], [ "", "nodeps", 0, "", "Do not include automatically dependencies of packages", sub { $config{nodeps} = 1 }, "Setting nodeps flag"], [ "", "nolive", 0, "", "Do not create live image of the discs.", sub { $config{nolive} = 1}, "Setting nolive option"], [ "", "noiso", 0, "", "Do not create iso images of the discs.", sub { $config{noiso} = 1}, "Setting noiso option"], [ "", "nosrcfit", 0, "", "Do not stop if sources discs are full", sub { $config{nosrcfit} = 1}, "Setting nosrcfit option"], [ "", "oem", -1, " ... ", "Build a OEM installation CD based on the given disc", \&oem, "Building oem disc" ], [ "p", "printscript", 1, "