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

Last change on this file since 9254 was 9254, checked in by nzdl, 19 years ago

Moved into here from the main Greenstone source (it is only used for creating distributions, and would be of no interest to anyone else).

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