source: trunk/gsdl/bin/script/buildcol.pl@ 12964

Last change on this file since 12964 was 12964, checked in by kjdon, 18 years ago

added a new option: -incremental, which invokes David's archives.inf timestamp stuff. So now you can have -keepold on without using this incremental stuff. eg if import out of differnet directories. buildcol incremental option changed to incremental_dlc, adn commented out. this invokes DLC hierarchy updates which doesn't work at the moment cos we are not compiling up gdbmget/set

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