source: main/trunk/greenstone2/bin/script/buildcol.pl@ 24755

Last change on this file since 24755 was 24755, checked in by sjm84, 13 years ago

Some changes to support the store_metadata_coverage option

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 22.0 KB
Line 
1#!/usr/bin/perl -w
2
3###########################################################################
4#
5# buildcol.pl --
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 1999 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28
29# This program will build a particular collection.
30
31package buildcol;
32
33BEGIN {
34 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
35 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
36 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
38 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan/XML/XPath");
39 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
40 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify");
41
42 if (defined $ENV{'GSDLEXTS'}) {
43 my @extensions = split(/:/,$ENV{'GSDLEXTS'});
44 foreach my $e (@extensions) {
45 my $ext_prefix = "$ENV{'GSDLHOME'}/ext/$e";
46
47 unshift (@INC, "$ext_prefix/perllib");
48 unshift (@INC, "$ext_prefix/perllib/cpan");
49 unshift (@INC, "$ext_prefix/perllib/plugins");
50 unshift (@INC, "$ext_prefix/perllib/classify");
51 }
52 }
53 if (defined $ENV{'GSDL3EXTS'}) {
54 my @extensions = split(/:/,$ENV{'GSDL3EXTS'});
55 foreach my $e (@extensions) {
56 my $ext_prefix = "$ENV{'GSDL3SRCHOME'}/ext/$e";
57
58 unshift (@INC, "$ext_prefix/perllib");
59 unshift (@INC, "$ext_prefix/perllib/cpan");
60 unshift (@INC, "$ext_prefix/perllib/plugins");
61 unshift (@INC, "$ext_prefix/perllib/classify");
62 }
63 }
64
65}
66
67use colcfg;
68use dbutil;
69use util;
70use scriptutil;
71use FileHandle;
72use gsprintf;
73use printusage;
74use parse2;
75
76use strict;
77no strict 'refs'; # allow filehandles to be variables and vice versa
78no strict 'subs'; # allow barewords (eg STDERR) as function arguments
79
80
81my $mode_list =
82 [ { 'name' => "all",
83 'desc' => "{buildcol.mode.all}" },
84 { 'name' => "compress_text",
85 'desc' => "{buildcol.mode.compress_text}" },
86 { 'name' => "build_index",
87 'desc' => "{buildcol.mode.build_index}" },
88 { 'name' => "infodb",
89 'desc' => "{buildcol.mode.infodb}" } ];
90
91my $sec_index_list =
92 [ {'name' => "never",
93 'desc' => "{buildcol.sections_index_document_metadata.never}" },
94 {'name' => "always",
95 'desc' => "{buildcol.sections_index_document_metadata.always}" },
96 {'name' => "unless_section_metadata_exists",
97 'desc' => "{buildcol.sections_index_document_metadata.unless_section_metadata_exists}" }
98 ];
99
100my $arguments =
101 [ { 'name' => "remove_empty_classifications",
102 'desc' => "{buildcol.remove_empty_classifications}",
103 'type' => "flag",
104 'reqd' => "no",
105 'modegli' => "2" },
106 { 'name' => "archivedir",
107 'desc' => "{buildcol.archivedir}",
108 'type' => "string",
109 'reqd' => "no",
110 'hiddengli' => "yes" },
111 { 'name' => "builddir",
112 'desc' => "{buildcol.builddir}",
113 'type' => "string",
114 'reqd' => "no",
115 'hiddengli' => "yes" },
116# { 'name' => "cachedir",
117# 'desc' => "{buildcol.cachedir}",
118# 'type' => "string",
119# 'reqd' => "no" },
120 { 'name' => "collectdir",
121 'desc' => "{buildcol.collectdir}",
122 'type' => "string",
123 # parsearg left "" as default
124 #'deft' => &util::filename_cat ($ENV{'GSDLHOME'}, "collect"),
125 'reqd' => "no",
126 'hiddengli' => "yes" },
127 { 'name' => "site",
128 'desc' => "{buildcol.site}",
129 'type' => "string",
130 'deft' => "",
131 'reqd' => "no",
132 'hiddengli' => "yes" },
133 { 'name' => "debug",
134 'desc' => "{buildcol.debug}",
135 'type' => "flag",
136 'reqd' => "no",
137 'hiddengli' => "yes" },
138 { 'name' => "faillog",
139 'desc' => "{buildcol.faillog}",
140 'type' => "string",
141 # parsearg left "" as default
142 #'deft' => &util::filename_cat("<collectdir>", "colname", "etc", "fail.log"),
143 'reqd' => "no",
144 'modegli' => "3" },
145 { 'name' => "index",
146 'desc' => "{buildcol.index}",
147 'type' => "string",
148 'reqd' => "no",
149 'modegli' => "3" },
150 { 'name' => "incremental",
151 'desc' => "{buildcol.incremental}",
152 'type' => "flag",
153 'hiddengli' => "yes" },
154 { 'name' => "keepold",
155 'desc' => "{buildcol.keepold}",
156 'type' => "flag",
157 'reqd' => "no",
158 #'modegli' => "3",
159 'hiddengli' => "yes" },
160 { 'name' => "removeold",
161 'desc' => "{buildcol.removeold}",
162 'type' => "flag",
163 'reqd' => "no",
164 #'modegli' => "3",
165 'hiddengli' => "yes" },
166 { 'name' => "language",
167 'desc' => "{scripts.language}",
168 'type' => "string",
169 'reqd' => "no",
170 'modegli' => "3" },
171 { 'name' => "maxdocs",
172 'desc' => "{buildcol.maxdocs}",
173 'type' => "int",
174 'reqd' => "no",
175 'hiddengli' => "yes" },
176 { 'name' => "maxnumeric",
177 'desc' => "{buildcol.maxnumeric}",
178 'type' => "int",
179 'reqd' => "no",
180 'deft' => "4",
181 'range' => "4,512",
182 'modegli' => "3" },
183 { 'name' => "mode",
184 'desc' => "{buildcol.mode}",
185 'type' => "enum",
186 'list' => $mode_list,
187 # parsearg left "" as default
188# 'deft' => "all",
189 'reqd' => "no",
190 'modegli' => "3" },
191 { 'name' => "no_strip_html",
192 'desc' => "{buildcol.no_strip_html}",
193 'type' => "flag",
194 'reqd' => "no",
195 'modegli' => "3" },
196 { 'name' => "store_metadata_coverage",
197 'desc' => "{buildcol.store_metadata_coverage}",
198 'type' => "flag",
199 'reqd' => "no",
200 'modegli' => "3" },
201 { 'name' => "no_text",
202 'desc' => "{buildcol.no_text}",
203 'type' => "flag",
204 'reqd' => "no",
205 'modegli' => "2" },
206 { 'name' => "sections_index_document_metadata",
207 'desc' => "{buildcol.sections_index_document_metadata}",
208 'type' => "enum",
209 'list' => $sec_index_list,
210 'reqd' => "no",
211 'modegli' => "2" },
212 { 'name' => "out",
213 'desc' => "{buildcol.out}",
214 'type' => "string",
215 'deft' => "STDERR",
216 'reqd' => "no",
217 'hiddengli' => "yes" },
218 { 'name' => "verbosity",
219 'desc' => "{buildcol.verbosity}",
220 'type' => "int",
221 # parsearg left "" as default
222 #'deft' => "2",
223 'reqd' => "no",
224 'modegli' => "3" },
225 { 'name' => "gli",
226 'desc' => "",
227 'type' => "flag",
228 'reqd' => "no",
229 'hiddengli' => "yes" },
230 { 'name' => "xml",
231 'desc' => "{scripts.xml}",
232 'type' => "flag",
233 'reqd' => "no",
234 'hiddengli' => "yes" },
235 ];
236
237my $options = { 'name' => "buildcol.pl",
238 'desc' => "{buildcol.desc}",
239 'args' => $arguments };
240
241
242# globals
243my $collection;
244my $configfilename;
245my $out;
246
247# used to signify "gs2"(default) or "gs3"
248my $gs_mode = "gs2";
249
250## @method gsprintf()
251# Print a string to the screen after looking it up from a locale dependant
252# strings file. This function is losely based on the idea of resource
253# bundles as used in Java.
254#
255# @param $error The STDERR stream.
256# @param $text The string containing GS keys that should be replaced with
257# their locale dependant equivilents.
258# @param $out The output stream.
259# @return The locale-based string to output.
260#
261sub gsprintf()
262{
263 return &gsprintf::gsprintf(@_);
264}
265## gsprintf() ##
266
267&main();
268
269## @method main()
270#
271# [Parses up and validates the arguments to the build process before creating
272# the appropriate build process to do the actual work - John]
273#
274# @note Added true incremental support - John Thompson, DL Consulting Ltd.
275# @note There were several bugs regarding using directories other than
276# "import" or "archives" during import and build quashed. - John
277# Thompson, DL Consulting Ltd.
278#
279# @param $incremental If true indicates this build should not regenerate all
280# the index and metadata files, and should instead just
281# append the information found in the archives directory
282# to the existing files. If this requires some complex
283# work so as to correctly insert into a classifier so be
284# it. Of course none of this is done here - instead the
285# incremental argument is passed to the document
286# processor.
287#
288sub main
289{
290 # command line args
291 my ($verbosity, $archivedir, $cachedir, $builddir, $site, $maxdocs,
292 $debug, $mode, $indexname, $removeold, $keepold,
293 $incremental, $incremental_mode,
294 $remove_empty_classifications,
295 $collectdir, $build, $type, $textindex,
296 $no_strip_html, $store_metadata_coverage,
297 $no_text, $faillog, $gli, $index, $language,
298 $sections_index_document_metadata, $maxnumeric);
299
300 my $xml = 0;
301 my $hashParsingResult = {};
302 # general options available to all plugins
303 my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options");
304
305 # If parse returns -1 then something has gone wrong
306 if ($intArgLeftinAfterParsing == -1)
307 {
308 &PrintUsage::print_txt_usage($options, "{buildcol.params}");
309 die "\n";
310 }
311
312 foreach my $strVariable (keys %$hashParsingResult)
313 {
314 eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}";
315 }
316
317 # If $language has been specified, load the appropriate resource bundle
318 # (Otherwise, the default resource bundle will be loaded automatically)
319 if ($language && $language =~ /\S/) {
320 &gsprintf::load_language_specific_resource_bundle($language);
321 }
322
323 if ($xml) {
324 &PrintUsage::print_xml_usage($options);
325 print "\n";
326 return;
327 }
328
329 if ($gli) { # the gli wants strings to be in UTF-8
330 &gsprintf::output_strings_in_UTF8;
331 }
332
333 # now check that we had exactly one leftover arg, which should be
334 # the collection name. We don't want to do this earlier, cos
335 # -xml arg doesn't need a collection name
336 # Or if the user specified -h, then we output the usage also
337 if ($intArgLeftinAfterParsing != 1 || (@ARGV && $ARGV[0] =~ /^\-+h/))
338 {
339 &PrintUsage::print_txt_usage($options, "{buildcol.params}");
340 die "\n";
341 }
342
343 $textindex = "";
344 my $close_out = 0;
345 if ($out !~ /^(STDERR|STDOUT)$/i) {
346 open (OUT, ">$out") ||
347 (&gsprintf(STDERR, "{common.cannot_open_output_file}\n", $out) && die);
348 $out = "buildcol::OUT";
349 $close_out = 1;
350 }
351 $out->autoflush(1);
352
353 # get and check the collection
354 if (($collection = &colcfg::use_collection($site, @ARGV, $collectdir)) eq "") {
355 &PrintUsage::print_txt_usage($options, "{buildcol.params}");
356 die "\n";
357 }
358
359 if ($faillog eq "") {
360 $faillog = &util::filename_cat($ENV{'GSDLCOLLECTDIR'}, "etc", "fail.log");
361 }
362 # note that we're appending to the faillog here (import.pl clears it each time)
363 # this could potentially create a situation where the faillog keeps being added
364 # to over multiple builds (if the import process is being skipped)
365 open (FAILLOG, ">>$faillog") ||
366 (&gsprintf(STDERR, "{common.cannot_open_fail_log}\n", $faillog) && die);
367 $faillog = 'buildcol::FAILLOG';
368 $faillog->autoflush(1);
369
370 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib");
371 # Don't know why this didn't already happen, but now collection specific
372 # classify and plugins directory also added to include path
373 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib/classify");
374 unshift (@INC, "$ENV{'GSDLCOLLECTDIR'}/perllib/plugins");
375
376 # Read in the collection configuration file.
377 my ($collectcfg, $buildtype, $orthogonalbuildtypes);
378 ($configfilename, $gs_mode) = &colcfg::get_collect_cfg_name($out);
379 $collectcfg = &colcfg::read_collection_cfg ($configfilename, $gs_mode);
380
381 # If the infodbtype value wasn't defined in the collect.cfg file, use the default
382 if (!defined($collectcfg->{'infodbtype'}))
383 {
384 $collectcfg->{'infodbtype'} = &dbutil::get_default_infodb_type();
385 }
386
387 if ($verbosity !~ /\d+/) {
388 if (defined $collectcfg->{'verbosity'} && $collectcfg->{'verbosity'} =~ /\d+/) {
389 $verbosity = $collectcfg->{'verbosity'};
390 } else {
391 $verbosity = 2; # the default
392 }
393 }
394 # we use searchtype for determining buildtype, but for old versions, use buildtype
395 if (defined $collectcfg->{'buildtype'}) {
396 $buildtype = $collectcfg->{'buildtype'};
397 } elsif (defined $collectcfg->{'searchtypes'} || defined $collectcfg->{'searchtype'}) {
398 $buildtype = "mgpp";
399 } else {
400 $buildtype = "mg"; #mg is the default
401 }
402
403 if (defined $collectcfg->{'orthogonalbuildtypes'}) {
404 $orthogonalbuildtypes = $collectcfg->{'orthogonalbuildtypes'};
405 }
406
407 if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
408 $archivedir = $collectcfg->{'archivedir'};
409 }
410 if (defined $collectcfg->{'cachedir'} && $cachedir eq "") {
411 $cachedir = $collectcfg->{'cachedir'};
412 }
413 if (defined $collectcfg->{'builddir'} && $builddir eq "") {
414 $builddir = $collectcfg->{'builddir'};
415 }
416 if ($maxdocs !~ /\-?\d+/) {
417 if (defined $collectcfg->{'maxdocs'} && $collectcfg->{'maxdocs'} =~ /\-?\d+/) {
418 $maxdocs = $collectcfg->{'maxdocs'};
419 } else {
420 $maxdocs = -1; # the default
421 }
422 }
423 if (defined $collectcfg->{'maxnumeric'} && $collectcfg->{'maxnumeric'} =~ /\d+/) {
424 $maxnumeric = $collectcfg->{'maxnumeric'};
425 }
426
427 if ($maxnumeric < 4 || $maxnumeric > 512) {
428 $maxnumeric = 4;
429 }
430
431 if (defined $collectcfg->{'debug'} && $collectcfg->{'debug'} =~ /^true$/i) {
432 $debug = 1;
433 }
434 if ($mode !~ /^(all|compress_text|build_index|infodb)$/) {
435 if (defined $collectcfg->{'mode'} && $collectcfg->{'mode'} =~ /^(all|compress_text|build_index|infodb)$/) {
436 $mode = $collectcfg->{'mode'};
437 } else {
438 $mode = "all"; # the default
439 }
440 }
441 if (defined $collectcfg->{'index'} && $indexname eq "") {
442 $indexname = $collectcfg->{'index'};
443 }
444 if (defined $collectcfg->{'no_text'} && $no_text == 0) {
445 if ($collectcfg->{'no_text'} =~ /^true$/i) {
446 $no_text = 1;
447 }
448 }
449 if (defined $collectcfg->{'no_strip_html'} && $no_strip_html == 0) {
450 if ($collectcfg->{'no_strip_html'} =~ /^true$/i) {
451 $no_strip_html = 1;
452 }
453 }
454 if (defined $collectcfg->{'store_metadata_coverage'} && $store_metadata_coverage == 0) {
455 if ($collectcfg->{'store_metadata_coverage'} =~ /^true$/i) {
456 $store_metadata_coverage = 1;
457 }
458 }
459 if (defined $collectcfg->{'remove_empty_classifications'} && $remove_empty_classifications == 0) {
460 if ($collectcfg->{'remove_empty_classifications'} =~ /^true$/i) {
461 $remove_empty_classifications = 1;
462 }
463 }
464
465 if ($buildtype eq "mgpp" && defined $collectcfg->{'textcompress'}) {
466 $textindex = $collectcfg->{'textcompress'};
467 }
468 if (defined $collectcfg->{'gli'} && $collectcfg->{'gli'} =~ /^true$/i) {
469 $gli = 1;
470 }
471
472 if ($sections_index_document_metadata !~ /\S/ && defined $collectcfg->{'sections_index_document_metadata'}) {
473 $sections_index_document_metadata = $collectcfg->{'sections_index_document_metadata'};
474 }
475
476 if ($sections_index_document_metadata !~ /^(never|always|unless_section_metadata_exists)$/) {
477 $sections_index_document_metadata = "never";
478 }
479
480 ($removeold, $keepold, $incremental, $incremental_mode)
481 = &scriptutil::check_removeold_and_keepold($removeold, $keepold,
482 $incremental, "building",
483 $collectcfg);
484
485 $gli = 0 unless defined $gli;
486
487 # New argument to track whether build is incremental
488 $incremental = 0 unless defined $incremental;
489
490 print STDERR "<Build>\n" if $gli;
491
492 #set the text index
493 if (($buildtype eq "mgpp") || ($buildtype eq "lucene")) {
494 if ($textindex eq "") {
495 $textindex = "text";
496 }
497 }
498 else {
499 $textindex = "section:text";
500 }
501
502 # fill in the default archives and building directories if none
503 # were supplied, turn all \ into / and remove trailing /
504
505 my ($realarchivedir, $realbuilddir);
506 # Modified so that the archivedir, if provided as an argument, is made
507 # absolute if it isn't already
508 if ($archivedir eq "")
509 {
510 $archivedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "archives");
511 }
512 else
513 {
514 $archivedir = &util::make_absolute($ENV{'GSDLCOLLECTDIR'}, $archivedir);
515 }
516 # End Mod
517 $archivedir =~ s/[\\\/]+/\//g;
518 $archivedir =~ s/\/$//;
519
520 if ($builddir eq "") {
521 $builddir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "building");
522 if ($incremental) {
523 &gsprintf($out, "{buildcol.incremental_default_builddir}\n");
524 }
525 }
526 $builddir =~ s/[\\\/]+/\//g;
527 $builddir =~ s/\/$//;
528
529 # update the archive cache if needed
530 if ($cachedir) {
531 &gsprintf($out, "{buildcol.updating_archive_cache}\n")
532 if ($verbosity >= 1);
533
534 $cachedir =~ s/[\\\/]+$//;
535 $cachedir .= "/collect/$collection" unless
536 $cachedir =~ /collect\/$collection/;
537
538 $realarchivedir = "$cachedir/archives";
539 $realbuilddir = "$cachedir/building";
540 &util::mk_all_dir ($realarchivedir);
541 &util::mk_all_dir ($realbuilddir);
542 &util::cachedir ($archivedir, $realarchivedir, $verbosity);
543
544 } else {
545 $realarchivedir = $archivedir;
546 $realbuilddir = $builddir;
547 }
548
549 # build it in realbuilddir
550 &util::mk_all_dir ($realbuilddir);
551
552 my ($buildertype, $builderdir, $builder);
553 # if a builder class has been created for this collection, use it
554 # otherwise, use the mg or mgpp builder
555 if (-e "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib/custombuilder.pm") {
556 $builderdir = "$ENV{'GSDLCOLLECTDIR'}/custom/${collection}/perllib";
557 $buildertype = "custombuilder";
558 } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/custombuilder.pm") {
559 $builderdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
560 $buildertype = "custombuilder";
561 } elsif (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}builder.pm") {
562 $builderdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
563 $buildertype = "${collection}builder";
564 } else {
565
566 $builderdir = undef;
567 if ($buildtype ne "") {
568 # caters for extension-based build types, such as 'solr'
569 $buildertype = $buildtype."builder";
570 }
571 else {
572 # Default to mgpp
573 $buildertype = "mgppbuilder";
574 }
575 }
576 # check for extension specific builders
577 # (that will then be run after main builder.pm
578
579 my @builderdir_list = ($builderdir);
580 my @buildertype_list = ($buildertype);
581
582 if (defined $orthogonalbuildtypes) {
583 foreach my $obt (@$orthogonalbuildtypes) {
584
585 push(@builderdir_list,undef); # rely on @INC to find it
586 push(@buildertype_list,$obt."Builder");
587 }
588 }
589
590 # Set up array of the main builder.pm, followed by any ones
591 # from the extension folders
592
593 my $num_builders = scalar(@buildertype_list);
594 my @builders = ();
595
596 for (my $i=0; $i<$num_builders; $i++) {
597 my $this_builder;
598 my $this_buildertype = $buildertype_list[$i];
599 my $this_builderdir = $builderdir_list[$i];
600
601 if ((defined $this_builderdir) && ($this_builderdir ne "")) {
602 require "$this_builderdir/$this_buildertype.pm";
603 }
604 else {
605 require "$this_buildertype.pm";
606 }
607
608 eval("\$this_builder = new $this_buildertype(\$site, \$collection, " .
609 "\$realarchivedir, \$realbuilddir, \$verbosity, " .
610 "\$maxdocs, \$debug, \$keepold, \$incremental, \$incremental_mode, " .
611 "\$remove_empty_classifications, " .
612 "\$out, \$no_text, \$faillog, \$gli)");
613 die "$@" if $@;
614
615 push(@builders,$this_builder);
616 }
617
618 # Init phase for builders
619 for (my $i=0; $i<$num_builders; $i++) {
620 my $this_buildertype = $buildertype_list[$i];
621 my $this_builderdir = $builderdir_list[$i];
622 my $this_builder = $builders[$i];
623
624 $this_builder->init();
625 $this_builder->set_maxnumeric($maxnumeric);
626
627 if (($this_buildertype eq "mgppbuilder") && $no_strip_html) {
628 $this_builder->set_strip_html(0);
629 }
630
631 if ($sections_index_document_metadata ne "never") {
632 $this_builder->set_sections_index_document_metadata($sections_index_document_metadata);
633 }
634
635 if ($store_metadata_coverage) {
636 $this_builder->set_store_metadata_coverage(1);
637 }
638 }
639
640 # Run the requested passes
641
642 if ($mode =~ /^all$/i) {
643
644 # 'map' modifies the elements of the original array, so calling
645 # methods -- as done below -- will cause (by default) @builders
646 # to be changed to whatever these functions return (which is *not*
647 # what we want -- we want to leave the values unchanged)
648 # => Use 'local' (dynamic scoping) to give each 'map' call its
649 # own local copy This could also be done with:
650 # (my $new =$_)->method(); $new
651 # but is a bit more cumbersome to write
652
653 map { local $_=$_; $_->compress_text($textindex); } @builders;
654 map { local $_=$_; $_->build_indexes($indexname); } @builders;
655 map { local $_=$_; $_->make_infodatabase(); } @builders;
656 map { local $_=$_; $_->collect_specific(); } @builders;
657 } elsif ($mode =~ /^compress_text$/i) {
658 map { local $_=$_; $_->compress_text($textindex); } @builders;
659 } elsif ($mode =~ /^build_index$/i) {
660 map { local $_=$_; $_->build_indexes($indexname); } @builders;
661 } elsif ($mode =~ /^infodb$/i) {
662 map { local $_=$_; $_->make_infodatabase(); } @builders;
663 } else {
664 (&gsprintf(STDERR, "{buildcol.unknown_mode}\n", $mode) && die);
665 }
666
667 if (!$debug) {
668 map {local $_=$_; $_->make_auxiliary_files(); } @builders;
669 }
670 map {local $_=$_; $_->deinit(); } @builders;
671
672 if (($realbuilddir ne $builddir) && !$debug) {
673 &gsprintf($out, "{buildcol.copying_back_cached_build}\n")
674 if ($verbosity >= 1);
675 &util::rm_r ($builddir);
676 &util::cp_r ($realbuilddir, $builddir);
677 }
678
679 close OUT if $close_out;
680 close FAILLOG;
681
682 print STDERR "</Build>\n" if $gli;
683}
684
685
686
Note: See TracBrowser for help on using the repository browser.