1 | package Mkcd::Functions; |
---|
2 | |
---|
3 | our $VERSION = '1.0.2'; |
---|
4 | |
---|
5 | use strict; |
---|
6 | use File::Path; |
---|
7 | use MDK::Common qw(substInFile); |
---|
8 | use File::NCopy qw(copy); |
---|
9 | use Mkcd::Tools qw(cpal du checkDiscs imageSize printDiscsFile config readBatchFile log_ convert_size); |
---|
10 | use Mkcd::Package qw(mkcd_build_hdlist); |
---|
11 | |
---|
12 | =head1 NAME |
---|
13 | |
---|
14 | Functions - mkcd module |
---|
15 | |
---|
16 | =head1 SYNOPSYS |
---|
17 | |
---|
18 | require Mkcd::Functions; |
---|
19 | |
---|
20 | =head1 DESCRIPTION |
---|
21 | |
---|
22 | <Mkcd::Functions> include the disc building standard functions. |
---|
23 | |
---|
24 | =head1 SEE ALSO |
---|
25 | |
---|
26 | mkcd |
---|
27 | |
---|
28 | =head1 COPYRIGHT |
---|
29 | |
---|
30 | Copyright (C) 2000,2001 MandrakeSoft <warly@mandrakesoft.com> |
---|
31 | |
---|
32 | This program is free software; you can redistribute it and/or modify |
---|
33 | it under the terms of the GNU General Public License as published by |
---|
34 | the Free Software Foundation; either version 2, or (at your option) |
---|
35 | any later version. |
---|
36 | |
---|
37 | This program is distributed in the hope that it will be useful, |
---|
38 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
39 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
40 | GNU General Public License for more details. |
---|
41 | |
---|
42 | You should have received a copy of the GNU General Public License |
---|
43 | along with this program; if not, write to the Free Software |
---|
44 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
45 | |
---|
46 | =cut |
---|
47 | use vars qw(%functions $config); |
---|
48 | |
---|
49 | # need to do it to have its address |
---|
50 | #my %functions = (); |
---|
51 | # [ function name, matching regexp, [arguments list (same as above)]] |
---|
52 | |
---|
53 | $functions{disc} = [ |
---|
54 | [ "", "disc", 5, "[options] <disc config number> <size> <serial> <longname> <label>", "disc configuration file parameters", |
---|
55 | sub { my ($cd, $name, $size, $serial, $longname, $label) = @_; |
---|
56 | $size = convert_size($size); |
---|
57 | log_("disc: disc $cd size $size\n", $config->{verbose}, $config->{LOG},3); |
---|
58 | $config->{disc}[$cd]{size} = $size; |
---|
59 | $config->{disc}[$cd]{serial} = substr $serial, 0, 128; |
---|
60 | $config->{disc}[$cd]{longname} = $longname; |
---|
61 | $config->{disc}[$cd]{label} = substr $label, 0, 32; |
---|
62 | if (!$config->{disc}[$cd]{appname}) { $config->{disc}[$cd]{appname} = substr $longname, 0, 128 } |
---|
63 | 1 |
---|
64 | }, "Setting disc configuration" ], |
---|
65 | [ "d", "discnumber", 1 , "<disc real number>", "Set the real disc number", |
---|
66 | sub { my ($cd, $discnb) = @_; |
---|
67 | log_("disc: disc $cd setting real disc number to $discnb\n", $config->{verbose}, $config->{LOG},3); |
---|
68 | $config->{disc}[$cd]{name} = $discnb; |
---|
69 | }, "Setting the real disc number" ], |
---|
70 | [ "p", "publisher", 1 , "<disc publisher id>", "Set the disc publisher", |
---|
71 | sub { my ($cd, $publisher) = @_; |
---|
72 | log_("disc: disc $cd setting publisher as $publisher\n", $config->{verbose}, $config->{LOG},3); |
---|
73 | $config->{disc}[$cd]{Publisher} = substr $publisher, 0, 128; |
---|
74 | }, "Setting the publisher ID flag" ] |
---|
75 | ]; |
---|
76 | |
---|
77 | $functions{list} = [ |
---|
78 | [ "", "list", -1, "[options] <list config number> <list config file 1> <list config file 2> ... <list config file n>", "list configuration file parameters", |
---|
79 | sub { |
---|
80 | my ($list, undef, @list_file) = @_; |
---|
81 | log_("list: list $list file list @list_file\n", $config->{verbose}, $config->{LOG},3); |
---|
82 | push @{$config->{list}[$list]{filelist}}, @list_file; |
---|
83 | 1 |
---|
84 | }, "Setting list configuration" ] |
---|
85 | ]; |
---|
86 | |
---|
87 | $functions{rpmlist} = [ |
---|
88 | [ "", "rpmlist", 0, "[options]", "rpm list associated with a list", |
---|
89 | sub { |
---|
90 | my ($list) = @_; |
---|
91 | push @{$config->{list}[$list]{packages}}, { }; |
---|
92 | 1 |
---|
93 | }, "Setting rpm list" ], |
---|
94 | [ "b", "binaries", -1, "<rpm path 1> <rpm path 2> ... <rpm path n>", "rpm list associated with a list", |
---|
95 | sub { |
---|
96 | my ($list, undef, @rpms) = @_; |
---|
97 | my $idx = $#{$config->{list}[$list]{packages}}; |
---|
98 | push @{$config->{list}[$list]{packages}[$idx]{rpm}}, @rpms; |
---|
99 | 1 |
---|
100 | }, "Setting rpm list" ], |
---|
101 | [ "d", "dynamic", -1, "<disc1/dir1> <disc2/dir2> ... <discn/dirn>", "dynamic rpm list based on disc generated by this config file", |
---|
102 | sub { |
---|
103 | my ($list, undef, @rpms) = @_; |
---|
104 | foreach my $l (@rpms) { |
---|
105 | my ($cd, $rep) = $l =~ /(\d+)\/(\S+)/ or log_("ERROR rpmlist: $l is not a valid <disc>/<rep> dynamic list definition\n", $config->{verbose}, $config->{LOG}, 1) and next; |
---|
106 | $config->{list}[$list]{prelist} = [ [ ".*", { regexp => 1 } ] ]; |
---|
107 | push @{$config->{list}[$list]{virtual}}, { disc => $cd, repname => $rep }; |
---|
108 | } |
---|
109 | 1 |
---|
110 | }, "Setting dynamic rpm list" ], |
---|
111 | [ "s", "sources", -1, "<source path 1> <source path 2> ... <source path n>", "rpm list associated with a list", |
---|
112 | sub { |
---|
113 | my ($list, undef, @srpms) = @_; |
---|
114 | my $idx = $#{$config->{list}[$list]{packages}}; |
---|
115 | push @{$config->{list}[$list]{packages}[$idx]{srpm}}, @srpms; |
---|
116 | 1 |
---|
117 | }, "Setting source rpm list" ], |
---|
118 | ]; |
---|
119 | |
---|
120 | $functions{dir} = |
---|
121 | [ |
---|
122 | [ "", "dir",2, "<directory name> <directory location>", "Set directory name", |
---|
123 | sub { my ($cd, $fn, $repname, $reploc) = @_; |
---|
124 | my @a = ("dir", { repname => $repname, reploc => $reploc }); |
---|
125 | $config->{disc}[$cd]{function}{data}{dir}{$repname} and log_("WARNING: disc $cd: duplicate directory $repname ($reploc)\n", $config->{verbose}, $config->{LOG}, 3); |
---|
126 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
127 | $config->{disc}[$cd]{function}{data}{dir}{$repname} = $reploc; |
---|
128 | log_("dir: disc $cd rep $repname ($reploc)\n", $config->{verbose}, $config->{LOG}, 3); |
---|
129 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
130 | 1 |
---|
131 | }, "Setting directory" ] |
---|
132 | ]; |
---|
133 | # |
---|
134 | # generic options |
---|
135 | # |
---|
136 | # source => source dir |
---|
137 | # |
---|
138 | # done => done |
---|
139 | # |
---|
140 | |
---|
141 | $functions{generic} = |
---|
142 | [ |
---|
143 | # 0 |
---|
144 | ["", "generic", -2, "<directory name> <list1 name> <list2 name> ... <listn name>", "Copy rpms from one list or several lists to a directory. List is either a predefined list number of the configuration file or an other disc directory (e.g. 13/rpms2)", |
---|
145 | sub { |
---|
146 | my ($cd, $fn, $repname, @lists) = @_; |
---|
147 | $config->{disc}[$cd]{function}{data}{dir}{$repname} or log_("ERROR: disc $cd: $repname not defined\n", $config->{verbose}, $config->{LOG}, 0); |
---|
148 | my @a = ("generic", { repname => $repname }); |
---|
149 | foreach my $list (@lists) { |
---|
150 | if ($list =~ /^\d+$/) { |
---|
151 | $config->{list}[$list] or log_("ERROR: lists $list does not exist, ignoring\n", $config->{verbose}, $config->{LOG}, 0) and next; |
---|
152 | push @{$a[1]{lists}}, $list; |
---|
153 | } else { |
---|
154 | log_("ERROR generic: $list is not a valid list name for rep $cd/$repname\n", $config->{verbose}, $config->{LOG}, 0) and next; |
---|
155 | } |
---|
156 | } |
---|
157 | log_("generic: disc $cd repname $repname lists @lists\n", $config->{verbose}, $config->{LOG}, 3); |
---|
158 | ref $a[1]{lists} or log_("ERROR generic: $cd/$repname has no valid list, ignoring\n", $config->{verbose}, $config->{LOG}, 0) and return; |
---|
159 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
160 | push @{$config->{disc}[$cd]{function}{data}{generic}{$repname}}, \@a; |
---|
161 | push @{$config->{disc}[$cd]{fastgeneric}}, \@a; |
---|
162 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
163 | 1 |
---|
164 | }, "Copying rpms to directory"], |
---|
165 | # 1 |
---|
166 | ["s", "source", [ |
---|
167 | [ "", "source", 0, "", "Source mode configuration", |
---|
168 | sub { my ($tmp) = @_; |
---|
169 | $tmp->[0]{source} = 1; |
---|
170 | }, "Source mode" ], |
---|
171 | # 2002 03 14 deprecated |
---|
172 | # [ "p", "priority", 1, "<priority>", "Set the repository priority", sub { my ($tmp, $prio) = @_; $tmp->[0]{priority} = $prio}, "Setting source repository priority"] |
---|
173 | ], "[options]", "Source mode setting", |
---|
174 | sub { my ($cd, $fn, $options) = @_; |
---|
175 | foreach (keys %$options) { $config->{disc}[$cd]{function}{list}[$fn][1]{$_} = $options->{$_} } |
---|
176 | 1 |
---|
177 | }, "Source mode option configuration"], |
---|
178 | [ "", "synthesis", 0, "", "Add synthesis file in the repository", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{synthesis} = 1 }, "Setting synthesis tag" ], |
---|
179 | [ "", "hdlist", 0, "", "Add hdlist file in the repository", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{hdlist} = 1 }, "Setting hdlist tag" ], |
---|
180 | [ "l", "limit", [ |
---|
181 | [ "", "limit", 1, "<limit>", "Source mode configuration", |
---|
182 | sub { my ($tmp, $limit) = @_; |
---|
183 | $tmp->[0]{limit} = 1; |
---|
184 | $tmp->[0]{value} = $limit; |
---|
185 | }, "Limit mode" ], |
---|
186 | [ "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" ] |
---|
187 | |
---|
188 | ], "[options] <limit>", "Limit the space of this directory on the disc", |
---|
189 | sub { my ($cd, $fn, $options) = @_; |
---|
190 | $config->{disc}[$cd]{function}{list}[$fn][1]{limit} = $options |
---|
191 | }, "Setting limit option" ], |
---|
192 | [ "", "nodeps", 0, "", "Do not include deps", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{nodeps} = 1 }, "Setting nodeps flag for this generic rep" ] |
---|
193 | ]; |
---|
194 | |
---|
195 | |
---|
196 | # |
---|
197 | # installation data |
---|
198 | # |
---|
199 | $functions{installation} = |
---|
200 | [ |
---|
201 | # 0 |
---|
202 | [ "", "installation", 0, "", "Preparing the installation directory and dependencies files", |
---|
203 | sub { my ($cd, $fn) = @_; |
---|
204 | my @a = ('installation', { }); |
---|
205 | ref $config->{disc}[$cd]{function}{data}{installation} and log_("ERROR: disc $cd: duplicate installation procedure, ignored\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
206 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
207 | $config->{disc}[$cd]{function}{data}{installation} = \@a; |
---|
208 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
209 | 1 |
---|
210 | }, "Setting up installation files" ], |
---|
211 | # 1 |
---|
212 | [ "b", "bootimg", 1, "<boot image>", "boot image for the cd", sub { my ($cd, $fn, $img) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{bootimg} = $img; 1 }, "Setting boot image" ], |
---|
213 | # 2 |
---|
214 | [ "c", "compss", 1, "<compsUser file>", "Choose alternative compssUser file", sub { my ($cd, $fn, $compss) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{compssUsers} = $compss; 1 }, "Setting alternative compssUser file" ], |
---|
215 | # 3 |
---|
216 | [ "f", "fixed", [ |
---|
217 | ["", "fixed", -1, "<repository> <extra RPMS directory 1> <extra RPMS directory 2> ... <extra RPMS directory n>", "Fixed repository option configuration", |
---|
218 | sub { my ($tmp, @arg) = @_; |
---|
219 | $tmp->[0]{fixed} = 1; |
---|
220 | push @$tmp, @arg; |
---|
221 | 1 |
---|
222 | }, "Setting fixed option arguments"], |
---|
223 | ["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"], |
---|
224 | ["", "nodeps", 0, "", "Do not handle other discs dependencies", sub { my ($tmp) = @_; $tmp->[0]{nodeps} = 1; 1 }, "Setting nodeps mode"], |
---|
225 | ["", "update", 0, "", "Update mode, update already done packages", sub { my ($tmp) = @_; $tmp->[0]{update} = 1; 1 }, "Setting update mode"] |
---|
226 | ], "[options] <fixed dir 1> <fixed dir 2> ... <fixed dir n>", "repositories that must not be computed but integrated in the installation group", |
---|
227 | sub { my ($cd, $fn, $options, @fixed) = @_; |
---|
228 | get_rpmsdir('rpmsdir', $cd, $fn, \@fixed, $options); |
---|
229 | $config->{disc}[$cd]{function}{list}[$fn][1]{fixed} = 1; |
---|
230 | 1 }, "Setting fixed option" ], |
---|
231 | # 4 |
---|
232 | [ "l", "lang", 1, "<languages to include>", "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" ], |
---|
233 | # 5 |
---|
234 | [ "i", "installdir", 1, "<installation directory source>", "Installation directory source", sub { my ($cd, $fn, $dir) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{install} = $dir; 1 }, "Setting install source directory" ], |
---|
235 | # 6 |
---|
236 | [ "", "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" ], |
---|
237 | # 7 |
---|
238 | [ "", "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" ], |
---|
239 | # 8 |
---|
240 | [ "o", "sortweight", 1, "<list of respective ordering weight (size,dependencies,rpmsrate)>", "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" ], |
---|
241 | # 9 |
---|
242 | [ "r", "rpmsrate", 1, "<rpmsrate file>", "Choose alternative rpmsrate", sub { my ($cd, $fn, $rpmsrate) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{rpmsrate} = $rpmsrate }, "Setting alternative rpmsrate file" ], |
---|
243 | # 10 |
---|
244 | [ "t", "tag name", 1, "<tag name>", "Tag added to the VERSION file", sub { my ($cd, $fn, $tag) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{tag} = $tag }, "Setting the tag name" ], |
---|
245 | # 11 |
---|
246 | [ "", "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" ], |
---|
247 | # 12 |
---|
248 | [ "", "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" ], |
---|
249 | # 13 |
---|
250 | [ "", "isolinux", 0, "", "Isolinux mode", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{isolinux} = 1 }, "Build an isolinux install" ], |
---|
251 | # 14 |
---|
252 | [ "", "synthesis", 0, "", "Add synthesis file in the repository", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{synthesis} = 1 }, "Setting synthesis tag" ], |
---|
253 | # 15 |
---|
254 | [ "", "sequential", 0, "", "Build disc in a sequential way", sub { my ($cd, $fn) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{sequential} = 1 }, "Setting sequential tag" ], |
---|
255 | # 16 |
---|
256 | # FIXME oem mode never tested nor debugged |
---|
257 | [ "", "oem", [ |
---|
258 | ["", "oem", 1, "[options] <rpms dir>", "OEM mode configuration", |
---|
259 | sub { my ($tmp, @arg) = @_; |
---|
260 | $tmp->[0]{oem} = 1; |
---|
261 | push @$tmp, @arg; |
---|
262 | 1 |
---|
263 | }, "Setting oem option arguments"], |
---|
264 | ["d", "dir", -1, "<installation dir> <root dir 1> ... <root dir n>", "Create OEM disc based on existing directories list", |
---|
265 | sub { |
---|
266 | my ($tmp, $instdir, @dir) = @_; |
---|
267 | $tmp->[0]{file} and log_("ERROR installation oem: could not use file and dir option in the same time, ignoring dir\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
268 | log_("dir $instdir @dir\n", $config->{verbose}, $config->{LOG}, 3); |
---|
269 | $tmp->[0]{instdir} = $instdir; |
---|
270 | $tmp->[0]{dir} = \@dir; |
---|
271 | 1 }, "Selecting directories"], |
---|
272 | ["h", "hdlists", 1, "<hdlists to include>", "Select hdlists to include (all if omitted)", sub { my ($tmp, $hdlists) = @_; $tmp->[0]{hdlists} = $hdlists; 1 }, "Selecting hdlists to include"], |
---|
273 | ["f", "file", 2, "<script file> <installation disc>", "Script file describing the discs (generated with printscript)", |
---|
274 | sub { |
---|
275 | my ($tmp, $file, $instdisc) = @_; |
---|
276 | $tmp->[0]{dir} and log_("ERROR installation oem: could not use file and dir option in the same time, ignoring file\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
277 | $tmp->[0]{file} = $file; |
---|
278 | $tmp->[0]{instdisc} = $instdisc; 1 |
---|
279 | }, "Setting update mode"], |
---|
280 | ["l", "listfile", 1, "<list of package to choose>", "Choose an alternative method to select package to select in OEM mode (default is to use packages with rate greater than 2 in rpmsrate ", sub { my ($tmp, $file) = @_; $tmp->[0]{file} = $file; 1 }, "Selecting list file"], |
---|
281 | ["n", "norebuild", 0, "", "Do not rebuild hdlists", sub { my ($tmp, $file) = @_; $tmp->[0]{norebuild} = 1; 1 }, "Setting no rebuilding flag"], |
---|
282 | ["r", "rpmsrate", 1, "<rpmsrate file>", "Rpmsrate file to use for OEM mode (use the installation one if omitted)", sub { my ($tmp, $rpmsrate) = @_; $tmp->[0]{rpmsrate} = $rpmsrate; 1 }, "Setting rpmsrate file OEM file"] |
---|
283 | ], "[options] <rpms dir>", "OEM mode", |
---|
284 | sub { my ($cd, $fn, $options, $rpmsdir) = @_; |
---|
285 | $config->{disc}[$cd]{function}{list}[$fn][1]{oem} = $options; |
---|
286 | if ($options->{dir}) { |
---|
287 | my $list = @{$config->{list}}; |
---|
288 | $config->{list}[$list]{prelist} = [ |
---|
289 | [ "INSTALL", { section => 1, force => 1 } ], |
---|
290 | [ "SERVER", { section => 1, regexp => 1, exclude => 1 } ], |
---|
291 | [ ".*", { section => 4, regexp => 1 } ] |
---|
292 | ]; |
---|
293 | log_("installation oem: adding list $list for OEM mode\n", $config->{verbose}, $config->{LOG}, 3); |
---|
294 | my $hdlists = "$options->{instdir}/Mandrake/base/hdlists"; |
---|
295 | local *A; open A, $hdlists or die "ERROR oem: could not open hdlists $hdlists file"; |
---|
296 | my $i; |
---|
297 | while (<A>) { |
---|
298 | my ($hdlist, $rep, $mname) = /(\S+)\s+(\S+)\s+(.*)/ or next; |
---|
299 | log_("$i -- $hdlist -- $rep -- $options->{dir}[$i]\n", $config->{verbose}, $config->{LOG}, 4); |
---|
300 | $options->{dir}[$i] or last; |
---|
301 | push @{$options->{hdlist}}, [ "$options->{instdir}/Mandrake/base/", $hdlist, $rep, $mname ]; |
---|
302 | push @{$config->{list}[$list]{packages}}, [ "$options->{dir}[$i]/$rep" ]; |
---|
303 | $i++ |
---|
304 | } |
---|
305 | for ($rpmsdir) { |
---|
306 | my ($cdrep, $repname) = m,^(\d+)/([^/]+)$,; |
---|
307 | my $gfn = @{$config->{disc}[$cdrep]{function}{list}}; |
---|
308 | log_("installation oem: adding function $gfn for generic oem packages on cd $cdrep\n", $config->{verbose}, $config->{LOG}, 4); |
---|
309 | $functions{generic}[0][5]($cdrep, $gfn, $repname, $list); |
---|
310 | if ($cd == $cdrep) { |
---|
311 | # FIXME trick to have this generic function done before the installation |
---|
312 | my $a = pop @{$config->{disc}[$cdrep]{steps}}; |
---|
313 | unshift @{$config->{disc}[$cdrep]{steps}}, $a |
---|
314 | } |
---|
315 | push @{$config->{disc}[$cd]{function}{list}[$fn][1]{rpmsdir}}, [ $list, $cdrep, $repname, { oem => 1 } ]; |
---|
316 | } |
---|
317 | } elsif ($options->{file}) { |
---|
318 | my $oemconfig; |
---|
319 | config($options->{file}, $oemconfig, \%functions); |
---|
320 | my ($discsFiles) = readBatchFile($options->{file}) or log_("ERROR installation oem: cannot read script file $options->{file}\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
321 | my $list = @{$config->{list}}; |
---|
322 | log_("installation oem: adding list $list for OEM mode\n", $config->{verbose}, $config->{LOG}, 3); |
---|
323 | foreach (@{$config->{list}}) { |
---|
324 | $_ or next; |
---|
325 | push @{$config->{list}[$list]{packages}}, @{$_->{packages}} |
---|
326 | } |
---|
327 | my $gfn = @{$config->{disc}[$cd]{function}{list}}; |
---|
328 | $config->{list}[$list]{prelist} = [[ ".*", { section => 3, regexp => 1 } ]]; |
---|
329 | log_("installation oem: adding function $gfn for generic oem packages\n", $config->{verbose}, $config->{LOG}, 3); |
---|
330 | $functions{generic}[0][5]($cd, $gfn, "rpms", $list); |
---|
331 | } else { |
---|
332 | log_("ERROR installation oem: no disc to build OEM on (either file or dir option are needed)\n", $config->{verbose}, $config->{LOG}); |
---|
333 | $config->{disc}[$cd]{function}{list}[$fn][1]{oem} = 0; |
---|
334 | return 0 |
---|
335 | } |
---|
336 | 1 }, "Setting oem option" ], |
---|
337 | # 17 |
---|
338 | [ "s", "sources", -1, "<srpms directory name 1> <srpms directory name 2> ... <srpms directory name n>", "Select the sources list where to put packages", |
---|
339 | sub { my ($cd, $fn, @sources) = @_; |
---|
340 | get_rpmsdir('srpmsdir', $cd, $fn, \@sources); |
---|
341 | $config->{disc}[$cd]{function}{list}[$fn][1]{sources} = 1; |
---|
342 | 1 }, "Setting fixed option" ], |
---|
343 | # 18 |
---|
344 | [ "d", "rpmsdir", -1, "<rpms directory 1 cd/rpms directory 1 name/rpms directory 1 list> <rpms directory 2 cd/rpms directory 2 name/rpms directory 2 list> ... <rpms directory n cd/rpms directory n name/rpms directory n list>", "Select rpms dir to take into account", |
---|
345 | sub { my ($cd, $fn, @rpms) = @_; |
---|
346 | get_rpmsdir('rpmsdir', $cd, $fn, \@rpms); |
---|
347 | 1 |
---|
348 | }, "Setting rpms dir" ], |
---|
349 | # 19 |
---|
350 | [ "", "boot_medium", 1, "<boot medium number>", "select alternatives boot medium", |
---|
351 | sub { my ($cd, $fn, $nb) = @_; |
---|
352 | $config->{disc}[$cd]{function}{list}[$fn][1]{boot_medium} = $nb; |
---|
353 | 1 |
---|
354 | }, "Setting rpms dir" ] ]; |
---|
355 | # |
---|
356 | # |
---|
357 | # advertising option |
---|
358 | # |
---|
359 | # img |
---|
360 | # lang (new advertising mode in 8.2 deprecates this option) |
---|
361 | # |
---|
362 | |
---|
363 | $functions{advertising} = |
---|
364 | [ |
---|
365 | [ "", "advertising", -1, "<picture 1> <picture 2> ... <picture n>", "Setting the advertising pictures used by the installation", |
---|
366 | sub { my ($cd, $fn, @img) = @_; |
---|
367 | my @a = ('advertising', { img => \@img }); |
---|
368 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
369 | push @{$config->{disc}[$cd]{function}{data}{advertising}}, \@a; |
---|
370 | push @{$config->{disc}[$cd]{steps}}, \@a |
---|
371 | }, "Setting the advertising pictures" ], |
---|
372 | [ "l", "lang", 1, "<language>", "Set the advertising picture language", sub { my ($cd, $fn, $lang) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{lang} = $lang; 1 }, "Setting the picture language" ] |
---|
373 | ]; |
---|
374 | |
---|
375 | # |
---|
376 | # cdcom data |
---|
377 | # |
---|
378 | # dir |
---|
379 | # |
---|
380 | # source |
---|
381 | # |
---|
382 | $functions{cdcom} = |
---|
383 | [ |
---|
384 | [ "", "cdcom", 2, "<directory name> <disc directory location>", "Commercial disc", |
---|
385 | sub { my ($cd, $fn, $dir, $source) = @_; |
---|
386 | my @a = ('cdcom', { dir => $dir, source => $source }); |
---|
387 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
388 | push @{$config->{disc}[$cd]{function}{data}{cdcom}}, \@a; |
---|
389 | my $list = @{$config->{list}}; |
---|
390 | log_("cdcom: disc $cd adding list $list for $source/Mandrake/RPMS\n", $config->{verbose}, $config->{LOG}, 3); |
---|
391 | $config->{list}[$list]{packages} = [ { rpm => [ "$source/Mandrake/RPMS" ] } ]; |
---|
392 | # $config->{list}[$list]{prelist} = [[ ".*", { regexp => 1 }]]; |
---|
393 | $config->{list}[$list]{done} = 1; |
---|
394 | $config->{list}[$list]{nosize} = 1; |
---|
395 | push @{$config->{disc}[$cd]{fastgeneric}}, [ '', { repname => $dir , lists => [ $list ] } ]; |
---|
396 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
397 | 1 |
---|
398 | }, "Configuring a commercial disc" ], |
---|
399 | [ "d", "dest", 1, "<destination on the disc>", "Select the destination directory on the disc", sub { my ($cd, $fn, $dest) = @_; $config->{disc}[$cd]{function}{list}[$fn][1]{dest} = $dest; 1 }, "Selecting destination directory" ] |
---|
400 | ]; |
---|
401 | # |
---|
402 | # cp |
---|
403 | # |
---|
404 | $functions{cp} = |
---|
405 | [ |
---|
406 | [ "", "cp", 2, "<file source> <file destination>", "Copy", |
---|
407 | sub { my ($cd, $fn, $src, $dest) = @_; |
---|
408 | my @a = ('cp', { src => $src, dest => $dest }); |
---|
409 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
410 | push @{$config->{disc}[$cd]{function}{data}{cp}}, \@a; |
---|
411 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
412 | 1 |
---|
413 | }, "Copying files" ] |
---|
414 | ]; |
---|
415 | # |
---|
416 | # boot |
---|
417 | # |
---|
418 | $functions{boot} = |
---|
419 | [ |
---|
420 | # 0 |
---|
421 | [ "", "boot", 0, "<options> <files or dir to copy 1> <files or dir to copy 2> .. <files or dir to copy 3>", "Boot parameters and files", |
---|
422 | sub { my ($cd, $fn) = @_; |
---|
423 | my @a = ('boot', { }); |
---|
424 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
425 | push @{$config->{disc}[$cd]{function}{data}{boot}}, \@a; |
---|
426 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
427 | 1 |
---|
428 | }, "Setting boot parameters" |
---|
429 | ], |
---|
430 | # 1 |
---|
431 | [ "", "isolinux", [ |
---|
432 | ["", "isolinux", 1, "<isolinux directory>", "Create an isolinux bootable disc", |
---|
433 | sub { my ($tmp, @args) = @_; |
---|
434 | $tmp->[0]{isolinux} = 1; |
---|
435 | push @$tmp, @args |
---|
436 | }, "Setting an isolinux boot disc"], |
---|
437 | ], "<options> <isolinux directory>", "isolinux boot disc", |
---|
438 | sub { my ($cd, $fn, $options, $dir) = @_; |
---|
439 | foreach (@{ $config->{disc}[$cd]{function}{data}{boot} }) { |
---|
440 | ref $_->[1]{isolinux} and log_("ERROR: disc $cd: duplicate isolinux boot image, ignored\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
441 | } |
---|
442 | $config->{disc}[$cd]{function}{list}[$fn][1]{isolinux} = [$dir, $options] |
---|
443 | }, "Setting isolinux image" |
---|
444 | ], |
---|
445 | #2 |
---|
446 | [ "b", "bootimg", [ |
---|
447 | [ "", "bootimg", 1, "<boot image name>", "set boot image name", |
---|
448 | sub { my ($tmp, @args) = @_; |
---|
449 | $tmp->[0]{bootimg} = 1; |
---|
450 | push @$tmp, @args |
---|
451 | }, "setting boot image name" |
---|
452 | ], |
---|
453 | [ "d", "dir", 1, "<directory>", "duplicate the boot image in directory and put it first in the ISO", |
---|
454 | sub { my ($tmp, $dir) = @_; $tmp->[0]{dir} = $dir }, "" |
---|
455 | ] |
---|
456 | ], "<options> <boot image>", "Create a bootable iso with given image", |
---|
457 | sub { my ($cd, $fn, $options, $img) = @_; |
---|
458 | foreach (@{ $config->{disc}[$cd]{function}{data}{boot} }) { |
---|
459 | ref $_->[1]{bootimg} and log_("ERROR: disc $cd: duplicate boot image, ignored\n", $config->{verbose}, $config->{LOG}) and return 0; |
---|
460 | } |
---|
461 | $config->{disc}[$cd]{function}{list}[$fn][1]{bootimg} = [$img, $options] |
---|
462 | }, "Setting boot image options" |
---|
463 | ], |
---|
464 | #3 |
---|
465 | [ "d", "dest", [ |
---|
466 | [ "", "dest", -2, "<destination> <file 1> <file 2> .. <file n>", "Set options for files copied to a given destination", |
---|
467 | sub { my ($tmp, @args) = @_; |
---|
468 | $tmp->[0]{dest} = $args[0]; |
---|
469 | push @$tmp, @args |
---|
470 | |
---|
471 | }, "Setting dest options" ], |
---|
472 | [ "f", "first", 0 , "", "Put this files first in the ISO", sub { my ($tmp) = @_; $tmp->[0]{first} = 1; 1 }, "Setting first flag for files" ] |
---|
473 | ], "[options] <destination> <files 1> <files 2> .. <files n>", "Copy files to a special destination", |
---|
474 | sub { my ($cd, $fn, $options, @files) = @_; |
---|
475 | foreach (@files) { |
---|
476 | push @{$config->{disc}[$cd]{function}{list}[$fn][1]{files}}, [ $_, $options ] |
---|
477 | } |
---|
478 | }, |
---|
479 | "Setting isolinux boot file" |
---|
480 | ], |
---|
481 | #4 |
---|
482 | [ "f", "files", -1, "<file 1> <file 2> <file 3>", "Files to copy", |
---|
483 | sub { my ($cd, $fn, @files) = @_; |
---|
484 | foreach (@files) { |
---|
485 | push @{$config->{disc}[$cd]{function}{list}[$fn][1]{files}}, [ $_ ] |
---|
486 | }; 1 |
---|
487 | }, "files to copy" |
---|
488 | ], |
---|
489 | #5 |
---|
490 | [ "", "first", -1, "<file 1> <file 2> <file 3>", "Set first flag to put files in the beginning of the ISO", |
---|
491 | sub { my ($cd, $fn, @files) = @_; |
---|
492 | foreach (@files) { |
---|
493 | push @{$config->{disc}[$cd]{function}{list}[$fn][1]{files}}, [ $_, { first => 1 } ] |
---|
494 | } |
---|
495 | }, "Setting first flag" |
---|
496 | ], |
---|
497 | #5 |
---|
498 | [ "", "oem", 0, "", "Set default boot to oem mode", |
---|
499 | sub { my ($cd, $fn) = @_; |
---|
500 | $config->{disc}[$cd]{function}{list}[$fn][1]{oem} = 1 |
---|
501 | }, "Setting oem boot mode" |
---|
502 | ], |
---|
503 | |
---|
504 | ]; |
---|
505 | |
---|
506 | # |
---|
507 | # clone |
---|
508 | # |
---|
509 | $functions{clone} = |
---|
510 | [ |
---|
511 | # 0 |
---|
512 | [ "", "clone", 1, "<disc to clone>", "Clone the given disc", |
---|
513 | sub { my ($cd, $fn, $disc) = @_; |
---|
514 | my @a = ('clone', { disc => $disc }); |
---|
515 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
516 | push @{$config->{disc}[$cd]{function}{data}{clone}}, \@a; |
---|
517 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
518 | 1 |
---|
519 | }, "Setting clone parameters" |
---|
520 | ], |
---|
521 | # 1 |
---|
522 | [ "i", "include", -2, "<directory name 1> <directory path 1> <directory name 2> <directory path 2> ... <directory name n> <directory path n>", "include declaration of copied directory", |
---|
523 | sub { my ($cd, $fn, @dir) = @_; |
---|
524 | my $list = @{$config->{list}}; |
---|
525 | while (@dir) { |
---|
526 | my $rpmdir = shift @dir; |
---|
527 | my $path = shift @dir or last; |
---|
528 | $config->{disc}[$cd]{function}{data}{dir}{$rpmdir} = $path; |
---|
529 | $config->{disc}[$cd]{function}{list}[$fn][1]{rpmsdir} = $path; |
---|
530 | log_("clone: disc $cd adding list $list for virtual rep $rpmdir path $path\n", $config->{verbose}, $config->{LOG},3); |
---|
531 | $config->{list}[$list]{virtual} = [ { disc => $cd, repname => $rpmdir } ]; |
---|
532 | push @{$config->{disc}[$cd]{fastgeneric}}, [ '', { repname => $rpmdir, lists => [ $list ] } ]; |
---|
533 | } |
---|
534 | $config->{list}[$list]{done} = 1; |
---|
535 | 1 |
---|
536 | }, "Setting directory name and path parameters" |
---|
537 | ] |
---|
538 | # [ "d", "delete", -1, "<function 1 nb to delete> <function 1 nb to delete> ... <function n nb to delete>", "delete these functions in the cloned disc", |
---|
539 | # sub { my ($cd, $fn,@to_del) = @_; |
---|
540 | # $config->{disc}[$cd]{function}{list}[$fn][1]{to_del} = \@to_del; |
---|
541 | # 1 |
---|
542 | # }, "Setting delete parametes" |
---|
543 | # ] |
---|
544 | ]; |
---|
545 | |
---|
546 | # |
---|
547 | # rm |
---|
548 | # |
---|
549 | $functions{rm} = |
---|
550 | [ |
---|
551 | # 0 |
---|
552 | [ "", "rm", -1, "<disc to rm>", "Clone the given disc", |
---|
553 | sub { my ($cd, $fn, @files) = @_; |
---|
554 | my @a = ('rm', { files => \@files }); |
---|
555 | $config->{disc}[$cd]{function}{list}[$fn] = \@a; |
---|
556 | push @{$config->{disc}[$cd]{function}{data}{files}}, \@a; |
---|
557 | push @{$config->{disc}[$cd]{steps}}, \@a; |
---|
558 | 1 |
---|
559 | }, "Setting rm parameters" |
---|
560 | ] |
---|
561 | ]; |
---|
562 | |
---|
563 | sub new { |
---|
564 | my ($class, $conf) = @_; |
---|
565 | $config = $conf; |
---|
566 | bless { |
---|
567 | config => $conf, |
---|
568 | functions => \%functions |
---|
569 | }, $class; |
---|
570 | } |
---|
571 | |
---|
572 | sub get_rpmsdir { |
---|
573 | my ($type, $cd, $fn, $rpms, $opts) = @_; |
---|
574 | foreach (@$rpms) { |
---|
575 | my ($opt, $cdrep, $repname, $list) = m,(noauto:)?(\d+)/([^/]+)(?:/(\d+))?,; |
---|
576 | chop $opt; |
---|
577 | my %options; |
---|
578 | foreach (split ',', $opt) { $options{$_} = 1 } |
---|
579 | foreach (keys %$opts) { $options{$_} = $opts->{$_} } |
---|
580 | push @{$config->{disc}[$cd]{function}{list}[$fn][1]{$type}}, [ $list, $cdrep, $repname, \%options ] |
---|
581 | } |
---|
582 | } |
---|
583 | |
---|
584 | sub template { |
---|
585 | my ($class, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discFile) = @_; |
---|
586 | if (!$fixed) { |
---|
587 | my $size; |
---|
588 | if ($nolive) { |
---|
589 | return $size |
---|
590 | } else { |
---|
591 | |
---|
592 | } |
---|
593 | } elsif ($fixed == 1) { |
---|
594 | my $mkiso; |
---|
595 | if ($nolive) { |
---|
596 | } else { |
---|
597 | |
---|
598 | } |
---|
599 | } elsif ($fixed == 2) { |
---|
600 | my $mkiso; |
---|
601 | if ($nolive) { |
---|
602 | } else { |
---|
603 | |
---|
604 | } |
---|
605 | } |
---|
606 | } |
---|
607 | |
---|
608 | sub clone { |
---|
609 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discFile) = @_; |
---|
610 | my $graft = $totgraft->{$cdnum}; |
---|
611 | my $disc_src = $fct->[1]{disc}; |
---|
612 | if ($fixed == 0) { |
---|
613 | if ($nolive) { |
---|
614 | if ($fct->[1]{full_copy}) { |
---|
615 | log_("clone: full copy of disc $disc_src nolive mode\n", $config->{verbose}, $config->{LOG},2); |
---|
616 | if ($totgraft->{$disc_src}) { |
---|
617 | log_("clone: getting disc from current build\n", $config->{verbose}, $config->{LOG},3); |
---|
618 | $graft = $totgraft->{$disc_src} |
---|
619 | } elsif (-d "$dir/$disc_src") { |
---|
620 | log_("clone: getting disc from filesystem\n", $config->{verbose}, $config->{LOG},3); |
---|
621 | $graft->{"/"}{"$dir/$disc_src"} = 1 |
---|
622 | } else { |
---|
623 | log_("ERROR clone: source disc not available\n", $config->{verbose}, $config->{LOG},3); |
---|
624 | } |
---|
625 | } |
---|
626 | } else { |
---|
627 | if ($fct->[1]{full_copy}) { |
---|
628 | log_("clone: full copy of disc $disc_src\n", $config->{verbose}, $config->{LOG},2); |
---|
629 | if (-d "$dir/$disc_src") { |
---|
630 | log_("clone: getting disc from filesystem\n", $config->{verbose}, $config->{LOG},3); |
---|
631 | $graft->{"/"}{"$dir/$disc_src"}; |
---|
632 | cpal("$dir/$disc_src/", "$dir/$cdnum"); |
---|
633 | } else { |
---|
634 | log_("ERROR clone: source disc not available\n", $config->{verbose}, $config->{LOG},3); |
---|
635 | } |
---|
636 | } |
---|
637 | } |
---|
638 | } |
---|
639 | 1 |
---|
640 | } |
---|
641 | |
---|
642 | sub rm { |
---|
643 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discFile) = @_; |
---|
644 | my $graft = $totgraft->{$cdnum}; |
---|
645 | my $files = $fct->[1]{files}; |
---|
646 | # use File::Find; |
---|
647 | if ($fixed == 0) { |
---|
648 | if ($nolive) { |
---|
649 | # FIXME this does not really works in no live mode (exclude files does not work with mkisofs properly) |
---|
650 | my $size; |
---|
651 | foreach my $r (@$files) { |
---|
652 | log_("rm: trying $r\n", $config->{verbose}, $config->{LOG},2); |
---|
653 | $graft->{$r} = 3; |
---|
654 | $r =~ s/\*/.+/; |
---|
655 | foreach my $g (keys %$graft) { |
---|
656 | ref $graft->{$g} or next; |
---|
657 | log_("rm: graft $g ($r)\n", $config->{verbose}, $config->{LOG},3); |
---|
658 | if ($g =~ m,^/?$r/?$,) { |
---|
659 | foreach my $f (keys %{$graft->{$g}}) { |
---|
660 | $size -= du $f |
---|
661 | } |
---|
662 | $graft->{$g} = 0; |
---|
663 | log_("rm: deleting $g (size $size)\n", $config->{verbose}, $config->{LOG},4); |
---|
664 | } |
---|
665 | } |
---|
666 | } |
---|
667 | # my @find; |
---|
668 | # foreach my $k (keys %$graft){ |
---|
669 | # ref $graft->{$k} or next; |
---|
670 | # foreach my $f (keys %{$graft->{$k}}){ |
---|
671 | # $f =~ s|/{2,}|/|g; |
---|
672 | # find({ wanted => sub { s,/?\Q$f,,; $_ = "$k/$_"; s|/{2,}|/|g; push @find, [ $f, $_ ] }, no_chdir => 1 }, $f); |
---|
673 | # } |
---|
674 | # } |
---|
675 | # foreach (@$files) { s|/{2,}|/|g } |
---|
676 | # foreach my $t (@find){ |
---|
677 | # my ($k, $f) = @$t; |
---|
678 | # foreach my $r (@$files){ |
---|
679 | # next if $f =~ m,^/?$r/[^/]+,; |
---|
680 | # if ($f =~ m,^/?$r/?$,){ |
---|
681 | # log_("rm: deleting $f (path $k regexp $r)\n", $config->{verbose}, $config->{LOG}); |
---|
682 | # $graft->{$f} = 0; |
---|
683 | # $size -= du $k; |
---|
684 | # $size -= du "$k/$f"; |
---|
685 | # } |
---|
686 | # } |
---|
687 | # } |
---|
688 | return $size |
---|
689 | } else { |
---|
690 | foreach (@$files) { |
---|
691 | my @file = glob "$dir/$cdnum/$_"; |
---|
692 | foreach my $f (@file) { |
---|
693 | if (-d $f) { |
---|
694 | log_("rm: deleting directory $f\n", $config->{verbose}, $config->{LOG}, 2); |
---|
695 | my $err = rmtree $f; |
---|
696 | if (!$err) { log_("ERROR rm: deleting $f failed: $!,\n", $config->{verbose}, $config->{LOG}) } |
---|
697 | } else { |
---|
698 | log_("rm: deleting file $f\n", $config->{verbose}, $config->{LOG},2); |
---|
699 | my $err = unlink $f; |
---|
700 | if (!$err) { log_("ERROR rm: deleting $f failed: $!,\n", $config->{verbose}, $config->{LOG}) } |
---|
701 | } |
---|
702 | } |
---|
703 | } |
---|
704 | return |
---|
705 | } |
---|
706 | } |
---|
707 | 1 |
---|
708 | } |
---|
709 | |
---|
710 | sub cp { |
---|
711 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode) = @_; |
---|
712 | my $graft = $totgraft->{$cdnum}; |
---|
713 | if (!$fixed) { |
---|
714 | my $size; |
---|
715 | my $source = $fct->[1]{src}; |
---|
716 | my $dest = $fct->[1]{dest}; |
---|
717 | if ($nolive) { |
---|
718 | $size += du($source, $inode); |
---|
719 | log_("cp: copying $source => $dest (size $size)\n", $config->{verbose}, $config->{LOG},1); |
---|
720 | $graft->{"/$dest"}{$source} = 1; |
---|
721 | return $size |
---|
722 | } else { |
---|
723 | cpal($source, "$dir/$cdnum/$dest"); |
---|
724 | $graft->{"$dir/$cdnum/$dest"}{$source} = 1; |
---|
725 | return |
---|
726 | } |
---|
727 | } |
---|
728 | } |
---|
729 | |
---|
730 | sub cdcom { |
---|
731 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode) = @_; |
---|
732 | my $graft = $totgraft->{$cdnum}; |
---|
733 | if (!$fixed) { |
---|
734 | my $size; |
---|
735 | my $source = $fct->[1]{source}; |
---|
736 | my $dest = $config->{disc}[$cdnum]{function}{data}{dir}{$fct->[1]{dir}}; |
---|
737 | my $destination = $fct->[1]{dest}; |
---|
738 | my $uppath = $destination; |
---|
739 | $uppath =~ s,([^/]+),../,g; |
---|
740 | $uppath =~ s,/+,/,g; |
---|
741 | log_("DEST: $destination uppath $uppath dest $dest\n", $config->{verbose}, $config->{LOG},3); |
---|
742 | my $fdest = "$dir/$cdnum/$destination"; |
---|
743 | if ($nolive) { |
---|
744 | my $path = "$dir/$cdnum/$dest"; |
---|
745 | -d $path or mkpath $path; |
---|
746 | opendir my $A, $source; |
---|
747 | log_("cdcom: $source\n", $config->{verbose}, $config->{LOG},3); |
---|
748 | foreach (readdir $A) { |
---|
749 | /^\.{1,2}$/ and next; |
---|
750 | if (! /^Mandrake$/) { |
---|
751 | $size += du("$source/$_", $inode); |
---|
752 | log_("cdcom: adding $_ (size $size)\n", $config->{verbose}, $config->{LOG},4); |
---|
753 | $graft->{"/$destination/$_/"}{"$source/$_"} = 1 |
---|
754 | } else { |
---|
755 | $graft->{"/$dest/"}{"$source/Mandrake/RPMS/"} = 1 |
---|
756 | } |
---|
757 | } |
---|
758 | #local *A; opendir A, "$source/Mandrake/RPMS"; |
---|
759 | #foreach (readdir A){ |
---|
760 | # /^\.{1,2}$/ and next; |
---|
761 | # my $newdest = readlink "$source/Mandrake/RPMS/$_"; |
---|
762 | # $newdest =~ s,((?:../))*(.*), $1/$destination/$2,; |
---|
763 | # log_("cdcom: creating symlink $dest/$_ => $newdest\n", $config->{verbose}, $config->{LOG}); |
---|
764 | # my $err = symlink $newdest, "$dir/$cdnum/$dest/$_"; |
---|
765 | # !$err and log_("ERROR cdcom: $!\n", $config->{verbose}, $config->{LOG}) and next; |
---|
766 | # $graft->{"/$dest/"}{"$dir/$cdnum/$dest/$_"} = 1 |
---|
767 | #} |
---|
768 | #$graft->{"/$dest/"}{"$source/Mandrake/RPMS"} = 1; |
---|
769 | log_("cdcom: creating symlink $uppath$dest => $fdest/RPMS\n", $config->{verbose}, $config->{LOG}, 4); |
---|
770 | my $err = symlink "$uppath$dest", "$fdest/RPMS"; |
---|
771 | !$err and log_("ERROR cdcom: $!\n", $config->{verbose}, $config->{LOG}); |
---|
772 | $graft->{"/"}{"$fdest/RPMS"} = 1; |
---|
773 | return $size |
---|
774 | } else { |
---|
775 | -f $fdest or mkpath $fdest; |
---|
776 | cpal($source, $fdest, "Mandrake/RPMS"); |
---|
777 | local *A; opendir A, "$source/Mandrake/RPMS"; |
---|
778 | foreach (readdir A) { |
---|
779 | /^\.{1,2}$/ and next; |
---|
780 | my $newdest = readlink "$source/Mandrake/RPMS/$_"; |
---|
781 | $newdest =~ s,((?:../)*)(.*),$1$destination/$2,; |
---|
782 | log_("cdcom: creating symlink $dir/$cdnum/$dest/$_ => $dir/$cdnum/$dest/$newdest\n", $config->{verbose}, $config->{LOG},2); |
---|
783 | my $err = link "$dir/$cdnum/$dest/$newdest", "$dir/$cdnum/$dest/$_"; |
---|
784 | # should be OK with new du with inode checking |
---|
785 | #$size -= du("$dir/$cdnum/$dest/$newdest"); |
---|
786 | !$err and log_("ERROR cdcom: $!\n", $config->{verbose}, $config->{LOG}) |
---|
787 | } |
---|
788 | log_("cdcom: creating symlink $uppath$dest => $fdest/RPMS\n", $config->{verbose}, $config->{LOG}); |
---|
789 | my $err = symlink "$uppath$dest", "$fdest/RPMS"; |
---|
790 | !$err and log_("ERROR cdcom: $!\n", $config->{verbose}, $config->{LOG}); |
---|
791 | return $size |
---|
792 | } |
---|
793 | } |
---|
794 | } |
---|
795 | |
---|
796 | sub printSize { |
---|
797 | my ($img, $file) = @_; |
---|
798 | local *A; open A, ">$file"; |
---|
799 | my $size = imageSize($img); |
---|
800 | log_("printSize: creating $file for $img\n", $config->{verbose}, $config->{LOG}); |
---|
801 | if ($size) { |
---|
802 | print A <<EOF |
---|
803 | #!/usr/bin/perl |
---|
804 | |
---|
805 | \$width = $size->[0]; |
---|
806 | \$height = $size->[1]; |
---|
807 | \@data = () |
---|
808 | EOF |
---|
809 | } else { |
---|
810 | print "ERROR advertising: $size/n"; |
---|
811 | return 0 |
---|
812 | } |
---|
813 | } |
---|
814 | |
---|
815 | sub advertising { |
---|
816 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode) = @_; |
---|
817 | my $graft = $totgraft->{$cdnum}; |
---|
818 | if (!$fixed) { |
---|
819 | my $size; |
---|
820 | if ($nolive) { |
---|
821 | log_("Getting advertising images size\n", $config->{verbose}, $config->{LOG}); |
---|
822 | my $addir = "Mandrake/share/advertising" . ($fct->[1]{lang} ? ".$fct->[1]{lang}" : ""); |
---|
823 | my $rep = "$dir/$cdnum/$addir"; |
---|
824 | -d $rep or mkpath $rep; |
---|
825 | local *L; open L, ">$rep/list"; |
---|
826 | foreach (@{$fct->[1]{img}}) { |
---|
827 | s/\.png$//; |
---|
828 | my ($name) = /([^\/]*)$/; |
---|
829 | $size += du($_, $inode); |
---|
830 | print L "$name\n"; |
---|
831 | if (-f "$_.png") { $graft->{"$addir/$name.png"}{"$_.png"} = 1 } else { next } |
---|
832 | if (-f "$_.pl") { $graft->{"$addir/$name.pl"}{"$_.pl"} = 1 |
---|
833 | } else { |
---|
834 | printSize("$_.png", "$rep/$name.pl"); |
---|
835 | $graft->{"$addir/$name.pl"}{"$_.pl"} = 1 |
---|
836 | } |
---|
837 | -f "${_}_icon.png" and $graft->{"$addir/$name-icon.png"}{"${_}_icon.png"} = 1 |
---|
838 | } |
---|
839 | close L; |
---|
840 | $graft->{"$addir/list"}{"$rep/list"} = 1; |
---|
841 | $size += du("$rep/list"); |
---|
842 | return $size |
---|
843 | } else { |
---|
844 | log_("Creating advertising images directory\n", $config->{verbose}, $config->{LOG}); |
---|
845 | my $rep = "$dir/$cdnum/Mandrake/share/advertising" . ($fct->[1]{lang} ? ".$fct->[1]{lang}" : ""); |
---|
846 | -d $rep or mkpath $rep; |
---|
847 | local *L; open L, ">$rep/list"; |
---|
848 | foreach (@{$fct->[1]{img}}) { |
---|
849 | s/\.png$//; |
---|
850 | my ($name) = /([^\/]*)$/; |
---|
851 | if (-f "$_.png") { cpal("$_.png", "$rep/$name.png") } else { next } |
---|
852 | if (-f "$_.pl") { cpal("$_.pl", "$rep/$name.pl") } else { printSize("$_.png", "$rep/$name.pl") } |
---|
853 | -f "${_}_icon.png" and cpal("${_}_icon.png", "$rep/${name}_icon.png"); |
---|
854 | print L "$name.png\n" |
---|
855 | } |
---|
856 | close L; |
---|
857 | return |
---|
858 | } |
---|
859 | } |
---|
860 | } |
---|
861 | |
---|
862 | sub dir { |
---|
863 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd) = @_; |
---|
864 | if (!$fixed) { |
---|
865 | if ($nolive) { |
---|
866 | return 0 |
---|
867 | } else { |
---|
868 | my $reploc = "$dir/$cdnum/$fct->[1]{reploc}"; |
---|
869 | log_("dir: creating $reploc\n", $config->{verbose}, $config->{LOG}); |
---|
870 | -d $reploc or mkpath $reploc; |
---|
871 | return 0 |
---|
872 | } |
---|
873 | } |
---|
874 | } |
---|
875 | |
---|
876 | sub generic { |
---|
877 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discFiles) = @_; |
---|
878 | my $graft = $totgraft->{$cdnum}; |
---|
879 | if ($fixed) { |
---|
880 | my $rep = $fct->[1]{repname}; |
---|
881 | my $lists = $fct->[1]{lists}; |
---|
882 | log_("generic: rep $rep\n", $config->{verbose}, $config->{LOG}); |
---|
883 | my $reploc = "$dir/$cdnum/$cd->{function}{data}{dir}{$rep}/"; |
---|
884 | if ($nolive) { |
---|
885 | my $size; |
---|
886 | if ($fixed > 0) { |
---|
887 | foreach my $list (@$lists) { |
---|
888 | foreach my $src (keys %{$cdfile->[$cdnum]{$rep}{$list}}) { |
---|
889 | log_("generic: src $src\n", $config->{verbose}, $config->{LOG}); |
---|
890 | foreach (@{$cdfile->[$cdnum]{$rep}{$list}{$src}}) { |
---|
891 | if ($_->[0] == 1) { |
---|
892 | $graft->{"$cd->{function}{data}{dir}{$rep}/$_->[1]"}{"$src/$_->[1]"} = 1 |
---|
893 | } elsif ($_->[0] == 2) { |
---|
894 | delete $graft->{"$cd->{function}{data}{dir}{$rep}/$_->[1]"}{"$src/$_->[1]"} |
---|
895 | } |
---|
896 | } |
---|
897 | } |
---|
898 | if ($fct->[1]{synthesis} || $fct->[1]{hdlist}) { |
---|
899 | if (ref $discFiles->[$cdnum]{$rep}{$list}) { |
---|
900 | buildGenericHdlist($dir, $cdnum, $fct, $rep, $reploc, $discFiles->[$cdnum]{$rep}{$list}); |
---|
901 | if ($fct->[1]{hdlist}) { |
---|
902 | $size += du("$dir/$cdnum/$reploc/hdlist$cdnum$rep.cz"); |
---|
903 | $graft->{"Mandrake/base/hdlist$cdnum$rep.cz"}{"$reploc/hdlist$cdnum$rep.c"} = 1 |
---|
904 | } |
---|
905 | if ($fct->[1]{synthesis}) { |
---|
906 | $size += du("$dir/$cdnum/$reploc/synthesis.hdlist$cdnum$rep.cz"); |
---|
907 | $graft->{"$cd->{function}{data}{dir}{$rep}/synthesis.hdlist$cdnum$rep.cz"}{"$reploc/synthesis.hdlist$cdnum$rep.cz"} = 1 |
---|
908 | } |
---|
909 | } else { |
---|
910 | log_("WARNING generic: disc $cd rep $rep list $list is empty, no hdlist or synthesis created\n", $config->{verbose}, $config->{LOG}); |
---|
911 | } |
---|
912 | } |
---|
913 | } |
---|
914 | } |
---|
915 | return $size |
---|
916 | } else { |
---|
917 | foreach my $list (@$lists) { |
---|
918 | foreach my $src (keys %{$cdfile->[$cdnum]{$rep}{$list}}) { |
---|
919 | log_("generic: src $src\n", $config->{verbose}, $config->{LOG}); |
---|
920 | foreach (@{$cdfile->[$cdnum]{$rep}{$list}{$src}}) { |
---|
921 | if ($_->[0] == 1) { |
---|
922 | cpal("$src/$_->[1]", $reploc) |
---|
923 | } elsif ($_->[0] == 2) { |
---|
924 | log_("generic: deleting $reploc/$_->[1]\n", $config->{verbose}, $config->{LOG}); |
---|
925 | unlink "$reploc/$_->[1]"; |
---|
926 | } |
---|
927 | } |
---|
928 | } |
---|
929 | if ($fct->[1]{synthesis} || $fct->[1]{hdlist}) { |
---|
930 | if (ref $discFiles->[$cdnum]{$rep}{$list}) { |
---|
931 | buildGenericHdlist($dir, $cdnum, $fct, $rep, $reploc, $discFiles->[$cdnum]{$rep}{$list}); |
---|
932 | } else { |
---|
933 | log_("WARNING generic: disc $cd rep $rep list $list is empty, no hdlist or synthesis created\n", $config->{verbose}, $config->{LOG}); |
---|
934 | } |
---|
935 | } |
---|
936 | } |
---|
937 | return 0 |
---|
938 | } |
---|
939 | } |
---|
940 | } |
---|
941 | |
---|
942 | sub printVERSION { |
---|
943 | my ($name, $file, $tag) = @_; |
---|
944 | local *A; open A, ">$file"; |
---|
945 | my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time()); |
---|
946 | $year += 1900; |
---|
947 | printf A "Mandrake Linux $name $tag %04d%02d%02d $hour:%02d\n", $year, $mon+1, $mday, $min; |
---|
948 | } |
---|
949 | |
---|
950 | sub buildGenericHdlist { |
---|
951 | my ($dir, $cdnum, $fct, $rep, $reploc, $discFilescdrep, $hdlist) = @_; |
---|
952 | my @rpm = map { "$discFilescdrep->{$_}/$_.rpm" } keys %{$discFilescdrep}; |
---|
953 | |
---|
954 | if ($fct->[1]{synthesis}) { |
---|
955 | -d $reploc or mkpath $reploc; |
---|
956 | } |
---|
957 | $hdlist = "$reploc/hdlist$cdnum$rep.cz" if $fct->[1]{hdlist}; |
---|
958 | my $synthesis = "$reploc/synthesis.hdlist$cdnum$rep.cz" if $fct->[1]{synthesis}; |
---|
959 | mkcd_build_hdlist(1, [ 0, { hdlist => $hdlist, rpms => \@rpm , synthesis => $synthesis } ], "$config->{tmp}/.mkcd_build_hdlist"); |
---|
960 | } |
---|
961 | |
---|
962 | sub buildInstallHdlist { |
---|
963 | my ($dir, $cdnum, $inst, $list, $discsFiles) = @_; |
---|
964 | my (@hdlist, @hdlist_list); |
---|
965 | -d "$dir/$cdnum/Mandrake/base/" or mkpath "$dir/$cdnum/Mandrake/base/"; |
---|
966 | local *A; open A, ">$dir/$cdnum/Mandrake/base/hdlists"; |
---|
967 | my %rpmdone; |
---|
968 | my $repnum = 1; |
---|
969 | my (@thisInstallRep, @check); |
---|
970 | my $headers_dir = "$config->{tmp}/.mkcd_build_hdlist"; |
---|
971 | my $path = "$dir/$cdnum/Mandrake/base"; |
---|
972 | foreach my $rd (@{$inst->[1]{rpmsdir}}) { |
---|
973 | my ($ls, $cdrep, $repname, $opts) = @$rd; |
---|
974 | $list->{$cdrep} or log_("WARNING buildInstallHdlist: disc $cdrep not in list, ignoring\n", $config->{verbose}, $config->{LOG}) and next; |
---|
975 | my $a = $discsFiles->[$cdrep]{$repname}; |
---|
976 | if (!(ref $a && %$a)) { log_("WARNING buildInstallHdlist: $cdrep/$repname is empty\n", $config->{verbose}, $config->{LOG}); next } |
---|
977 | my $realcd = $config->{disc}[$cdrep]{name}; |
---|
978 | my $rpmdir = $config->{disc}[$cdrep]{function}{data}{dir}{$repname}; |
---|
979 | $rpmdir or log_("ERROR buildInstallHdlist: disc $cdrep: $repname not defined\n", $config->{verbose}, $config->{LOG}) and next; |
---|
980 | if ($opts->{oem}) { |
---|
981 | log_("buildInstallHdlist: oem mode for $cdrep/$repname ($rpmdir)\n", $config->{verbose}, $config->{LOG}); |
---|
982 | foreach (@{$inst->[1]{oem}{hdlist}}) { |
---|
983 | my ($oemdir, $hl, $rep, $name) = @$_; |
---|
984 | print A "noauto:" if $opts->{noauto}; |
---|
985 | print A "$hl $rep $name\n"; |
---|
986 | my $hdlist = "$path/$hl"; |
---|
987 | log_("buildInstallHdlist: adding oem hdlist $hdlist from $dir\n", $config->{verbose}, $config->{LOG}); |
---|
988 | if ($inst->[1]{oem}{norebuild}) { |
---|
989 | cpal("$oemdir/$hl", $hdlist) |
---|
990 | } |
---|
991 | $hdlist[$repnum]{hdlist} = $hdlist; |
---|
992 | $hdlist_list[$repnum] = $hdlist; |
---|
993 | $hdlist[$repnum]{synthesis} = "$path/synthesis.$hl"; |
---|
994 | $repnum++ |
---|
995 | } |
---|
996 | } else { |
---|
997 | # |
---|
998 | # even for live sources rpm are taken, this may lead to errors in some special case, where |
---|
999 | # the sources change after the live is created, but this could help in combined live/nolive |
---|
1000 | # situation |
---|
1001 | # |
---|
1002 | log_("installation: $cdrep - $repname\n", $config->{verbose}, $config->{LOG}); |
---|
1003 | foreach my $list (keys %{$discsFiles->[$cdrep]{$repname}}) { |
---|
1004 | next if $ls && $ls == $list; |
---|
1005 | $thisInstallRep[$cdrep]{$repname}{$list} = $discsFiles->[$cdrep]{$repname}{$list}; |
---|
1006 | push @{$check[$repnum]}, [$cdrep, $repname, $list]; |
---|
1007 | my $cdsfilesrpms = $discsFiles->[$cdrep]{$repname}{$list}; |
---|
1008 | if ($opts->{update}) { |
---|
1009 | my %localdone; |
---|
1010 | log_("buildInstallHdlist: update mode for $cdrep/$repname list $list\n", $config->{verbose}, $config->{LOG}); |
---|
1011 | push @{$hdlist[$repnum]{rpms}}, map { /(.*)-[^-]+-[^-]+\.[^.]+$/; $rpmdone{$_} = 1; $rpmdone{$1} = 1; "$cdsfilesrpms->{$_}/$_.rpm" } grep { /(.*)-[^-]+-[^-]+\.[^.]+$/; if ($localdone{$1}) { 0 } else { $localdone{$1} = 1; ! $rpmdone{$_} } } keys %{$cdsfilesrpms}; |
---|
1012 | } else { |
---|
1013 | my %localdone; |
---|
1014 | log_("buildInstallHdlist: normal mode for $cdrep/$repname list $list\n", $config->{verbose}, $config->{LOG}); |
---|
1015 | push @{$hdlist[$repnum]{rpms}}, map { /(.*)-[^-]+-[^-]+\.[^.]+$/; $rpmdone{$_} = 1; $rpmdone{$1} = 1; "$cdsfilesrpms->{$_}/$_.rpm" } grep { /(.*)-[^-]+-[^-]+\.[^.]+$/; if ($localdone{$1}) { 0 } else { $localdone{$1} = 1; ! ($rpmdone{$_} || $rpmdone{$1}) } } keys %{$cdsfilesrpms}; |
---|
1016 | } |
---|
1017 | } |
---|
1018 | if (@{$hdlist[$repnum]{rpms}}) { |
---|
1019 | print A "noauto:" if $opts->{noauto}; |
---|
1020 | if ($realcd) { |
---|
1021 | print A "hdlist$repnum.cz $rpmdir disc $realcd $config->{disc}[$cdrep]{longname}\n"; |
---|
1022 | } else { |
---|
1023 | print A "hdlist$repnum.cz $rpmdir $config->{disc}[$cdrep]{longname}\n"; |
---|
1024 | } |
---|
1025 | $hdlist[$repnum]{hdlist} = "$path/hdlist$repnum.cz"; |
---|
1026 | $hdlist_list[$repnum] = "$path/hdlist$repnum.cz"; |
---|
1027 | $hdlist[$repnum]{synthesis} = "$path/synthesis.hdlist$repnum.cz" if $inst->[1]{synthesis}; |
---|
1028 | $repnum++ |
---|
1029 | } else { |
---|
1030 | log_("WARNING installation: $cdrep $repname is empty, ignoring\n", $config->{verbose}, $config->{LOG}); |
---|
1031 | } |
---|
1032 | } |
---|
1033 | } |
---|
1034 | # FIXME OEM mode not tested, moreover this norebuild test is wrong, new URPM need to rebuild hdlist. |
---|
1035 | if (!$inst->[1]{oem}{norebuild}) { |
---|
1036 | mkcd_build_hdlist($repnum - 1, \@hdlist, $headers_dir, "$path/depslist.ordered", "$path/provides", "$path/compss"); |
---|
1037 | } |
---|
1038 | |
---|
1039 | if (!$inst->[1]{oem}) { |
---|
1040 | checkDiscs(\@hdlist_list, "$path/depslist.ordered", \@thisInstallRep, \@check, $config->{LOG}) or die "depslist.ordered, hdlists and RPMS mismatch\n"; |
---|
1041 | } |
---|
1042 | # Add sources |
---|
1043 | foreach my $rd (@{$inst->[1]{srpmsdir}}) { |
---|
1044 | my ($ls, $cdrep, $repname, $opts) = @$rd; |
---|
1045 | $list->{$cdrep} or log_("WARNING buildInstallHdlist: disc $cdrep not in list, ignoring\n", $config->{verbose}, $config->{LOG}) and next; |
---|
1046 | foreach my $list (keys %{$discsFiles->[$cdrep]{$repname}}) { |
---|
1047 | next if $ls && $ls == $list; |
---|
1048 | $thisInstallRep[$cdrep]{$repname}{$list} = $discsFiles->[$cdrep]{$repname}{$list}; |
---|
1049 | } |
---|
1050 | } |
---|
1051 | my $pfile = "$dir/$cdnum/pkg-$config->{name}" . ($inst->[1]{tag} ? "-$inst->[1]{tag}" : "") . ".idx"; |
---|
1052 | printDiscsFile($config, \@thisInstallRep, $pfile); |
---|
1053 | |
---|
1054 | return ($repnum, $path, $pfile); |
---|
1055 | } |
---|
1056 | |
---|
1057 | sub boot { |
---|
1058 | my ($class, $fct, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discsFiles) = @_; |
---|
1059 | my $graft = $totgraft->{$cdnum}; |
---|
1060 | my $isolinux = $fct->[1]{isolinux}; |
---|
1061 | my $bootimg = $fct->[1]{bootimg}; |
---|
1062 | log_("Boot: $fixed nolive $nolive\n", $config->{verbose}, $config->{LOG}); |
---|
1063 | if (!$fixed) { |
---|
1064 | my $size; |
---|
1065 | if ($nolive) { |
---|
1066 | my $mkiso; |
---|
1067 | my $img; |
---|
1068 | my $dir; |
---|
1069 | my $path; |
---|
1070 | if ($isolinux) { |
---|
1071 | my $dir = $isolinux->[0]; |
---|
1072 | my $img = $bootimg ? $bootimg->[0] : "isolinux/isolinux.bin"; |
---|
1073 | $mkiso = qq( -b $img -c $dir/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table); |
---|
1074 | $graft->{"$dir/boot.cat"} = 0; |
---|
1075 | $graft->{"/isolinux/isolinux.bin"} = 0 |
---|
1076 | } elsif ($bootimg) { |
---|
1077 | $img = $bootimg->[0]; |
---|
1078 | $dir = $bootimg->[1]{dir}; |
---|
1079 | $img =~ s/(.*)\/([^\/]+)$/$2/; |
---|
1080 | $dir or ($dir) = $1; |
---|
1081 | $mkiso = qq( -b $dir/$img -c ${dir}/boot.cat); |
---|
1082 | $graft->{"$dir/boot.cat"} = 0 |
---|
1083 | } |
---|
1084 | foreach (@{$fct->[1]{files}}) { |
---|
1085 | my ($files, $opt) = @$_; |
---|
1086 | my $dest = $opt->{dest}; |
---|
1087 | $size += du($files); |
---|
1088 | my ($dirname) = $files =~ /([^\/]*)$/; |
---|
1089 | log_("boot: files $files dest $dest dirname $dirname\n", $config->{verbose}, $config->{LOG}); |
---|
1090 | if ($img) { |
---|
1091 | my $bimg = $bootimg->[0]; |
---|
1092 | $bimg =~ s/^$dirname//; |
---|
1093 | log_("boot: boot image $files/$bimg in $dir/$img (" . (stat "$files/$bimg")[7] . ")\n", $config->{verbose}, $config->{LOG}); |
---|
1094 | if (-f "$files/$bimg") { |
---|
1095 | if ((stat "$files/$bimg")[7] > 3000000) { |
---|
1096 | $mkiso .= qq( -no-emul-boot) |
---|
1097 | } |
---|
1098 | # $mkiso .= qq( $dir/$img=$files/$bimg) |
---|
1099 | $graft->{"$dir/$img"}{"$files/$bimg"} = 1 |
---|
1100 | } |
---|
1101 | } |
---|
1102 | # if (-d "$files") { $mkiso .= " $dest/$dirname/=$files"; next } |
---|
1103 | # $mkiso .= " $dest/=$files"; |
---|
1104 | if (-d $files) { $graft->{"$dest/$dirname/"}{$files} = 1; next } |
---|
1105 | $graft->{"$dest/"}{$files} = 1 |
---|
1106 | } |
---|
1107 | # it is = and not .= because mkcdisos->[$cdnum] has been added already at the beginning |
---|
1108 | $mkisos->[$cdnum] = "$mkiso $mkisos->[$cdnum]"; |
---|
1109 | } else { |
---|
1110 | log_("FILES $fct->[1]{files}\n", $config->{verbose}, $config->{LOG}); |
---|
1111 | foreach (@{$fct->[1]{files}}) { |
---|
1112 | my ($files, $opt) = @$_; |
---|
1113 | log_("boot: file $files\n", $config->{verbose}, $config->{LOG}); |
---|
1114 | my $dest = "$config->{topdir}/build/$config->{name}/" . ($opt->{first} ? "first/" : "") . "$cdnum/"; |
---|
1115 | -d $dest or mkpath $dest; |
---|
1116 | my $odest = $opt->{dest}; |
---|
1117 | if ($odest) { |
---|
1118 | $dest .= "/$odest"; |
---|
1119 | if ($odest =~ /\/$/) { mkpath $dest } |
---|
1120 | } else { |
---|
1121 | my ($dirname) = $files =~ /([^\/]*)$/; |
---|
1122 | $dest .= "/$dirname" |
---|
1123 | } |
---|
1124 | cpal($files, $dest) |
---|
1125 | } |
---|
1126 | if ($fct->[1]{oem}) { |
---|
1127 | log_("boot: setting default boot to oem\n", $config->{verbose}, $config->{LOG}); |
---|
1128 | my $dest = "$config->{topdir}/build/$config->{name}/first/$cdnum/isolinux"; |
---|
1129 | -d $dest or mkpath $dest; |
---|
1130 | my $old = "$dest/isolinux.cfg"; |
---|
1131 | my $new = "$dest/isolinux.cfg.new"; |
---|
1132 | copy $old, $new; |
---|
1133 | unlink $old; |
---|
1134 | link $new, $old; |
---|
1135 | unlink $new; |
---|
1136 | substInFile { s/default linux/default oem/ } $old |
---|
1137 | } |
---|
1138 | $graft->{"/"}{"$dir/first/$cdnum/"} = 1; |
---|
1139 | $size = du("$dir/first/$cdnum/", $inode); |
---|
1140 | } |
---|
1141 | return $size |
---|
1142 | } elsif ($fixed == 1) { |
---|
1143 | if (!$nolive) { |
---|
1144 | if ($isolinux) { |
---|
1145 | my $dir = $isolinux->[0]; |
---|
1146 | my $img = $bootimg ? $bootimg->[0] : "isolinux/isolinux.bin"; |
---|
1147 | $mkisos->[$cdnum] .= qq( -b $img -c $dir/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table "$config->{topdir}/build/$config->{name}/first/$cdnum"); |
---|
1148 | $graft->{"/isolinux/isolinux.bin"} = 0; |
---|
1149 | $graft->{"$dir/boot.cat"} = 0 |
---|
1150 | } elsif ($bootimg) { |
---|
1151 | my $img = $bootimg->[0]; |
---|
1152 | my $sdir = $bootimg->[1]{dir}; |
---|
1153 | $img =~ s/(.*\/)([^\/]+)$/$2/; |
---|
1154 | $sdir or ($sdir) = $1; |
---|
1155 | $sdir =~ s/\/\/+/\//g; |
---|
1156 | $sdir =~ s/\/$//g; |
---|
1157 | log_("boot: boot image $sdir/$img\n", $config->{verbose}, $config->{LOG}); |
---|
1158 | $mkisos->[$cdnum] .= qq(-b $sdir/$img); |
---|
1159 | if ((stat $img)[7] > 3000000) { |
---|
1160 | $mkisos->[$cdnum] .= qq( -no-emul-boot) |
---|
1161 | } |
---|
1162 | my $cdimages = "$dir/$cdnum/"; |
---|
1163 | my $Bootdir = "$dir/first/$cdnum/$sdir/"; |
---|
1164 | $Bootdir =~ s/\/\/+/\//g; |
---|
1165 | $Bootdir =~ s/\/$//g; |
---|
1166 | if (! -f "$Bootdir/$img") { |
---|
1167 | if (! -d $Bootdir) { mkpath $Bootdir or die "cannot create $Bootdir\n" } |
---|
1168 | my $err = link "$cdimages/$bootimg->[0]", "$Bootdir/$img"; |
---|
1169 | if (!$err) { log_("Linking failed $cdimages/$bootimg->[0]: $!\n", $config->{verbose}, $config->{LOG}) }; |
---|
1170 | } |
---|
1171 | $mkisos->[$cdnum] .= qq( -c $sdir/boot.cat $dir/first/$cdnum); |
---|
1172 | $graft->{"$sdir/boot.cat"} = 0; |
---|
1173 | log_("BOOT $mkisos->[$cdnum]\n", $config->{verbose}, $config->{LOG}); |
---|
1174 | } |
---|
1175 | } |
---|
1176 | } |
---|
1177 | } |
---|
1178 | |
---|
1179 | sub installation { |
---|
1180 | my ($class, $inst, $dir, $fixed, $nolive, $cdnum, $cd, $cdfile, $list, $mkisos, $totgraft, $inode, $discsFiles) = @_; |
---|
1181 | my $graft = $totgraft->{$cdnum}; |
---|
1182 | my $install = $inst->[1]{install}; |
---|
1183 | if (!$fixed) { |
---|
1184 | $install or return; |
---|
1185 | my $size; |
---|
1186 | if ($nolive) { |
---|
1187 | opendir my $A, $install; |
---|
1188 | foreach (readdir $A) { |
---|
1189 | /~$/ and next; |
---|
1190 | /^(\.{1,2}|Mandrake|LICENSE-APPS.txt|isolinux|images|VERSION)$/ and next; |
---|
1191 | $size += du("$install/$_"); |
---|
1192 | # if (-d "$install/$_") { $mkiso .= " /$_/=$install/$_"; next } |
---|
1193 | # $mkiso .= " /=$install/$_" |
---|
1194 | if (-d "$install/$_") { $graft->{"/$_/"}{"$install/$_"} = 1; next } |
---|
1195 | $graft->{"/"}{"$install/$_"} = 1 |
---|
1196 | } |
---|
1197 | |
---|
1198 | local *A; opendir A, "$install/Mandrake"; |
---|
1199 | foreach (readdir A) { |
---|
1200 | log_("Mandrake -- $_\n", $config->{verbose}, $config->{LOG}, 3); |
---|
1201 | /~$/ and next; |
---|
1202 | /(^(\.{1,2}|base)$|RPMS|share)/ and next; |
---|
1203 | $size += du("$install/Mandrake/$_"); |
---|
1204 | # if (-d "$install/Mandrake/$_") { $mkiso .= " Mandrake/$_/=$install/Mandrake/$_"; next } |
---|
1205 | # $graft->{"Mandrake/"}{"$install/Mandrake/$_"} = 1; |
---|
1206 | if (-d "$install/Mandrake/$_") { $graft->{"Mandrake/$_/"}{"$install/Mandrake/$_"} = 1; next } |
---|
1207 | $graft->{"Mandrake/"}{"$install/Mandrake/$_"} = 1; |
---|
1208 | } |
---|
1209 | |
---|
1210 | local *A; opendir A, "$install/Mandrake/base"; |
---|
1211 | foreach (readdir A) { |
---|
1212 | /~$/ and next; |
---|
1213 | /(^(\.{1,2}|compss|provides|depslist.ordered|synthesis|compssUsers|rpmsrate|rpmslist|filelist|Serial|hashfile)|hdlist|cooker)/ and next; |
---|
1214 | $size += du("$install/Mandrake/base/$_"); |
---|
1215 | # if (-d "$install/Mandrake/base/$_") { $mkiso .= " Mandrake/base/$_/=$install/Mandrake/base/$_"; next} |
---|
1216 | # $mkiso .= " Mandrake/base/=$install/Mandrake/base/$_"; |
---|
1217 | if (-d "$install/Mandrake/base/$_") { $graft->{"Mandrake/base/$_/"}{"$install/Mandrake/base/$_"} = 1; next } |
---|
1218 | $graft->{"Mandrake/base/"}{"$install/Mandrake/base/$_"} = 1 |
---|
1219 | } |
---|
1220 | my $compss = $cd->{function}{data}{installation}[1]{compssUsers} || "$install/Mandrake/base/compssUsers"; |
---|
1221 | if (-f $compss) { |
---|
1222 | $size += du($compss); |
---|
1223 | # $mkiso .= " Mandrake/base/compssUsers=$compss" |
---|
1224 | $graft->{"Mandrake/base/compssUsers"}{$compss} = 1 |
---|
1225 | } else { log_("ERROR installation: $compss file does not exist", $config->{verbose}, $config->{LOG}, 0) } |
---|
1226 | if ($inst->[1]{boot_medium}) { |
---|
1227 | -d "$dir/$cdnum/Mandrake/base/" or mkpath "$dir/$cdnum/Mandrake/base/"; |
---|
1228 | my $file = "$dir/$cdnum/Mandrake/base/patch-oem.pl"; |
---|
1229 | local *A, open A, ">$file" or print "ERROR installation: could not open $file for writing\n"; |
---|
1230 | print A "use install_any; |
---|
1231 | package install_any; |
---|
1232 | |
---|
1233 | \$current_medium = $inst->[1]{boot_medium}; |
---|
1234 | \$asked_medium = $inst->[1]{boot_medium}; |
---|
1235 | "; |
---|
1236 | $graft->{"Mandrake/base/"}{$file} = 1; |
---|
1237 | $size += du("Mandrake/base/$file", $inode) |
---|
1238 | } |
---|
1239 | } else { |
---|
1240 | cpal("$install/", "$dir/$cdnum", "($install/+(Mandrake/+base/+(hdlist|depslist|synthesis|rpmslist|filelist|Serial|hashfile|compssUsers|rpmsrate)|Mandrake/+RPMS|Mandrake/+share|isolinux|images|tutorial|misc|doc|LICENSE-APPS.txt))"); |
---|
1241 | if (!$inst->[1]{oem}) { |
---|
1242 | cpal("$install/tutorial", "$dir/$cdnum/tutorial") if -d "$install/tutorial"; |
---|
1243 | cpal("$install/misc", "$dir/$cdnum/misc") if -d "$install/misc"; |
---|
1244 | cpal("$install/doc", "$dir/$cdnum/doc") if -d "$install/doc"; |
---|
1245 | } |
---|
1246 | if ($inst->[1]{boot_medium}) { |
---|
1247 | my $file = "$dir/$cdnum/Mandrake/base/patch-oem.pl"; |
---|
1248 | local *A, open A, ">$file" or print "ERROR installation: could not open $file for writing\n"; |
---|
1249 | print A "use install_any; |
---|
1250 | package install_any; |
---|
1251 | |
---|
1252 | \$current_medium = $inst->[1]{boot_medium}; |
---|
1253 | \$asked_medium = $inst->[1]{boot_medium}; |
---|
1254 | "; |
---|
1255 | } |
---|
1256 | my $compss = $cd->{function}{data}{installation}[1]{compssUsers} || "$install/Mandrake/base/compssUsers"; |
---|
1257 | if (-f $compss) { |
---|
1258 | log_("installation: compssUsers $compss\n", $config->{verbose}, $config->{LOG}, 2); |
---|
1259 | cpal($compss, "$dir/$cdnum/Mandrake/base/compssUsers"); |
---|
1260 | } else { log_("ERROR installation: $compss file does not exist", $config->{verbose}, $config->{LOG}, 0) } |
---|
1261 | } |
---|
1262 | return $size |
---|
1263 | } else { |
---|
1264 | if ($nolive) { |
---|
1265 | my $size; |
---|
1266 | my ($repnum, $path, $pfile) = buildInstallHdlist($dir, $cdnum, $inst, $list, $discsFiles); |
---|
1267 | if ($install && $fixed == 1) { |
---|
1268 | my $rpmsrate = $cd->{function}{data}{installation}[1]{rpmsrate} || "$install/Mandrake/base/rpmsrate"; |
---|
1269 | # $mkiso = " Mandrake/base/=$path/compss Mandrake/base/=$path/depslist.ordered Mandrake/base/=$path/provides Mandrake/base/=$path/hdlists /=$pfile"; |
---|
1270 | $graft->{"Mandrake/base/"}{"$path/compss"} = 1; |
---|
1271 | $graft->{"Mandrake/base/"}{"$path/depslist.ordered"} = 1; |
---|
1272 | $graft->{"Mandrake/base/"}{"$path/provides"} = 1; |
---|
1273 | $graft->{"Mandrake/base/"}{"$path/hdlists"} = 1; |
---|
1274 | $graft->{"/"}{$pfile} = 1; |
---|
1275 | if (-f $rpmsrate) { |
---|
1276 | $size += du($rpmsrate); |
---|
1277 | # $mkiso .= " Mandrake/base/rpmsrate=$rpmsrate" |
---|
1278 | $graft->{"Mandrake/base/rpmsrate"}{$rpmsrate} = 1 |
---|
1279 | } else { log_("ERROR installation: $rpmsrate file does not exist", $config->{verbose}, $config->{LOG}, 0); return 0 } |
---|
1280 | $size += du("$path/compss", $inode); |
---|
1281 | $size += du("$path/depslist.ordered"); |
---|
1282 | $size += du("$path/provides"); |
---|
1283 | $size += du($pfile, $inode); |
---|
1284 | } |
---|
1285 | my $version = "$dir/$cdnum/VERSION"; |
---|
1286 | $size += du("$path/hdlists"); |
---|
1287 | printVERSION($config->{name}, $version, $inst->[1]{tag}); |
---|
1288 | $graft->{VERSION}{$version} = 1; |
---|
1289 | $size += du($version); |
---|
1290 | foreach my $n (1 .. $repnum - 1) { |
---|
1291 | # $mkiso .= " Mandrake/base/=$path/hdlist$n.cz"; |
---|
1292 | $graft->{"Mandrake/base/"}{"$path/hdlist$n.cz"} = 1; |
---|
1293 | # FIXME This is wrong, previous hdlist size must be deduced in iterative rebuild mode |
---|
1294 | $size += du("Mandrake/base/=$path/hdlist$n.cz"); |
---|
1295 | if ($inst->[1]{synthesis}) { |
---|
1296 | # $mkiso .= " Mandrake/base/=$path/synthesis.hdlist$n.cz"; |
---|
1297 | $graft->{"Mandrake/base/"}{"$path/synthesis.hdlist$n.cz"} = 1; |
---|
1298 | $size += du("Mandrake/base/=$path/synthesys.hdlist$n.cz") |
---|
1299 | } |
---|
1300 | } |
---|
1301 | return $size; |
---|
1302 | } else { |
---|
1303 | if (!$install) { mkpath "$dir/$cdnum/Mandrake/base/" } |
---|
1304 | unlink "$dir/$cdnum/Mandrake/base/hdlists"; |
---|
1305 | buildInstallHdlist($dir, $cdnum, $inst, $list, $discsFiles); |
---|
1306 | if ($install && $fixed == 1) { |
---|
1307 | my $rpmsrate = $cd->{function}{data}{installation}[1]{rpmsrate} || "$install/Mandrake/base/rpmsrate"; |
---|
1308 | if (-f $rpmsrate) { |
---|
1309 | log_("installation: rpmsrate: $rpmsrate\n", $config->{verbose}, $config->{LOG}, 2); |
---|
1310 | cpal($rpmsrate, "$dir/$cdnum/Mandrake/base/rpmsrate"); |
---|
1311 | } else { log_("ERROR installation: $rpmsrate file does not exist", $config->{verbose}, $config->{LOG}, 0); return 0 } |
---|
1312 | } |
---|
1313 | my $version = "$dir/$cdnum/VERSION"; |
---|
1314 | unlink $version; |
---|
1315 | printVERSION($config->{name}, $version, $inst->[1]{tag}); |
---|
1316 | } |
---|
1317 | } |
---|
1318 | } |
---|
1319 | |
---|
1320 | 1 |
---|
1321 | |
---|
1322 | # |
---|
1323 | # Changeloh |
---|
1324 | # |
---|
1325 | # 2002 03 15 |
---|
1326 | # new sources handling in installation |
---|
1327 | # |
---|
1328 | # 2002 03 19 |
---|
1329 | # cdcom are now build as normal ones not to force deps, use standard list |
---|
1330 | # |
---|
1331 | # 2002 03 29 |
---|
1332 | # fix a bug in nolive mode that prevent rpmsrate to be put on discs |
---|
1333 | # |
---|
1334 | # 2002 05 13 |
---|
1335 | # finish md5 check |
---|
1336 | # fix commented du in sub installation |
---|
1337 | # |
---|
1338 | # 2002 08 01 |
---|
1339 | # add noauto options for rpmsdir |
---|
1340 | # |
---|
1341 | # 2002 08 14 |
---|
1342 | # fix little bug in buildGenericHdlists |
---|
1343 | # |
---|
1344 | # 2002 10 02 |
---|
1345 | # allow glob in rm function for live mode (need to do it for nolive mode) |
---|