package Mkcd::Functions; our $VERSION = '0.1.1'; use strict; use File::Path; use rpmtools; use Mkcd::Tools qw(cpal du checkDiscs imageSize printDiscsFile config); =head1 NAME Functions - mkcd module =head1 SYNOPSYS require Mkcd::Functions; =head1 DESCRIPTION C include the disc building standard functions. =head1 SEE ALSO mkcd =head1 COPYRIGHT Copyright (C) 2000,2001 MandrakeSoft This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. =cut my $config; # need to do it to have its address my %functions = (); # [ function name, matching regexp, [arguments list (same as above)]] $functions{dir} = [ ["","dir",2," ", "Set directory name", sub { my ($cd,$fn,$repname,$reploc) = @_; my @a = ("dir", { repname => $repname, reploc => $reploc}); $config->{disc}[$cd]{function}{data}{dir}{$repname} and print {$config->{LOG}} "WARNING: disc $cd: duplicate directory $repname ($reploc)\n"; $config->{disc}[$cd]{function}{list}[$fn] = \@a; $config->{disc}[$cd]{function}{data}{dir}{$repname} = $reploc; print {$config->{LOG}} "dir: $repname ($reploc)\n"; push @{$config->{disc}[$cd]{steps}}, \@a; 1 }, "Setting directory" ] ]; # # generic options # # source => source dir # # done => done # $functions{generic} = [ ["","generic", 2, " ","Copy rpms from a list to a directory", sub { my ($cd,$fn,$repname,$list) = @_; my @a = ("generic", { repname => $repname, list => $list}); $config->{disc}[$cd]{function}{data}{dir}{$repname} or print {$config->{LOG}} "ERROR: disc $cd: $repname not defined\n"; $config->{list}[$list] or print {$config->{LOG}} "ERROR: lists $list does not exist, ignoring\n" and return 0; $config->{disc}[$cd]{function}{list}[$fn] = \@a; push @{$config->{disc}[$cd]{function}{data}{generic}{$repname}}, \@a ; push @{$config->{disc}[$cd]{fastgeneric}}, \@a; # [$a[1],$repname,$list]; push @{$config->{disc}[$cd]{steps}}, \@a; 1 }, "Copying rpms to directory"], ["s","source", [ [ "", "source", 0, "","Source mode configuration", sub { my ($tmp) = @_; $tmp->[0]{source} = 1; }, "Source mode"], # 2002 03 14 deprecated # [ "p", "priority", 1, "","Set the repository priority", sub { my ($tmp,$prio) = @_; $tmp->[0]{priority} = $prio}, "Setting source repository priority"] ], "[options]","Source mode setting", sub { my ($cd,$fn,$options) = @_; foreach (keys %$options){ $config->{disc}[$cd]{function}{list}[$fn][1]{$_} = $options->{$_}} 1 }, "Source mode option configuration"], [ "", "synthesis", 0, "","Add synthesis file in the repository", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{synthesis} = 1 }, "Setting synthesis tag"], [ "l", "limit", [ [ "", "limit", 1, "","Source mode configuration", sub { my ($tmp,$limit) = @_; $tmp->[0]{limit} = 1; $tmp->[0]{value} = $limit; }, "Limit mode"], [ "s", "soft",0, "","Soft mode, do not limit size if disc is not full", sub { my ($tmp) = @_; $tmp->[0]{soft} = 1 } , "Setting soft limit flag"] ], "[options] ","Limit the space of this directory on the disc", sub { my ($cd,$fn,$options) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{limit} = $options }, "Setting limit option"] ]; # # installation data # # install => install source path # # rpmsdir => rpm repositories list # # bootimg => boot image # # tag => tag # # lang => langage list # # rpmsrate => rpmsrate file to use # # compssUsers => compssUsers file to use # # score => score weights # # Installation options # # nosources # # nosrcfit # $functions{installation} = [ # 0 [ "", "installation", -1, " ... ","Preparing the installation directory and dependencies files", sub { my ($cd,$fn,@rpms) = @_; my @rpmsdir; foreach (@rpms){ my ($cdrep,$repname,$list) = m,(\d+)/([^/]+)(?:/(\d+))?,; push @rpmsdir, [$list,$cdrep,$repname] } my @a = ('installation', { rpmsdir => \@rpmsdir}); ref $config->{disc}[$cd]{function}{data}{installation} and print {$config->{LOG}} "ERROR: disc $cd: duplicate installation procedure, ignored\n" and return 0; $config->{disc}[$cd]{function}{list}[$fn] = \@a; $config->{disc}[$cd]{function}{data}{installation} = \@a; push @{$config->{disc}[$cd]{steps}}, \@a; 1 }, "Setting up installation files"], # 1 [ "b", "bootimg", 1, "","boot image for the cd", sub { my ($cd,$fn,$img) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{bootimg} = $img; 1}, "Setting boot image"], # 2 [ "c", "compss", 1, "", "Choose alternative compssUser file", sub { my ($cd,$fn,$compss) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{compssUsers} = $compss; 1 }, "Setting alternative compssUser file"], # 3 [ "f", "fixed", [ ["", "fixed", -1, " ... ","Fixed repository option configuration", sub { my ($tmp,@arg) = @_; $tmp->[0]{fixed} = 1; push @$tmp, @arg; 1 },"Setting fixed option arguments"], ["d", "dup", 0, "","Duplicate mode, accept to put package present in already done discs", sub { my ($tmp) = @_; $tmp->[0]{dup} = 1; 1 },"Setting duplicate mode"], ["", "nodeps", 0, "","Do not handle other discs dependencies", sub { my ($tmp) = @_; $tmp->[0]{nodeps} = 1; 1 },"Setting nodeps mode"], ["", "update", 0, "","Update mode, update already done packages", sub { my ($tmp) = @_; $tmp->[0]{update} = 1; 1 },"Setting update mode"] ], " ","repositories that must not be computed but integrated in the installation group", sub { my ($cd,$fn,$options,@fixed) = @_; foreach (@fixed){ my ($cdrep,$repname,$list) = m,(\d+)/([^/]+)(?:/(\d+))?,; push @{$config->{disc}[$cd]{function}{list}[$fn][1]{rpmsdir}}, [ $list, $cdrep, $repname, $options ] } $config->{disc}[$cd]{function}{list}[$fn][1]{fixed} = 1; 1}, "Setting fixed option"], # 4 [ "l", "lang", 1, "","languages that are conisdered by the install", sub { my ($cd,$fn,$lang) = @_; my @l = split ',',$lang; push @{$config->{disc}[$cd]{function}{list}[$fn][1]{lang}}, @l; 1}, "Setting language supported"], # 5 [ "i", "installdir", 1, "","Installation directory source", sub { my ($cd,$fn,$dir) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{install} = $dir; 1}, "Setting install source directory"], # 6 [ "", "nosources", 0, "","Do not add source rpm for this installation group", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{nosources} = 1; 1}, "Setting nosources tag for this installation group"], # 7 [ "", "nosrcfit", 0, "","Do not stop if sources discs are full", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{nosrcfit} = 1; 1}, "Setting nosourcefit tag for this installation group"], # 8 [ "o", "sortweight", 1, "","Set the weight for automatic sorting rules", sub { my ($cd,$fn,$weight) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{score} = [split ',', $weight]; 1}, "Setting sorting weights"], # 9 [ "r", "rpmsrate", 1, "", "Choose alternative rpmsrate", sub { my ($cd,$fn,$rpmsrate) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{rpmsrate} = $rpmsrate }, "Setting alternative rpmsrate file"], # 10 [ "t", "tag name", 1, "", "Tag added to the VERSION file", sub { my ($cd,$fn,$tag) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{tag} = $tag }, "Setting the tag name"], # 11 [ "", "dup", 0, "", "Authorize duplicate version for this install", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{data}[$fn][1]{dup} = 1 }, "Setting the tag name"], # 12 [ "", "nodeps", 0, "", "Do not include deps", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{nodeps} = 1 }, "Setting nodeps flag for this installation"], # 13 [ "", "isolinux", 0, "", "Isolinux mode", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{isolinux} = 1 }, "Build an isolinux install"], # 14 [ "", "synthesis", 0, "","Add synthesis file in the repository", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{synthesis} = 1 }, "Setting synthesis tag"], # 15 [ "", "sequential", 0, "","Build disc in a sequential way", sub { my ($cd,$fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{sequential} = 1 }, "Setting sequential tag"], # 16 [ "", "oem", [ ["", "oem", 0, "[options]","OEM mode configuration", sub { my ($tmp,@arg) = @_; $tmp->[0]{oem} = 1; push @$tmp, @arg; 1 },"Setting fixed option arguments"], ["d", "dir", 1, " ... ","Create OEM disc based on existing directories list", sub { my ($tmp,@dir) = @_; $tmp->[0]{file} and print {$config->{LOG}} "ERROR installation oem: could not use file and dir option in the same time, ignoring dir\n" and return 0; $tmp->[0]{dir} = \@dir; 1 },"Selecting directories"], ["h", "hdlists", 1, "","Select hdlists to include (all if omitted)", sub { my ($tmp,$hdlists) = @_; $tmp->[0]{hdlists} = $hdlists; 1 },"Selecting hdlists to include"], ["f", "file", 1, "