source: trunk/gsdl/bin/script/create_distributions.pl@ 6072

Last change on this file since 6072 was 6072, checked in by mdewsnip, 20 years ago

Made quite a few changes related to including the GLI with all distributions, and only including the core language interfaces (English, French, Spanish, Russian).

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