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

Last change on this file since 25553 was 25553, checked in by sjm84, 12 years ago

If GSDL-RUN-SETUP is set then we want to set up the environment

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