source: trunk/for-distributions/bin/script/create_distributions.pl@ 13474

Last change on this file since 13474 was 13474, checked in by nzdl, 17 years ago

heaps of changes over the last year and a half, no one has done any committing. So I'll commit this as is - kjdon

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 40.1 KB
Line 
1#!/usr/bin/perl -w
2
3
4BEGIN {
5 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
6 unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
7}
8
9
10# create_distributions.pl creates the following distributions from the gsdl
11# directory pointed to by $GSDLHOME (although it uses the main CVS
12# repository to get the latest source code distribution).
13
14# Windows distribution - gsdl-x.xx-win32.exe
15# Creates directory structure for this - use Installshield to create installer
16
17# Unix distribution - gsdl-x.xx-unix.tgz
18
19# Source distribution - gsdl-x.xx.tgz
20
21# cd-rom distribution = gsdl-x.xx-cdrom.tgz
22# Creates directory structure - use Installshield to create media
23# for writing to cd-rom
24
25# all collections in $GSDLHOME/collect (except modelcol and those
26# explicitly ignored by -ignorecol options):
27# pre-built (collname-prebuilt) .tgz .zip
28# unbuilt (collname) .tgz .zip
29
30
31# creates ChangeLog using `cvs2cl.pl -P -F trunk -r -S -l "-d'date<tomorrow'"
32# where date of last distribution is read from the last line of
33# $GSDLHOME/DistDates or from -ChangeLogDate command line option
34# should use something like cvs2cl.pl ... -l "-r'last_tag' -r'this_tag'" but
35# I can't get cvs to ignore files which contain neither last_tag or this_tag
36# so ChangeLog contains lots of ancient stuff
37
38# sets a cvs tag called gsdl-x_xx-distribution (unless -cvs_tag is set
39# in which case it uses that)
40
41# creates a copy of everything in cvs repository in $tmpdir
42
43# edits /tmp/gsdl/etc/VERSION, /tmp/gsdl/src/w32server/fnord.cpp
44# and /tmp/gsdl/cgi-bin/gsdlsite.cfg to use new version number
45# and default GSDLHOME
46
47# temporary working directory
48my $tmpdir = '/tmp';
49
50# docs directory - up-to-date copy of everything to go in the docs directory
51# (including the README.txt) is expected to live here
52my $docs_dir = '/home/nzdl/gsdl-docs';
53
54my $for_distributions_dir = '/home/nzdl/for-distributions';
55
56# where the windows binaries live (including library.exe and server.exe)
57# this currently relies on being a directory ending in "windows"
58my $winbin = "$ENV{'GSDLHOME'}/bin/windows";
59
60# ditto for linux binaries (don't forget getpw)
61my $linuxbin = "$ENV{'GSDLHOME'}/bin/linux";
62
63# ditto for Mac OS/X binaries
64my $macosxbin = "$ENV{'GSDLHOME'}/bin/darwin";
65
66my $cvsanon = ':pserver:[email protected]:2402/usr/local/global-cvs/gsdl-src';
67
68
69use strict;
70use parsargv;
71use util;
72
73use Cwd;
74
75
76sub print_usage {
77 print STDERR "\n";
78 print STDERR "create_distributions.pl: Packages up Greenstone distributions.\n\n";
79 print STDERR " usage: $0 [options]\n\n";
80 print STDERR " options:\n";
81 print STDERR " -version_num version number of distribution (x.xx)\n";
82 print STDERR " -cvs_tag cvs tag from which to create distributions\n";
83 print STDERR " - if not set latest versions will be used and\n";
84 print STDERR " a tag will be set\n";
85 print STDERR " -no_cdrom don't create cd-rom version\n";
86 print STDERR " -unesco create unesco style release, i.e. only 4 languages enabled\n";
87 print STDERR " -no_cols don't attempt to create any collection distributions\n";
88 print STDERR " -only_cols create collection distributions only\n";
89 print STDERR " -includecol collection to include (by default all collections in\n";
90 print STDERR " $ENV{'GSDLHOME'}/collect will be included\n";
91 print STDERR " -ignorecol directory in $ENV{'GSDLHOME'}/collect to ignore (i.e.\n";
92 print STDERR " don't include as collection in distribution)\n";
93 print STDERR " -output_dir directory to output distributions to\n";
94 print STDERR " -NoChangeLog don't create ChangeLog\n";
95 print STDERR " -UseExistingLog use $ENV{'GSDLHOME'}/ChangeLog rather than creating one\n";
96 print STDERR " -ChangeLogDate date from which to begin ChangeLog - note that ChangeLog\n";
97 print STDERR " will always run from date to most recent commits, even if\n";
98 print STDERR " cvs_tag is for a previous revision\n\n";
99}
100
101&main ();
102
103my $version_num;
104my $cvs_tag;
105my $no_cdrom;
106my $unesco;
107my $no_cols;
108my $only_cols;
109my $nochangelog;
110my $useexistinglog;
111my $changelogdate;
112my $output_dir;
113my @includecols;
114my @ignorecols;
115
116sub main
117{
118 if (!parsargv::parse(\@ARGV,
119 'version_num/\d\.\d\d[a-z]?', \$version_num,
120 'cvs_tag/.*/', \$cvs_tag,
121 'no_cdrom', \$no_cdrom,
122 'unesco', \$unesco,
123 'no_cols', \$no_cols,
124 'only_cols', \$only_cols,
125 'includecol/.*', \@includecols,
126 'ignorecol/.*', \@ignorecols,
127 'NoChangeLog', \$nochangelog,
128 'UseExistingLog', \$useexistinglog,
129 'ChangeLogDate/.*/', \$changelogdate,
130 'output_dir/.*/', \$output_dir)) {
131 &print_usage();
132 die "\n";
133 }
134
135 $output_dir = "." unless $output_dir =~ /\w/;
136 mkdir ($output_dir, 0777) unless -d $output_dir;
137
138 my $have_tag = 0;
139 if ($cvs_tag !~ /\w/) {
140 $cvs_tag = $version_num;
141 $cvs_tag =~ s/\./\_/g;
142 $cvs_tag = "gsdl-" . $cvs_tag . "-distribution";
143 $have_tag = 1;
144 }
145
146 &create_changelog() unless ($nochangelog || $useexistinglog);
147
148 if (!$only_cols) {
149
150 if ($have_tag) {
151 # Tag gsdl repository
152 #chdir ($ENV{'GSDLHOME'});
153 #print STDERR "\ntagging gsdl with $cvs_tag\n";
154 # `cvs tag -F $cvs_tag`;
155
156 # Tag gli repository
157 #chdir (&util::filename_cat($ENV{'GSDLHOME'}, "gli"));
158 #print STDERR "\ntagging gli with $cvs_tag\n";
159 # `cvs tag -F $cvs_tag`;
160 }
161
162 # Export gsdl to $tmpdir
163 print STDERR "\nexporting gsdl ($cvs_tag) to $tmpdir\n\n";
164 chdir($tmpdir);
165 # `cvs -d $cvsanon export -r $cvs_tag gsdl`;
166 `cvs -d $cvsanon export -D "1 second ago" gsdl`;
167 #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gsdl`;
168
169 # Export gli to $tmpdir/gli
170 print STDERR "\nexporting gli ($cvs_tag) to " . &util::filename_cat($tmpdir, "gsdl") . "\n\n";
171 chdir(&util::filename_cat($tmpdir, "gsdl"));
172 # `cvs -d $cvsanon export -r $cvs_tag gli`;
173 `cvs -d $cvsanon export -D "1 second ago" gli`;
174 #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gli`;
175
176 # Compile gli
177 print STDERR "\ncompiling gli...\n";
178 chdir(&util::filename_cat($tmpdir, "gsdl", "gli"));
179 `./makegli.sh`;
180
181 # JAR up the gli, then delete the class files
182 print STDERR "jarring gli...\n";
183 `./makejar.sh`;
184 &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "jar"));
185 &util::rm(&util::filename_cat($tmpdir, "gsdl", "gli", "metadata.zip"));
186 &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "classes", "org"));
187
188 # Move the GLIServer.jar file created by makejar.sh into bin/java
189 &util::mv(&util::filename_cat($tmpdir, "gsdl", "gli", "GLIServer.jar"),
190 &util::filename_cat($tmpdir, "gsdl", "bin", "java"));
191
192 # Remove bits used by none of the distributions
193 &util::rm(&util::filename_cat($tmpdir, "gsdl", "packages", "cpan", "XML-Parser-2.27.tar.gz"));
194
195 # copy ChangeLog into $tmpdir/gsdl
196 &util::cp(&util::filename_cat($ENV{'GSDLHOME'}, "ChangeLog"),
197 &util::filename_cat($tmpdir, "gsdl")) unless $nochangelog;
198
199 # edit the VERSION and fnord.cpp files
200 &edit_files();
201
202 &create_unix_distribution();
203 &create_source_distribution();
204 &create_cdrom_distribution() unless $no_cdrom;
205 }
206
207 # &create_collection_distributions() unless $no_cols;
208}
209
210
211sub create_unix_distribution
212{
213 print STDERR "Creating Unix distribution...\n";
214
215 my $unix_dist_dir = &util::filename_cat($output_dir, "gsdl-" . $version_num . "-unix");
216 mkdir ($unix_dist_dir, 0777);
217
218 # Web release has a slightly customised version of Install.sh
219 &util::cp(&util::filename_cat($tmpdir, "gsdl", "Install.sh"), $unix_dist_dir);
220 my $Install_sh_file = &util::filename_cat($unix_dist_dir, "Install.sh");
221 open (INSTALL_SH, $Install_sh_file) || die "Failed to open $Install_sh_file\n";
222 my $found = 0; my $line = ""; my $file = "";
223 while (defined ($line = <INSTALL_SH>)) {
224 if ($line =~ /^iscdrom=\"/) {
225 $line = "iscdrom=\"no\"\n";
226 $found = 1;
227 }
228 $file .= $line;
229 }
230 close INSTALL_SH;
231
232 if ($found != 1) {
233 die "Error while editing $Install_sh_file\n";
234 }
235
236 open (INSTALL_SH, ">$Install_sh_file") || die;
237 print INSTALL_SH $file;
238 close INSTALL_SH;
239}
240
241
242sub create_source_distribution
243{
244 print STDERR "Creating Source distribution...\n";
245
246 my $source_dist_dir = &util::filename_cat($output_dir, "gsdl-" . $version_num . "-src");
247 mkdir($source_dist_dir, 0777);
248
249 my $gsdldir = &util::filename_cat ($source_dist_dir, "gsdl");
250
251 # Copy the entire contents of the exported GSDL directory
252 my $tmpgsdldir = &util::filename_cat($tmpdir, "gsdl");
253 `cp -r $tmpgsdldir $source_dist_dir`;
254
255 # We want the COPYING file in the source distribution too
256 &util::cp(&util::filename_cat($docs_dir, "COPYING"), $gsdldir);
257
258 # We shouldn't distribute the GLI applet signed by us
259 if (-e &util::filename_cat($source_dist_dir, "gsdl", "bin", "java", "SignedGatherer.jar")) {
260 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "bin", "java", "SignedGatherer.jar"));
261 }
262
263 # Don't need the "images/garish" directory for web releases
264 #&util::rm_r(&util::filename_cat($gsdldir, "images", "garish"));
265
266 # Remove the copied "macros" folder and copy over just the core language macros
267 #my $gsdlmacrosdir = &util::filename_cat($source_dist_dir, "gsdl", "macros");
268 #&util::rm_r($gsdlmacrosdir);
269 #&install_only_core_language_macros(&util::filename_cat($tmpdir, "gsdl", "macros"), $gsdlmacrosdir);
270
271 # We don't want the compiled GLI classes in the source distribution (or the GS3 scripts)
272 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", ".greenstonestore"));
273 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "GLI.jar"));
274 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "gli4gs3.bat"));
275 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "gli4gs3.sh"));
276
277 # (We don't include the built demo collection in the source distribution)
278}
279
280
281sub create_cdrom_distribution
282{
283 print STDERR "Creating CD-ROM distribution...\n";
284
285 my $cdrom_dist_dir = &util::filename_cat ($output_dir, "gsdl-" . $version_num . "-cdrom");
286 mkdir ($cdrom_dist_dir, 0777);
287
288 # docs directory
289 &install_docs ($cdrom_dist_dir, 0);
290
291 # gsdl directory
292 &install_gsdl ($cdrom_dist_dir);
293
294 # gli directory (in gsdl)
295 &install_gli($cdrom_dist_dir, "cdrom");
296
297 # src directory
298 &install_src ($cdrom_dist_dir, "cdrom");
299
300 # Windows directory
301 &install_windows_specific ($cdrom_dist_dir, 1);
302
303 # Unix directory
304 &install_unix_specific ($cdrom_dist_dir);
305
306 # for the cd-rom we want to include the unbuilt bits of the demo collection too
307 my $demodir = &util::filename_cat($cdrom_dist_dir, "gsdl", "collect", "demo");
308 my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
309 die "oops, no demo dir\n" unless -d $demodir;
310 &util::cp (&util::filename_cat ($tmpdemo, "demo.col"), $demodir);
311 &util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
312 &util::cp_r (&util::filename_cat ($tmpdemo, "metadata"), $demodir);
313
314 # collect directory, with documented example collections and customised home.dm file
315 # no longer use customised home.dm
316 my $cdrom_collect_dir = &util::filename_cat ($cdrom_dist_dir, "collect");
317 mkdir($cdrom_collect_dir, 0777);
318
319 my $source_collect_dir = &util::filename_cat($for_distributions_dir, "collect");
320 my $target_collect_dir = &util::filename_cat($cdrom_dist_dir, "collect");
321
322# *****
323 &util::cp_r(&util::filename_cat($source_collect_dir, "MARC-e"), $target_collect_dir);
324 &util::cp_r(&util::filename_cat($source_collect_dir, "authen-e"), $target_collect_dir);
325 &util::cp_r(&util::filename_cat($source_collect_dir, "cltbib-e"), $target_collect_dir);
326 &util::cp_r(&util::filename_cat($source_collect_dir, "cltext-e"), $target_collect_dir);
327 &util::cp_r(&util::filename_cat($source_collect_dir, "dls-e"), $target_collect_dir);
328 &util::cp_r(&util::filename_cat($source_collect_dir, "garish"), $target_collect_dir);
329 &util::cp_r(&util::filename_cat($source_collect_dir, "gsarch-e"), $target_collect_dir);
330 &util::cp_r(&util::filename_cat($source_collect_dir, "image-e"), $target_collect_dir);
331 &util::cp_r(&util::filename_cat($source_collect_dir, "isis-e"), $target_collect_dir);
332 &util::cp_r(&util::filename_cat($source_collect_dir, "oai-e"), $target_collect_dir);
333 &util::cp_r(&util::filename_cat($source_collect_dir, "wrdpdf-e"), $target_collect_dir);
334 &util::cp_r(&util::filename_cat($source_collect_dir, "dspace-e"), $target_collect_dir);
335 &util::cp_r(&util::filename_cat($source_collect_dir, "style-e"), $target_collect_dir);
336 &util::cp_r(&util::filename_cat($source_collect_dir, "pagedimg-e"), $target_collect_dir);
337 # The customised home.dm file must have a modified date after the gsdl/macros/home.dm file
338 # no longer use customised home.dm
339 #&util::cp(&util::filename_cat($for_distributions_dir, "macros", "home.dm"), $cdrom_collect_dir);
340
341 # Make sure the whole thing is user-writeable
342 `chmod -R u+rw $cdrom_dist_dir`;
343}
344
345
346# isweb is 1 if it's one of the web distributions (i.e. if we don't
347# want to install the manuals) - this shouldn't be called at all for
348# windows web installation as it doesn't use docs at all (not much
349# point for self-extracting exe).
350sub install_docs {
351 my ($install_dir, $isweb) = @_;
352
353 # COPYING, README*.txt and Support.htm
354 &util::cp (&util::filename_cat($docs_dir, "COPYING"), $install_dir);
355 &util::cp (&util::filename_cat($docs_dir, "READMEen.txt"), $install_dir);
356 &util::cp (&util::filename_cat($docs_dir, "READMEes.txt"), $install_dir);
357 &util::cp (&util::filename_cat($docs_dir, "READMEfr.txt"), $install_dir);
358 &util::cp (&util::filename_cat($docs_dir, "READMEru.txt-cp1251"), $install_dir);
359 &util::cp (&util::filename_cat($docs_dir, "READMEru.txt-koi8-r"), $install_dir);
360 &util::cp (&util::filename_cat($docs_dir, "Support.htm"), $install_dir);
361
362 &force_windows_line_endings(&util::filename_cat($install_dir, "COPYING"));
363 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEen.txt"));
364 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEes.txt"));
365 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEfr.txt"));
366
367 # The web distributions don't have any of the manuals
368 return if ($isweb);
369
370 # docs directory, but not any of the Word files or Latex files
371 &util::cp_r (&util::filename_cat($docs_dir, "docs"), $install_dir);
372 my $en_docs = &util::filename_cat ($install_dir, "docs", "english", "*.doc");
373 `rm $en_docs`;
374 my $es_docs = &util::filename_cat ($install_dir, "docs", "spanish", "*.doc");
375 `rm $es_docs`;
376 my $ru_docs = &util::filename_cat ($install_dir, "docs", "russian", "*.doc");
377 `rm $ru_docs`;
378 my $fr_latex = &util::filename_cat ($install_dir, "docs", "french", "latex");
379 `rm -r $fr_latex`;
380}
381
382
383sub install_gsdl {
384 my ($install_dir) = @_;
385
386 my $gsdldir = &util::filename_cat ($install_dir, "gsdl");
387 mkdir ($gsdldir, 0777);
388
389 my $gsdlbindir = &util::filename_cat ($gsdldir, "bin");
390 mkdir ($gsdlbindir, 0777);
391 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "script"), $gsdlbindir);
392 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "java"), $gsdlbindir);
393 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "cgi-bin"), $gsdldir);
394 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "collect"), $gsdldir);
395 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "etc"), $gsdldir);
396
397 #Get the modified main.cfg file with only core language interfaces enabled
398 if ($unesco) {
399 &util::cp(&util::filename_cat($for_distributions_dir, "etc", "main.cfg"), &util::filename_cat($gsdldir, "etc"));
400 }
401 # Make sure everything in bin/script is executable
402 my $bin_script_dir = &util::filename_cat($gsdldir, "bin", "script");
403 `chmod a+x $bin_script_dir/*`;
404
405 # Make sure cgi scripts are executable
406 my $gliserver_script = &util::filename_cat($gsdldir, "cgi-bin", "gliserver.pl");
407 `chmod a+x $gliserver_script`;
408 # should we be doing these ones - usability feedback scripts ??
409 #my $perl_script = &util::filename_cat($gsdldir, "cgi-bin", "perl.cgi");
410 #`chmod a+x $perl_script`;
411 #my $readresults_script = &util::filename_cat($gsdldir, "cgi-bin", "readresults.cgi");
412 #`chmod a+x $readresults_script`;
413 #my $trackreport_script = &util::filename_cat($gsdldir, "cgi-bin", "trackreport.cgi");
414 #`chmod a+x $trackreport_script`;
415
416 &force_windows_line_endings(&util::filename_cat($gsdldir, "cgi-bin", "gsdlsite.cfg"));
417 &force_windows_line_endings(&util::filename_cat($gsdldir, "etc", "main.cfg"));
418 &force_windows_line_endings(&util::filename_cat($gsdldir, "etc", "oai.cfg"));
419
420 # Make sure certain files in the etc directory are writeable by everyone
421 my $error_txt_file = &util::filename_cat($gsdldir, "etc", "error.txt");
422 `chmod a+w $error_txt_file`;
423 my $history_db_file = &util::filename_cat($gsdldir, "etc", "history.db");
424 `chmod a+w $history_db_file`;
425 my $key_db_file = &util::filename_cat($gsdldir, "etc", "key.db");
426 `chmod a+w $key_db_file`;
427 my $main_cfg_file = &util::filename_cat($gsdldir, "etc", "main.cfg");
428 `chmod a+w $main_cfg_file`;
429 my $usage_txt_file = &util::filename_cat($gsdldir, "etc", "usage.txt");
430 `chmod a+w $usage_txt_file`;
431 my $users_db_file = &util::filename_cat($gsdldir, "etc", "users.db");
432 `chmod a+rw $users_db_file`; # Readable too
433
434 # We shouldn't distribute the GLI applet signed by us
435 if (-e &util::filename_cat($gsdlbindir, "java", "SignedGatherer.jar")) {
436 &util::rm(&util::filename_cat($gsdlbindir, "java", "SignedGatherer.jar"));
437 }
438
439 # Install all images (non-core languages are now not included)
440 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "images"), $gsdldir);
441
442 #my $gsdlmacrosdir = &util::filename_cat ($gsdldir, "macros");
443 #&install_only_core_language_macros(&util::filename_cat($tmpdir, "gsdl", "macros"), $gsdlmacrosdir);
444 # Install all macrofiles now
445 &util::cp_r(&util::filename_cat ($tmpdir, "gsdl", "macros"), $gsdldir);
446 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "mappings"), $gsdldir);
447 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "perllib"), $gsdldir);
448
449 # Rename perllib/strings.properties to perllib/strings_en.properties
450 my $stringsrbfile = &util::filename_cat ($gsdldir, "perllib", "strings.properties");
451 &util::cp ($stringsrbfile, &util::filename_cat ($gsdldir, "perllib", "strings_en.properties"));
452 &util::rm ($stringsrbfile);
453 `touch $stringsrbfile`;
454
455 # Untar Ping.tgz and XML-Parser.tar.gz
456 my $wd = cwd;
457 chdir (&util::filename_cat($gsdldir, "perllib", "cpan"));
458 `tar xvzf Ping.tgz`;
459 unlink ("Ping.tgz");
460 &util::cp(&util::filename_cat($for_distributions_dir, "perllib", "cpan", "XML-Parser.tar.gz"),
461 &util::filename_cat($gsdldir, "perllib", "cpan"));
462 `tar xvzf XML-Parser.tar.gz`;
463 unlink ("XML-Parser.tar.gz");
464 chdir ($wd);
465
466 # make sure that modelcol collection contains all the right
467 # empty directories
468 my $modelindex = &util::filename_cat ($gsdldir, "collect", "modelcol", "index");
469 &util::mk_all_dir ($modelindex) unless -d $modelindex;
470 my $modelbuilding = &util::filename_cat ($gsdldir, "collect", "modelcol", "building");
471 &util::mk_all_dir ($modelbuilding) unless -d $modelbuilding;
472 my $modelarchives = &util::filename_cat ($gsdldir, "collect", "modelcol", "archives");
473 &util::mk_all_dir ($modelarchives) unless -d $modelarchives;
474 my $modelimport = &util::filename_cat ($gsdldir, "collect", "modelcol", "import");
475 &util::mk_all_dir ($modelimport) unless -d $modelimport;
476 my $modelperllib = &util::filename_cat ($gsdldir, "collect", "modelcol", "perllib");
477 &util::mk_all_dir ($modelperllib) unless -d $modelperllib;
478 my $modelimages = &util::filename_cat ($gsdldir, "collect", "modelcol", "images");
479 &util::mk_all_dir ($modelimages) unless -d $modelimages;
480
481 # demo collection needs to be pre-built
482 my $collectdir = &util::filename_cat ($gsdldir, "collect");
483 &util::rm_r (&util::filename_cat($collectdir, "demo"));
484 if (!&get_built_collection ("demo", $collectdir)) {
485 die "Couldn't get built version of demo collection\n";
486 }
487#******
488 if ($unesco) {
489 # Get modified version of demo collect.cfg file with only core language strings
490 &util::cp(&util::filename_cat($for_distributions_dir, "collect", "demo", "etc", "collect.cfg"),
491 &util::filename_cat($collectdir, "demo", "etc"));
492 }
493}
494
495# no longer used!
496sub install_only_core_language_macros
497{
498 my ($source_dir, $target_dir) = @_;
499 mkdir($target_dir, 0777);
500
501 # Language independent (theoretically) macrofiles
502 my @basicmacrofiles = ("about.dm", "authen.dm", "base.dm", "browse.dm", "bsummary.dm",
503 "collect.dm", "dateqry.dm", "docs.dm", "document.dm",
504 "exported_home.dm", "extlink.dm", "extra.dm",
505 "garish.dm", "gli.dm", "gsdl.dm", "gti.dm", "help.dm", "home.dm", "html.dm", "nav_css.dm",
506 "nzdlhome.dm", "pref.dm", "query.dm", "status.dm", "style.dm",
507 "tip.dm", "users.dm", "yourhome.dm");
508
509 # Core language (English, French, Spanish, Russian) macrofiles
510 my @corelanguagemacrofiles = ("english.dm", "english2.dm", "french.dm", "french2.dm",
511 "spanish.dm", "spanish2.dm", "russian.dm", "russian2.dm",
512 "yourhome-es.dm", "yourhome-fr.dm");
513
514 # Copy the macrofiles
515 foreach my $file ((@basicmacrofiles, @corelanguagemacrofiles)) {
516 &util::cp(&util::filename_cat($source_dir, $file), $target_dir);
517 }
518}
519
520
521sub install_gli
522{
523 my ($install_dir, $type) = @_;
524
525 # Copy the Greenstone Librarian Interface
526 my $source_dir = &util::filename_cat($tmpdir, "gsdl", "gli");
527 my $target_dir = &util::filename_cat($install_dir, "gsdl");
528 &util::cp_r($source_dir, $target_dir);
529
530 my $gli_dir = &util::filename_cat($target_dir, "gli");
531 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEen.txt"));
532 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEes.txt"));
533 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEfr.txt"));
534
535 # Make Unix scripts executable
536 `chmod a+x $gli_dir/*.sh`;
537
538 # Copy dictionary.properties to dictionary_en.properties to prevent problems with non-English machines
539 &util::cp(&util::filename_cat($gli_dir, "classes", "dictionary.properties"),
540 &util::filename_cat($gli_dir, "classes", "dictionary_en.properties"));
541
542 if ($unesco) {
543 # Copy the customised languages.xml file with only core languages enabled
544 &util::cp(&util::filename_cat($for_distributions_dir, "gli", "classes", "xml", "languages.xml"),
545 &util::filename_cat($gli_dir, "classes", "xml"));
546 }
547 # Remove unwanted stuff - all distributions
548 &util::rm(&util::filename_cat($gli_dir, ".greenstonestore"));
549
550 # Don't need Greenstone 3 scripts
551 &util::rm(&util::filename_cat($gli_dir, "gli4gs3.bat"));
552 &util::rm(&util::filename_cat($gli_dir, "gli4gs3.sh"));
553
554 # Remove unwanted stuff - Unix distributions
555 if ($type eq "unix") {
556 # Don't need Windows scripts
557 &util::rm(&util::filename_cat($gli_dir, "clean.bat"));
558 &util::rm(&util::filename_cat($gli_dir, "document.bat"));
559 &util::rm(&util::filename_cat($gli_dir, "gems.bat"));
560 &util::rm(&util::filename_cat($gli_dir, "gli.bat"));
561 &util::rm(&util::filename_cat($gli_dir, "makegli.bat"));
562
563 # Don't need Windows utilities
564 &util::rm_r(&util::filename_cat($gli_dir, "winutil"));
565
566 # Don't need Windows README file
567 &util::rm(&util::filename_cat($gli_dir, "READMEru.txt-cp1251"));
568
569 # Rename Unix README file
570 &util::cp(&util::filename_cat($gli_dir, "READMEru.txt-koi8-r"),
571 &util::filename_cat($gli_dir, "READMEru.txt"));
572 &util::rm(&util::filename_cat($gli_dir, "READMEru.txt-koi8-r"));
573 }
574
575 # Remove unwanted stuff - Windows distributions
576 if ($type eq "windows") {
577 # Don't need Unix scripts
578 &util::rm(&util::filename_cat($gli_dir, "clean.sh"));
579 &util::rm(&util::filename_cat($gli_dir, "document.sh"));
580 &util::rm(&util::filename_cat($gli_dir, "gems.sh"));
581 &util::rm(&util::filename_cat($gli_dir, "gli.sh"));
582 &util::rm(&util::filename_cat($gli_dir, "makegli.sh"));
583 &util::rm(&util::filename_cat($gli_dir, "makejar.sh"));
584 }
585}
586
587
588sub install_src {
589 my ($install_dir, $type) = @_;
590
591 my $srcdir = &util::filename_cat ($install_dir, "src");
592 my $srcwindir = &util::filename_cat ($srcdir, "Windows");
593 my $srcunixdir = &util::filename_cat ($srcdir, "Unix");
594 mkdir ($srcdir, 0777);
595 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "lib"), $srcdir);
596 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "packages"), $srcdir);
597 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "src"), $srcdir);
598 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Install.txt"), $srcdir);
599 &force_windows_line_endings(&util::filename_cat($srcdir, "Install.txt"));
600
601 if ($type ne "unix") {
602 mkdir ($srcwindir, 0777);
603 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bat"), $srcwindir);
604 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "win32.mak"), $srcwindir);
605 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "WIN32cfg.h"), $srcwindir);
606 }
607
608 if ($type ne "windows") {
609 mkdir ($srcunixdir, 0777);
610 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Makefile.in"), $srcunixdir);
611 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "acconfig.h"), $srcunixdir);
612 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "aclocal.m4"), $srcunixdir);
613 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.h.in"), $srcunixdir);
614 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configtest.pl"), $srcunixdir);
615 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure"), $srcunixdir);
616 # make sure configure and setup scripts are executable
617 my $configure_script = &util::filename_cat ($srcunixdir , "configure");
618 `chmod a+x $configure_script`;
619
620 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure.in"), $srcunixdir);
621 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.sub"), $srcunixdir);
622 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.guess"), $srcunixdir);
623 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "install-sh"), $srcunixdir);
624 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bash"), $srcunixdir);
625 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.csh"), $srcunixdir);
626 `chmod a+x $srcunixdir/setup.*`;
627
628 # get all the configure scripts
629 `cd $srcdir; find -name "configure" -exec chmod a+x {} \\; ; cd -`
630
631 }
632}
633
634# if $cd_rom is not true then we don't want to include the net16, net32,
635# Win32s or netscape directories in the bin/windows directory (note that
636# this currently means exportcol.pl will fail for all but cd-rom installed
637# distributions)
638sub install_windows_specific {
639 my ($install_dir, $cd_rom) = @_;
640
641 my $windir = &util::filename_cat ($install_dir, "Windows");
642 my $winbindir = &util::filename_cat ($windir, "bin");
643 mkdir ($windir, 0777);
644 mkdir ($winbindir, 0777);
645 &util::cp_r ($winbin, $winbindir);
646
647 if (!$cd_rom) {
648 &util::rm_r (&util::filename_cat ($winbindir, "windows", "Win32s"));
649 &util::rm_r (&util::filename_cat ($winbindir, "windows", "netscape"));
650 }
651
652 # make sure there aren't any CVS directories laying around
653 &remove_cvs_dirs ($windir);
654}
655
656sub install_unix_specific {
657 my ($install_dir) = @_;
658
659 my $unixdir = &util::filename_cat ($install_dir, "Unix");
660 my $unixbindir = &util::filename_cat ($unixdir, "bin");
661 mkdir ($unixdir, 0777);
662 mkdir ($unixbindir, 0777);
663 &util::cp (&util::filename_cat($tmpdir, "gsdl", "Install.sh"), $unixdir);
664
665 # make sure Install.sh is executable
666 my $install_sh = &util::filename_cat($unixdir, "Install.sh");
667 `chmod a+x $install_sh`;
668
669 # Get Linux binaries, and make sure they're all executable
670 &util::cp_r ($linuxbin, $unixbindir);
671 my $linuxbindir = &util::filename_cat($unixbindir, 'linux');
672 `chmod -R a+x $linuxbindir`;
673
674 # remove the non-static mgquery_old program from distributions
675 &util::rm(&util::filename_cat($linuxbindir, "mgquery_old"));
676
677 # Get Mac OS/X binaries, and make sure they're all executable
678 &util::cp_r ($macosxbin, $unixbindir);
679 my $macosxbindir = &util::filename_cat($unixbindir, 'darwin');
680 `chmod -R a+x $macosxbindir`;
681
682 # make sure there aren't any CVS directories laying around
683 &remove_cvs_dirs ($unixdir);
684}
685
686sub create_collection_distributions {
687
688 # work out which collections we want
689 my @cols = ();
690 if (scalar @includecols) {
691 @cols = @includecols;
692 } else {
693 my $collectdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect");
694
695 opendir (COLLECTDIR, $collectdir) || die;
696 my @cdirs = readdir COLLECTDIR;
697 closedir COLLECTDIR;
698 my %ignore = ();
699 map { $ignore{$_} = ""; } @ignorecols;
700 foreach my $d (@cdirs) {
701 if ((-d &util::filename_cat($collectdir, $d)) && ($d ne ".") && ($d ne "..") &&
702 ($d ne "modelcol") && ($d ne "CVS") && (!defined $ignore{$d})) {
703 push (@cols, $d);
704 }
705 }
706 }
707
708 return unless scalar @cols;
709
710 # create distributions
711 foreach my $collection (@cols) {
712 if (&get_built_collection ($collection, $tmpdir)) {
713 &zip ("$collection-prebuilt", $collection, $tmpdir, 0);
714 &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.tgz"), $output_dir);
715 &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.zip"), $output_dir);
716 } else {
717 print STDERR "ERROR: Couldn't create pre-built $collection collection\n";
718 }
719 &util::rm_r (&util::filename_cat ($tmpdir, $collection))
720 if -d &util::filename_cat ($tmpdir, $collection);
721
722 if (&get_unbuilt_collection ($collection, $tmpdir)) {
723 &zip ($collection, $collection, $tmpdir, 0);
724 &util::cp (&util::filename_cat($tmpdir, "$collection.tgz"), $output_dir);
725 &util::cp (&util::filename_cat($tmpdir, "$collection.zip"), $output_dir);
726 } else {
727 print STDERR "ERROR: Couldn't create unbuilt $collection collection\n";
728 }
729 &util::rm_r (&util::filename_cat ($tmpdir, $collection))
730 if -d &util::filename_cat ($tmpdir, $collection);
731 }
732}
733
734# gets all the right bits of a built collection from
735# $GSDLHOME/collect and copies them to $collect_dir
736# returns 1 if successful, 0 if not
737sub get_built_collection {
738 my ($colname, $collect_dir) = @_;
739
740 my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
741 if (!-d $from_dir) {
742 print STDERR "\nERROR: No collection at $from_dir\n";
743 return 0;
744 }
745
746 my $to_dir = &util::filename_cat ($collect_dir, $colname);
747 mkdir ($to_dir, 0777) unless -d $to_dir;
748
749 # get the built indexes
750 my $index_dir = &util::filename_cat ($from_dir, "index");
751 if (-d $index_dir) {
752 # if build.cfg exists we'll assume collection is built ok
753 if (-e &util::filename_cat ($index_dir, "build.cfg")) {
754 &util::cp_r ($index_dir, $to_dir);
755 } else {
756 print STDERR "\nERROR: no build.cfg at $index_dir (collection not built?)\n";
757 rmdir ($to_dir);
758 return 0;
759 }
760 } else {
761 print STDERR "\nERROR: collection at $from_dir appears unbuilt (no index directory)\n";
762 return 0;
763 }
764 &util::cp_r ($index_dir, $to_dir);
765
766 # get the collect.cfg file
767 mkdir (&util::filename_cat($to_dir, "etc"), 0777);
768 &util::cp (&util::filename_cat($from_dir, "etc", "collect.cfg"),
769 &util::filename_cat($to_dir, "etc"));
770
771 # get the images directory
772 my $from_images = &util::filename_cat ($from_dir, "images");
773 &util::cp_r ($from_images, $to_dir) if -d $from_images;
774
775 # make sure there aren't any CVS directories laying around
776 &remove_cvs_dirs ($to_dir);
777
778 &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
779 &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), 0);
780
781 return 1;
782}
783
784# gets all the right bits of an unbuilt collection from
785# $GSDLHOME/collect and copies them to $collect_dir
786# returns 1 if successful, 0 if not
787sub get_unbuilt_collection {
788 my ($colname, $collect_dir) = @_;
789
790 my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
791 if (!-d $from_dir) {
792 print STDERR "\nERROR: No collection at $from_dir\n";
793 return 0;
794 }
795
796 my $to_dir = &util::filename_cat ($collect_dir, $colname);
797 mkdir ($to_dir, 0777) unless -d $to_dir;
798
799 # get the unbuilt data (either import or archives)
800 my $have_import = 0;
801 my $import_dir = &util::filename_cat ($from_dir, "import");
802 if (-d $import_dir && opendir (IMPORTDIR, $import_dir)) {
803 my @importfiles = readdir IMPORTDIR;
804 closedir IMPORTDIR;
805 # if the import directory isn't empty we'll assume everything's ok
806 if (scalar @importfiles) {
807 $have_import = 1;
808 &util::cp_r ($import_dir, $to_dir);
809 mkdir (&util::filename_cat ($to_dir, "archives"), 0777);
810 }
811 }
812 if (!$have_import) {
813 # see if we've got archives then (check for archives.inf)
814 if (-e &util::filename_cat ($from_dir, "archives", "archives.inf")) {
815 &util::cp_r (&util::filename_cat($from_dir, "archives"), $to_dir);
816 } else {
817
818 print STDERR "$colname collection appears to have no valid\n";
819 print STDERR "import or archives data\n";
820 &util::rm_r ($to_dir);
821 return 0;
822 }
823 }
824
825 # get the etc directory
826 &util::cp_r (&util::filename_cat ($from_dir, "etc"), $to_dir);
827
828 # get the perllib directory
829 &util::cp_r (&util::filename_cat ($from_dir, "perllib"), $to_dir);
830
831 # get the images
832 &util::cp_r (&util::filename_cat ($from_dir, "images"), $to_dir);
833
834 mkdir (&util::filename_cat ($to_dir, "building"), 0777);
835 mkdir (&util::filename_cat ($to_dir, "index"), 0777);
836
837 # make sure there aren't any CVS directories laying around
838 &remove_cvs_dirs ($to_dir);
839
840 &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
841 my $preimported = 0;
842 $preimported = 1 unless $have_import;
843 &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), $preimported);
844
845 return 1;
846}
847
848
849sub force_windows_line_endings
850{
851 my ($filepath) = @_;
852
853 open(IN, "<$filepath");
854 my $text = join('', <IN>);
855 close(IN);
856
857 $text =~ s/\n\x0A/\n\x0D\x0A/g;
858 $text =~ s/([^\x0D])\x0A/$1\x0D\x0A/g;
859
860 open(OUT, ">$filepath");
861 print OUT "$text";
862 close(OUT);
863}
864
865
866sub create_changelog {
867
868 my ($tag, $date, $file);
869
870 my $datefile = &util::filename_cat ($for_distributions_dir, "DistDates");
871 if ($changelogdate !~ /\w/) {
872 # get date from for-distributions/DistDates (and update DistDates)
873 open (DATES, $datefile) || die "can't open $datefile\n";
874 my $line = "";
875 while (defined ($line = <DATES>)) {
876 if ($line =~ /\w/) {
877 ($tag, $date) = $line =~ /^(\S+)\t(.*)$/;
878 $changelogdate = $date unless ($tag eq $cvs_tag);
879 }
880 $file .= $line;
881 }
882 close DATES;
883 }
884
885 if ((!defined $tag) || ($tag ne $cvs_tag)) {
886 open (DATES, ">$datefile") || die;
887 print DATES $file if defined $file;
888 print DATES "$cvs_tag\t" . `date`;
889 close DATES;
890 }
891
892 print STDERR "Creating ChangeLog from $changelogdate to most recent\n";
893
894 chdir($ENV{'GSDLHOME'});
895 my $cmd = "$for_distributions_dir/bin/script/cvs2cl.pl -P -F trunk -r -S -l \"-d'$changelogdate<tomorrow'\"";
896 system ($cmd);
897}
898
899# edits the gsdlsite.cfg file to set GSDLHOME
900# makes a copy of the initial version of gsdlsite.cfg in
901# /tmp (if it doesn't exist already).
902# sub edit_gsdlsite {
903# my ($gsdlhome) = @_;
904
905# my $gsdlsite_file = &util::filename_cat ($tmpdir, "gsdl", "cgi-bin", "gsdlsite.cfg");
906# my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
907
908# if (-e $tmp_gsdlsite_file) {
909# &util::cp ($tmp_gsdlsite_file, $gsdlsite_file);
910# } else {
911# &util::cp ($gsdlsite_file, $tmp_gsdlsite_file);
912# }
913
914# open (GSDLSITE, $gsdlsite_file) || die;
915# my $line = ""; my $file = ""; my $found = 0;
916# while (defined ($line = <GSDLSITE>)) {
917# if ($line =~ s/\*\*GSDLHOME\*\*/$gsdlhome/g) {
918# $found = 1;
919# }
920# $file .= $line;
921# }
922# close GSDLSITE;
923
924# if (!$found) {
925# die "ERROR: $gsdlsite_file contains no **GSDLHOME** string\n";
926# }
927
928# open (GSDLSITE, ">$gsdlsite_file") || die;
929# print GSDLSITE $file;
930# close GSDLSITE;
931# }
932
933# currently just checks that iconcollection fields are correct and that
934# creator and maintainer fields are set to [email protected]
935sub edit_collect_cfg {
936 my ($collect_cfg_file, $collname) = @_;
937
938 open (FILE, $collect_cfg_file) || die "couldn't open $collect_cfg_file\n";
939 my $line = ""; my $file = "";
940 while (defined ($line = <FILE>)) {
941 $line =~ s/^((?:creator|maintainer)\s+\"?)[\w\.]+@[\w\.]+(\"?)/$1greenstone\@cs.waikato.ac.nz$2/ix;
942 # !! This will stuff up if there are handle language qualifiers eg. [l=en] !!
943 # $line =~ s/^(collectionmeta\s+\"?iconcollection(?:small)?\"?\s+\"?).*?($collname\/images\/)/$1_httpprefix_\/collect\/$2/ix;
944 $file .= $line;
945 }
946 close FILE;
947
948 open (FILE, ">$collect_cfg_file") || die;
949 print FILE $file;
950 close FILE;
951}
952
953# the "collection release" is the version of the content - it should only change if the
954# collections content is changed in some way
955# the "build version" is the build version of Greenstone when the collection distribution
956# was created
957
958# recent build version changes were:
959# 2.0 - 2.1: plugins were altered to take input_encoding (and other) options. GB plugins
960# were removed. numwords and numsections statistics were added.
961# All build version 2.0 collections other than those that suddenly required
962# the input_encoding option (i.e. Arabic and Chinese) may still be built and
963# viewed using build verion 2.1 software (numwords and numsections won't be
964# available though).
965
966sub create_version_file {
967 my ($version_file, $preimported) = @_;
968
969 open (FILE, ">$version_file") || die;
970
971 print FILE "collection release: 1.1\n";
972 print FILE "build version: 2.1\n";
973 print FILE "pre-imported\n" if $preimported;
974
975 close FILE;
976}
977
978# simply recurses directory structure beginning at $dir
979# and deletes any CVS administrative directories it comes
980# across
981sub remove_cvs_dirs {
982 my ($dir) = @_;
983
984 if (!-d $dir) {return;}
985
986 opendir (DIR, $dir) || die;
987 my @files = readdir DIR;
988 closedir DIR;
989
990 foreach my $file (@files) {
991 next if $file =~ /^\.\.?$/;
992 my $fullpath = &util::filename_cat ($dir, $file);
993 if (-d $fullpath) {
994 if ($file eq "CVS") {
995 &util::rm_r ($fullpath);
996 } else {
997 &remove_cvs_dirs ($fullpath);
998 }
999 }
1000 }
1001}
1002
1003# mode is 0 to create .zip and .tgz, 1 to create .zip only, and 2 to create
1004# .tgz only
1005sub zip {
1006 my ($zip_to, $zip_from, $dir, $mode) = @_;
1007
1008 chdir ($dir);
1009
1010 if ($mode != 2) {
1011 my $to = $zip_to . ".zip";
1012 unlink ($to) if -e $to;
1013 print STDERR "zipping up $to\n";
1014 `zip -r $to $zip_from`;
1015 }
1016 if ($mode != 1) {
1017 my $to = $zip_to . ".tgz";
1018 unlink ($to) if -e $to;
1019 print STDERR "tarring and gzipping $to\n";
1020 print STDERR "tar cvzf $to $zip_from\n";
1021 system ("tar cvzf $to $zip_from");
1022 }
1023}
1024
1025sub edit_files {
1026 # edit VERSION file
1027 my $version_file = &util::filename_cat ($tmpdir, "gsdl", "etc" , "VERSION");
1028 open (VERSION, $version_file) || die "failed to open $version_file\n";
1029 my $found = 0; my $line = ""; my $file = "";
1030 while (defined ($line = <VERSION>)) {
1031 if ($line =~ s/(gsdl version: )x\.xx/$1$version_num/) {
1032 $found ++;
1033 } elsif ($line =~ s/(cvs tag: )gsdl-x_xx-distribution/$1$cvs_tag/) {
1034 $found ++;
1035 }
1036 $file .= $line;
1037 }
1038 close VERSION;
1039 if ($found != 2) {
1040 die "error while editing $version_file\n";
1041 }
1042
1043 open (VERSION, ">$version_file") || die;
1044 print VERSION $file;
1045 close VERSION;
1046
1047 # edit gsdlconf.h
1048 my $gsdlconf_file = &util::filename_cat ($tmpdir, "gsdl", "lib", "gsdlconf.h");
1049 open (GSDLCONF, $gsdlconf_file) || die;
1050 $found = 0; $line = ""; $file = "";
1051 while (defined ($line = <GSDLCONF>)) {
1052 if ($line =~ s/(\#define GSDL_VERSION \")x\.xx(\")/$1$version_num$2/) {
1053 $found ++;
1054 }
1055 $file .= $line;
1056 }
1057 close GSDLCONF;
1058 if (!$found) {
1059 die "error while editing $gsdlconf_file\n";
1060 }
1061
1062 open (GSDLCONF, ">$gsdlconf_file") || die;
1063 print GSDLCONF $file;
1064 close GSDLCONF;
1065}
1066
1067END {
1068 # remove any temporary files we created
1069 print STDERR "\ndeleting temporary files\n";
1070 my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
1071 if (-e $tmp_gsdlsite_file) {
1072 print STDERR "$tmp_gsdlsite_file\n";
1073 unlink($tmp_gsdlsite_file);
1074 }
1075 my $tmp_gsdlhome = &util::filename_cat ($tmpdir, "gsdl");
1076 if (-d $tmp_gsdlhome) {
1077 print STDERR "$tmp_gsdlhome\n";
1078 &util::rm_r ($tmp_gsdlhome);
1079 }
1080}
Note: See TracBrowser for help on using the repository browser.