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

Last change on this file since 14299 was 14299, checked in by oranfry, 17 years ago

reworked the create_distributions.pl script to read from the new svn repository instead of the old cvs repository, so we can keep doing releases! n.b., the script which creates the changelog is still untouched and will need to be reworked at some stage. 'till then get changelogs from trac.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 31.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 distribution source directories
11# from the gsdl directory pointed to by $GSDLHOME (although it uses the
12# main SVN repository to get the latest source code distribution).
13
14# CDROM - main distribution source: gsdl-x.xx-cdrom
15# UNIX - some additional unix specific stuff: gsdl-x.xx-unix
16# These first two rely on InstallShield X installer to create the actual distributions (Windows/LInux/Mac, web and CD-ROM)
17# Source - a source distribution, which just needs to be tarred and gzipped up.
18
19# creates ChangeLog using `cvs2cl.pl -P -F trunk -r -S -l "-d'date<tomorrow'"
20# where date of last distribution is read from the last line of
21# $GSDLHOME/DistDates or from -ChangeLogDate command line option
22# should use something like cvs2cl.pl ... -l "-r'last_tag' -r'this_tag'" but
23# I can't get cvs to ignore files which contain neither last_tag or this_tag
24# so ChangeLog contains lots of ancient stuff
25
26# creates a copy of everything in svn repository in $tmpdir
27
28# edits /tmp/gsdl/etc/VERSION, /tmp/gsdl/src/w32server/fnord.cpp
29# and /tmp/gsdl/cgi-bin/gsdlsite.cfg to use new version number
30# and default GSDLHOME
31
32# temporary working directory
33
34my $tmpdir = '/tmp/tmp';
35#my $tmpdir = '/research/oranfry/greenstone2-releases/2.74/dist/tmp/';
36
37# docs directory - up-to-date copy of everything to go in the docs directory
38# (including the README.txt) is expected to live here
39my $docs_dir = '/home/nzdl/gsdl-docs';
40
41my $for_distributions_dir = '/home/nzdl/for-distributions';
42
43# where the windows binaries live (including library.exe and server.exe)
44# this currently relies on being a directory ending in "windows"
45my $winbin = "$ENV{'GSDLHOME'}/bin/windows";
46
47# ditto for linux binaries (don't forget getpw)
48my $linuxbin = "$ENV{'GSDLHOME'}/bin/linux";
49
50# ditto for Mac OS/X binaries
51my $macosxbin = "$ENV{'GSDLHOME'}/bin/darwin";
52
53#my $cvsanon = ':pserver:[email protected]:2402/usr/local/global-cvs/gsdl-src';
54my $svnroot = "http://svn.greenstone.org";
55
56use strict;
57use parsargv;
58use util;
59
60use Cwd;
61
62
63sub print_usage {
64 print STDERR "\n";
65 print STDERR "create_distributions.pl: Packages up Greenstone distributions.\n\n";
66 print STDERR " usage: $0 [options]\n\n";
67 print STDERR " options:\n";
68 print STDERR " -tmpdir temporary directory to use instead of $tmpdir\n";
69 print STDERR " -output_dir directory to output distributions to\n";
70 print STDERR " -version_num version number of distribution (x.xx)\n";
71 print STDERR " -svn_tag svn tag from which to create distributions\n";
72 print STDERR " - if not set latest versions will be used.\n";
73 print STDERR " -unesco create unesco style release, i.e. only 4 languages enabled\n";
74 print STDERR " -NoChangeLog don't create ChangeLog\n";
75 print STDERR " -UseExistingLog use $ENV{'GSDLHOME'}/ChangeLog rather than creating one\n";
76 print STDERR " -ChangeLogDate date from which to begin ChangeLog - note that ChangeLog\n";
77 print STDERR " will always run from date to most recent commits, even if\n";
78 print STDERR " svn_tag is for a previous revision\n\n";
79}
80
81&main ();
82
83my $newtmpdir;
84my $version_num;
85my $svn_tag;
86my $unesco;
87my $nochangelog;
88my $useexistinglog;
89my $changelogdate;
90my $output_dir;
91
92sub main
93{
94 if (!parsargv::parse(\@ARGV,
95 'tmpdir/.*/', \$newtmpdir,
96 'version_num/\d\.\d\d[a-z]?', \$version_num,
97 'svn_tag/.*/', \$svn_tag,
98 'unesco', \$unesco,
99 'NoChangeLog', \$nochangelog,
100 'UseExistingLog', \$useexistinglog,
101 'ChangeLogDate/.*/', \$changelogdate,
102 'output_dir/.*/', \$output_dir)) {
103 &print_usage();
104 die "\n";
105 }
106
107 $tmpdir = $newtmpdir if (defined $newtmpdir && -d $newtmpdir);
108 $output_dir = "." unless $output_dir =~ /\w/;
109 mkdir ($output_dir, 0777) unless -d $output_dir;
110
111 if ($svn_tag !~ /\w/) {
112 $svn_tag = $version_num;
113 $svn_tag =~ s/\./\_/g;
114 $svn_tag = "gsdl-" . $svn_tag . "-distribution";
115 }
116
117 &create_changelog() unless ($nochangelog || $useexistinglog);
118
119 # Export gsdl to $tmpdir
120 print STDERR "\nexporting gsdl to $tmpdir\n\n";
121 chdir($tmpdir);
122 #`svn export $svnroot/gsdl/trunk gsdl`
123
124 #`cvs -d $cvsanon export -D "1 second ago" gsdl`;
125 # use something like the following if you want a previous version
126 my $output;
127 $output=`svn export $svnroot/gsdl/branches/gsdl-2.74 gsdl`;
128 print STDERR $output;
129 #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gsdl`;
130
131 # Export gli to $tmpdir/gli
132 chdir(&util::filename_cat($tmpdir, "gsdl"));
133
134 print STDERR "\nexporting indexers to " . &util::filename_cat($tmpdir, "gsdl") . "\n\n";
135 $output=`svn export $svnroot/indexers/trunk indexers`;
136 print STDERR $output;
137
138 print STDERR "\nexporting gli to " . &util::filename_cat($tmpdir, "gsdl") . "\n\n";
139 $output=`svn export $svnroot/gli/trunk gli`;
140 print STDERR $output;
141 #`cvs -d $cvsanon export -D "1 second ago" gli`;
142
143 # use something like the following if you want a previous version
144 #`svn export $svnroot/gli/branches/2.74 gli`;
145
146 # Compile gli
147 &compile_gli();
148
149 # Remove bits used by none of the distributions
150 &util::rm(&util::filename_cat($tmpdir, "gsdl", "packages", "cpan", "XML-Parser-2.27.tar.gz"));
151
152 # copy ChangeLog into $tmpdir/gsdl
153 &util::cp(&util::filename_cat($ENV{'GSDLHOME'}, "ChangeLog"),
154 &util::filename_cat($tmpdir, "gsdl")) unless $nochangelog;
155
156 # edit the VERSION and fnord.cpp files
157 &edit_files();
158
159 &create_unix_distribution();
160 &create_source_distribution();
161 &create_cdrom_distribution();
162}
163
164
165sub compile_gli
166{
167 print STDERR "\ncompiling gli...\n";
168 chdir(&util::filename_cat($tmpdir, "gsdl", "gli"));
169 my $output;
170 $output=`./makegli.sh`;
171 print STDERR $output;
172
173 # JAR up the gli, then delete the class files
174 print STDERR "jarring gli...\n";
175 `./makejar.sh`;
176 &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "jar"));
177 #metadata.zip is deleted by makegli.sh
178 #&util::rm(&util::filename_cat($tmpdir, "gsdl", "gli", "metadata.zip"));
179
180 &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "classes", "org"));
181
182 # Move the GLIServer.jar file created by makejar.sh into bin/java
183 &util::mv(&util::filename_cat($tmpdir, "gsdl", "gli", "GLIServer.jar"),
184 &util::filename_cat($tmpdir, "gsdl", "bin", "java"));
185
186 # Make the gli-client.zip file
187 chdir($tmpdir);
188
189 # take a copy of GLI directory
190 &util::cp_r(&util::filename_cat($tmpdir, "gsdl", "gli"), $tmpdir);
191
192 my $client_dirname = "gli-client-" . $version_num;
193 rename ("gli", $client_dirname);
194 chdir(&util::filename_cat($tmpdir, $client_dirname));
195
196
197 # delete unnecessary stuff
198 `rm -rf clean.* document.* gems.* gli*.sh gli*.bat make*.sh make*.bat lib src`;
199 # make sure permissions are ok
200 `chmod a+x client-gli.sh client-gli.bat`;
201 chdir($tmpdir);
202
203 # zip up the client
204 &zip($client_dirname, $client_dirname, $tmpdir, 1);
205
206 # Move the zip file to the destination directory
207
208 &util::cp(&util::filename_cat($tmpdir, "$client_dirname.zip"), $output_dir);
209 &util::rm_r(&util::filename_cat($tmpdir, $client_dirname));
210 &util::rm(&util::filename_cat($tmpdir, "$client_dirname.zip"));
211
212}
213
214sub create_unix_distribution
215{
216 print STDERR "Creating Unix distribution...\n";
217
218 my $unix_dist_dir = &util::filename_cat($output_dir, "gsdl-" . $version_num . "-unix");
219 mkdir ($unix_dist_dir, 0777);
220
221 # Web release has a slightly customised version of Install.sh
222 &util::cp(&util::filename_cat($tmpdir, "gsdl", "Install.sh"), $unix_dist_dir);
223 my $Install_sh_file = &util::filename_cat($unix_dist_dir, "Install.sh");
224 open (INSTALL_SH, $Install_sh_file) || die "Failed to open $Install_sh_file\n";
225 my $found = 0; my $line = ""; my $file = "";
226 while (defined ($line = <INSTALL_SH>)) {
227 if ($line =~ /^iscdrom=\"/) {
228 $line = "iscdrom=\"no\"\n";
229 $found = 1;
230 }
231 $file .= $line;
232 }
233 close INSTALL_SH;
234
235 if ($found != 1) {
236 die "Error while editing $Install_sh_file\n";
237 }
238
239 open (INSTALL_SH, ">$Install_sh_file") || die;
240 print INSTALL_SH $file;
241 close INSTALL_SH;
242}
243
244
245sub create_source_distribution
246{
247 print STDERR "Creating Source distribution...\n";
248
249 my $source_dist_dir = &util::filename_cat($output_dir, "gsdl-" . $version_num . "-src");
250 mkdir($source_dist_dir, 0777);
251
252 my $gsdldir = &util::filename_cat ($source_dist_dir, "gsdl");
253
254 # Copy the entire contents of the exported GSDL directory
255 my $tmpgsdldir = &util::filename_cat($tmpdir, "gsdl");
256 `cp -r $tmpgsdldir $source_dist_dir`;
257
258 # We want the COPYING file in the source distribution too
259 &util::cp(&util::filename_cat($docs_dir, "COPYING"), $gsdldir);
260
261 # We shouldn't distribute the GLI applet signed by us
262 if (-e &util::filename_cat($source_dist_dir, "gsdl", "bin", "java", "SignedGatherer.jar")) {
263 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "bin", "java", "SignedGatherer.jar"));
264 }
265
266 # We don't want the compiled GLI classes in the source distribution (or the GS3 scripts)
267 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", ".greenstonestore"));
268 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "GLI.jar"));
269 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "gli4gs3.bat"));
270 &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "gli4gs3.sh"));
271
272}
273
274
275sub create_cdrom_distribution
276{
277 print STDERR "Creating CD-ROM distribution...\n";
278
279 my $cdrom_dist_dir = &util::filename_cat ($output_dir, "gsdl-" . $version_num . "-cdrom");
280 mkdir ($cdrom_dist_dir, 0777);
281
282 # docs directory
283 &install_docs ($cdrom_dist_dir, 0);
284
285 # gsdl directory
286 &install_gsdl ($cdrom_dist_dir);
287
288 # gli directory (in gsdl)
289 &install_gli($cdrom_dist_dir, "cdrom");
290
291 # src directory
292 &install_src ($cdrom_dist_dir, "cdrom");
293
294 # Windows directory
295 &install_windows_specific ($cdrom_dist_dir, 1);
296
297 # Unix directory
298 &install_unix_specific ($cdrom_dist_dir);
299
300 # for the cd-rom we want to include the unbuilt bits of the demo collection too
301 #my $demodir = &util::filename_cat($cdrom_dist_dir, "gsdl", "collect", "demo");
302 #my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
303 #die "oops, no demo dir\n" unless -d $demodir;
304 #&util::cp (&util::filename_cat ($tmpdemo, "demo.col"), $demodir);
305 #&util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
306 #&util::cp_r (&util::filename_cat ($tmpdemo, "metadata"), $demodir);
307
308 # collect directory, with documented example collections
309 my $cdrom_collect_dir = &util::filename_cat ($cdrom_dist_dir, "collect");
310 mkdir($cdrom_collect_dir, 0777);
311
312 my $source_collect_dir = &util::filename_cat($for_distributions_dir, "collect");
313 my $target_collect_dir = &util::filename_cat($cdrom_dist_dir, "collect");
314
315 &util::cp_r(&util::filename_cat($source_collect_dir, "MARC-e"), $target_collect_dir);
316 &util::cp_r(&util::filename_cat($source_collect_dir, "authen-e"), $target_collect_dir);
317 &util::cp_r(&util::filename_cat($source_collect_dir, "cltbib-e"), $target_collect_dir);
318 &util::cp_r(&util::filename_cat($source_collect_dir, "cltext-e"), $target_collect_dir);
319 &util::cp_r(&util::filename_cat($source_collect_dir, "dls-e"), $target_collect_dir);
320 &util::cp_r(&util::filename_cat($source_collect_dir, "garish"), $target_collect_dir);
321 &util::cp_r(&util::filename_cat($source_collect_dir, "gsarch-e"), $target_collect_dir);
322 &util::cp_r(&util::filename_cat($source_collect_dir, "image-e"), $target_collect_dir);
323 &util::cp_r(&util::filename_cat($source_collect_dir, "isis-e"), $target_collect_dir);
324 &util::cp_r(&util::filename_cat($source_collect_dir, "oai-e"), $target_collect_dir);
325 &util::cp_r(&util::filename_cat($source_collect_dir, "wrdpdf-e"), $target_collect_dir);
326 &util::cp_r(&util::filename_cat($source_collect_dir, "dspace-e"), $target_collect_dir);
327 &util::cp_r(&util::filename_cat($source_collect_dir, "style-e"), $target_collect_dir);
328 &util::cp_r(&util::filename_cat($source_collect_dir, "pagedimg-e"), $target_collect_dir);
329
330 # Make sure the whole thing is user-writeable
331 `chmod -R u+rw $cdrom_dist_dir`;
332}
333
334
335# isweb is 1 if it's one of the web distributions (i.e. if we don't
336# want to install the manuals) - this shouldn't be called at all for
337# windows web installation as it doesn't use docs at all (not much
338# point for self-extracting exe).
339sub install_docs {
340 my ($install_dir, $isweb) = @_;
341
342 # COPYING, README*.txt and Support.htm
343 &util::cp (&util::filename_cat($docs_dir, "COPYING"), $install_dir);
344 &util::cp (&util::filename_cat($docs_dir, "READMEen.txt"), $install_dir);
345 &util::cp (&util::filename_cat($docs_dir, "READMEes.txt"), $install_dir);
346 &util::cp (&util::filename_cat($docs_dir, "READMEfr.txt"), $install_dir);
347 &util::cp (&util::filename_cat($docs_dir, "READMEru.txt-cp1251"), $install_dir);
348 &util::cp (&util::filename_cat($docs_dir, "READMEru.txt-koi8-r"), $install_dir);
349 &util::cp (&util::filename_cat($docs_dir, "Support.htm"), $install_dir);
350
351 &force_windows_line_endings(&util::filename_cat($install_dir, "COPYING"));
352 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEen.txt"));
353 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEes.txt"));
354 &force_windows_line_endings(&util::filename_cat($install_dir, "READMEfr.txt"));
355
356 # The web distributions don't have any of the manuals
357 return if ($isweb);
358
359 # docs directory, but not any of the Word files or Latex files
360 &util::cp_r (&util::filename_cat($docs_dir, "docs"), $install_dir);
361 my $en_docs = &util::filename_cat ($install_dir, "docs", "english", "*.doc");
362 `rm $en_docs`;
363 my $es_docs = &util::filename_cat ($install_dir, "docs", "spanish", "*.doc");
364 `rm $es_docs`;
365 my $ru_docs = &util::filename_cat ($install_dir, "docs", "russian", "*.doc");
366 `rm $ru_docs`;
367 my $fr_latex = &util::filename_cat ($install_dir, "docs", "french", "latex");
368 `rm -r $fr_latex`;
369}
370
371
372sub install_gsdl {
373 my ($install_dir) = @_;
374
375 my $gsdldir = &util::filename_cat ($install_dir, "gsdl");
376 mkdir ($gsdldir, 0777);
377
378 my $gsdlbindir = &util::filename_cat ($gsdldir, "bin");
379 mkdir ($gsdlbindir, 0777);
380 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "script"), $gsdlbindir);
381 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "java"), $gsdlbindir);
382 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "cgi-bin"), $gsdldir);
383 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "collect"), $gsdldir);
384 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "etc"), $gsdldir);
385
386 #Get the modified main.cfg file with only core language interfaces enabled
387 if ($unesco) {
388 &util::cp(&util::filename_cat($for_distributions_dir, "etc", "main.cfg"), &util::filename_cat($gsdldir, "etc"));
389 }
390 # Make sure everything in bin/script is executable
391 my $bin_script_dir = &util::filename_cat($gsdldir, "bin", "script");
392 `chmod a+x $bin_script_dir/*`;
393
394 # Make sure cgi scripts are executable
395 my $gliserver_script = &util::filename_cat($gsdldir, "cgi-bin", "gliserver.pl");
396 `chmod a+x $gliserver_script`;
397 # should we be doing these ones - usability feedback scripts ??
398 #my $perl_script = &util::filename_cat($gsdldir, "cgi-bin", "perl.cgi");
399 #`chmod a+x $perl_script`;
400 #my $readresults_script = &util::filename_cat($gsdldir, "cgi-bin", "readresults.cgi");
401 #`chmod a+x $readresults_script`;
402 #my $trackreport_script = &util::filename_cat($gsdldir, "cgi-bin", "trackreport.cgi");
403 #`chmod a+x $trackreport_script`;
404
405 &force_windows_line_endings(&util::filename_cat($gsdldir, "cgi-bin", "gsdlsite.cfg"));
406 &force_windows_line_endings(&util::filename_cat($gsdldir, "etc", "main.cfg"));
407 &force_windows_line_endings(&util::filename_cat($gsdldir, "etc", "oai.cfg"));
408
409 # Make sure certain files in the etc directory are writeable by everyone
410 my $error_txt_file = &util::filename_cat($gsdldir, "etc", "error.txt");
411 `chmod a+w $error_txt_file`;
412 my $history_db_file = &util::filename_cat($gsdldir, "etc", "history.db");
413 `chmod a+w $history_db_file`;
414 my $key_db_file = &util::filename_cat($gsdldir, "etc", "key.db");
415 `chmod a+w $key_db_file`;
416 my $main_cfg_file = &util::filename_cat($gsdldir, "etc", "main.cfg");
417 `chmod a+w $main_cfg_file`;
418 my $usage_txt_file = &util::filename_cat($gsdldir, "etc", "usage.txt");
419 `chmod a+w $usage_txt_file`;
420 my $users_db_file = &util::filename_cat($gsdldir, "etc", "users.db");
421 `chmod a+rw $users_db_file`; # Readable too
422
423 # We shouldn't distribute the GLI applet signed by us
424 if (-e &util::filename_cat($gsdlbindir, "java", "SignedGatherer.jar")) {
425 &util::rm(&util::filename_cat($gsdlbindir, "java", "SignedGatherer.jar"));
426 }
427
428 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "images"), $gsdldir);
429 &util::cp_r(&util::filename_cat ($tmpdir, "gsdl", "macros"), $gsdldir);
430 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "mappings"), $gsdldir);
431 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "perllib"), $gsdldir);
432
433 # Rename perllib/strings.properties to perllib/strings_en.properties
434 my $stringsrbfile = &util::filename_cat ($gsdldir, "perllib", "strings.properties");
435 &util::cp ($stringsrbfile, &util::filename_cat ($gsdldir, "perllib", "strings_en.properties"));
436 &util::rm ($stringsrbfile);
437 `touch $stringsrbfile`;
438
439 # Untar Ping.tgz and XML-Parser.tar.gz
440 my $wd = cwd;
441 chdir (&util::filename_cat($gsdldir, "perllib", "cpan"));
442 `tar xvzf Ping.tgz`;
443 unlink ("Ping.tgz");
444 &util::cp(&util::filename_cat($for_distributions_dir, "perllib", "cpan", "XML-Parser.tar.gz"),
445 &util::filename_cat($gsdldir, "perllib", "cpan"));
446 `tar xvzf XML-Parser.tar.gz`;
447 unlink ("XML-Parser.tar.gz");
448 chdir ($wd);
449
450 # make sure that modelcol collection contains all the right
451 # empty directories
452 my $modelindex = &util::filename_cat ($gsdldir, "collect", "modelcol", "index");
453 &util::mk_all_dir ($modelindex) unless -d $modelindex;
454 my $modelbuilding = &util::filename_cat ($gsdldir, "collect", "modelcol", "building");
455 &util::mk_all_dir ($modelbuilding) unless -d $modelbuilding;
456 my $modelarchives = &util::filename_cat ($gsdldir, "collect", "modelcol", "archives");
457 &util::mk_all_dir ($modelarchives) unless -d $modelarchives;
458 my $modelimport = &util::filename_cat ($gsdldir, "collect", "modelcol", "import");
459 &util::mk_all_dir ($modelimport) unless -d $modelimport;
460 my $modelperllib = &util::filename_cat ($gsdldir, "collect", "modelcol", "perllib");
461 &util::mk_all_dir ($modelperllib) unless -d $modelperllib;
462 my $modelimages = &util::filename_cat ($gsdldir, "collect", "modelcol", "images");
463 &util::mk_all_dir ($modelimages) unless -d $modelimages;
464
465 # demo collection needs to be pre-built
466 my $collectdir = &util::filename_cat ($gsdldir, "collect");
467 &util::rm_r (&util::filename_cat($collectdir, "demo"));
468 if (!&get_built_collection ("demo", $collectdir)) {
469 die "Couldn't get built version of demo collection\n";
470 }
471#******
472 if ($unesco) {
473 # Get modified version of demo collect.cfg file with only core language strings
474 &util::cp(&util::filename_cat($for_distributions_dir, "collect", "demo", "etc", "collect.cfg"),
475 &util::filename_cat($collectdir, "demo", "etc"));
476 }
477}
478
479
480sub install_gli
481{
482 my ($install_dir, $type) = @_;
483
484 # Copy the Greenstone Librarian Interface
485 my $source_dir = &util::filename_cat($tmpdir, "gsdl", "gli");
486 my $target_dir = &util::filename_cat($install_dir, "gsdl");
487 &util::cp_r($source_dir, $target_dir);
488
489 my $gli_dir = &util::filename_cat($target_dir, "gli");
490 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEen.txt"));
491 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEes.txt"));
492 &force_windows_line_endings(&util::filename_cat($gli_dir, "READMEfr.txt"));
493
494 # Make Unix scripts executable
495 `chmod a+x $gli_dir/*.sh`;
496
497 # Copy dictionary.properties to dictionary_en.properties to prevent problems with non-English machines
498 &util::cp(&util::filename_cat($gli_dir, "classes", "dictionary.properties"),
499 &util::filename_cat($gli_dir, "classes", "dictionary_en.properties"));
500
501 if ($unesco) {
502 # Copy the customised languages.xml file with only core languages enabled
503 &util::cp(&util::filename_cat($for_distributions_dir, "gli", "classes", "xml", "languages.xml"),
504 &util::filename_cat($gli_dir, "classes", "xml"));
505 }
506 # Remove unwanted stuff - all distributions
507 &util::rm(&util::filename_cat($gli_dir, ".greenstonestore"));
508
509 # Don't need Greenstone 3 scripts
510 &util::rm(&util::filename_cat($gli_dir, "gli4gs3.bat"));
511 &util::rm(&util::filename_cat($gli_dir, "gli4gs3.sh"));
512
513 # Remove unwanted stuff - Unix distributions
514 if ($type eq "unix") {
515 # Don't need Windows scripts
516 &util::rm(&util::filename_cat($gli_dir, "clean.bat"));
517 &util::rm(&util::filename_cat($gli_dir, "document.bat"));
518 &util::rm(&util::filename_cat($gli_dir, "gems.bat"));
519 &util::rm(&util::filename_cat($gli_dir, "gli.bat"));
520 &util::rm(&util::filename_cat($gli_dir, "makegli.bat"));
521
522 # Don't need Windows utilities
523 &util::rm_r(&util::filename_cat($gli_dir, "winutil"));
524
525 # Don't need Windows README file
526 &util::rm(&util::filename_cat($gli_dir, "READMEru.txt-cp1251"));
527
528 # Rename Unix README file
529 &util::cp(&util::filename_cat($gli_dir, "READMEru.txt-koi8-r"),
530 &util::filename_cat($gli_dir, "READMEru.txt"));
531 &util::rm(&util::filename_cat($gli_dir, "READMEru.txt-koi8-r"));
532 }
533
534 # Remove unwanted stuff - Windows distributions
535 if ($type eq "windows") {
536 # Don't need Unix scripts
537 &util::rm(&util::filename_cat($gli_dir, "clean.sh"));
538 &util::rm(&util::filename_cat($gli_dir, "document.sh"));
539 &util::rm(&util::filename_cat($gli_dir, "gems.sh"));
540 &util::rm(&util::filename_cat($gli_dir, "gli.sh"));
541 &util::rm(&util::filename_cat($gli_dir, "makegli.sh"));
542 &util::rm(&util::filename_cat($gli_dir, "makejar.sh"));
543 }
544}
545
546
547sub install_src {
548 my ($install_dir, $type) = @_;
549
550 my $srcdir = &util::filename_cat ($install_dir, "src");
551 my $srcwindir = &util::filename_cat ($srcdir, "Windows");
552 my $srcunixdir = &util::filename_cat ($srcdir, "Unix");
553 mkdir ($srcdir, 0777);
554 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "lib"), $srcdir);
555 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "packages"), $srcdir);
556 &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "src"), $srcdir);
557 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Install.txt"), $srcdir);
558 &force_windows_line_endings(&util::filename_cat($srcdir, "Install.txt"));
559
560 if ($type ne "unix") {
561 mkdir ($srcwindir, 0777);
562 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bat"), $srcwindir);
563 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "win32.mak"), $srcwindir);
564 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "WIN32cfg.h"), $srcwindir);
565 }
566
567 if ($type ne "windows") {
568 mkdir ($srcunixdir, 0777);
569 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Makefile.in"), $srcunixdir);
570 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "acconfig.h"), $srcunixdir);
571 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "aclocal.m4"), $srcunixdir);
572 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.h.in"), $srcunixdir);
573 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configtest.pl"), $srcunixdir);
574 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure"), $srcunixdir);
575 # make sure configure and setup scripts are executable
576 my $configure_script = &util::filename_cat ($srcunixdir , "configure");
577 `chmod a+x $configure_script`;
578
579 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure.in"), $srcunixdir);
580 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.sub"), $srcunixdir);
581 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.guess"), $srcunixdir);
582 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "install-sh"), $srcunixdir);
583 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bash"), $srcunixdir);
584 &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.csh"), $srcunixdir);
585 `chmod a+x $srcunixdir/setup.*`;
586
587 # get all the configure scripts
588 `cd $srcdir; find -name "configure" -exec chmod a+x {} \\; ; cd -`
589
590 }
591}
592
593sub install_windows_specific {
594 my ($install_dir, $cd_rom) = @_;
595
596 my $windir = &util::filename_cat ($install_dir, "Windows");
597 my $winbindir = &util::filename_cat ($windir, "bin");
598 mkdir ($windir, 0777);
599 mkdir ($winbindir, 0777);
600 &util::cp_r ($winbin, $winbindir);
601
602 # make sure there aren't any .svn directories laying around
603 &remove_svn_dirs ($windir);
604}
605
606sub install_unix_specific {
607 my ($install_dir) = @_;
608
609 my $unixdir = &util::filename_cat ($install_dir, "Unix");
610 my $unixbindir = &util::filename_cat ($unixdir, "bin");
611 mkdir ($unixdir, 0777);
612 mkdir ($unixbindir, 0777);
613 &util::cp (&util::filename_cat($tmpdir, "gsdl", "Install.sh"), $unixdir);
614
615 # make sure Install.sh is executable
616 my $install_sh = &util::filename_cat($unixdir, "Install.sh");
617 `chmod a+x $install_sh`;
618
619 # Get Linux binaries, and make sure they're all executable
620 &util::cp_r ($linuxbin, $unixbindir);
621 my $linuxbindir = &util::filename_cat($unixbindir, 'linux');
622 `chmod -R a+x $linuxbindir`;
623
624 # remove the non-static mgquery_old program from distributions
625 &util::rm(&util::filename_cat($linuxbindir, "mgquery_old"));
626
627 # Get Mac OS/X binaries, and make sure they're all executable
628 &util::cp_r ($macosxbin, $unixbindir);
629 my $macosxbindir = &util::filename_cat($unixbindir, 'darwin');
630 `chmod -R a+x $macosxbindir`;
631
632 # make sure there aren't any .svn directories laying around
633 &remove_svn_dirs ($unixdir);
634}
635
636
637# gets all the right bits of a built collection from
638# $GSDLHOME/collect and copies them to $collect_dir
639# returns 1 if successful, 0 if not
640sub get_built_collection {
641 my ($colname, $collect_dir) = @_;
642
643 my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
644 if (!-d $from_dir) {
645 print STDERR "\nERROR: No collection at $from_dir\n";
646 return 0;
647 }
648
649 my $to_dir = &util::filename_cat ($collect_dir, $colname);
650 mkdir ($to_dir, 0777) unless -d $to_dir;
651
652 # get the built indexes
653 my $index_dir = &util::filename_cat ($from_dir, "index");
654 if (-d $index_dir) {
655 # if build.cfg exists we'll assume collection is built ok
656 if (-e &util::filename_cat ($index_dir, "build.cfg")) {
657 &util::cp_r ($index_dir, $to_dir);
658 } else {
659 print STDERR "\nERROR: no build.cfg at $index_dir (collection not built?)\n";
660 rmdir ($to_dir);
661 return 0;
662 }
663 } else {
664 print STDERR "\nERROR: collection at $from_dir appears unbuilt (no index directory)\n";
665 return 0;
666 }
667 &util::cp_r ($index_dir, $to_dir);
668
669 # get the collect.cfg file
670 mkdir (&util::filename_cat($to_dir, "etc"), 0777);
671 &util::cp (&util::filename_cat($from_dir, "etc", "collect.cfg"),
672 &util::filename_cat($to_dir, "etc"));
673
674 # get the .col file
675 &util::cp (&util::filename_cat($from_dir, "$colname.col"),
676 $to_dir);
677 # get any other directories - import, metadata, images, macros, perllib
678 my $from_import = &util::filename_cat ($from_dir, "import");
679 &util::cp_r ($from_import, $to_dir) if -d $from_import;
680 my $from_metadata = &util::filename_cat ($from_dir, "metadata");
681 &util::cp_r ($from_metadata, $to_dir) if -d $from_metadata;
682 my $from_images = &util::filename_cat ($from_dir, "images");
683 &util::cp_r ($from_images, $to_dir) if -d $from_images;
684 my $from_macros = &util::filename_cat ($from_dir, "macros");
685 &util::cp_r ($from_macros, $to_dir) if -d $from_macros;
686 my $from_perllib = &util::filename_cat ($from_dir, "perllib");
687 &util::cp_r ($from_perllib, $to_dir) if -d $from_perllib;
688
689 # make sure there aren't any .svn directories laying around
690 &remove_svn_dirs ($to_dir);
691
692 return 1;
693}
694
695sub force_windows_line_endings
696{
697 my ($filepath) = @_;
698
699 open(IN, "<$filepath");
700 my $text = join('', <IN>);
701 close(IN);
702
703 $text =~ s/\n\x0A/\n\x0D\x0A/g;
704 $text =~ s/([^\x0D])\x0A/$1\x0D\x0A/g;
705
706 open(OUT, ">$filepath");
707 print OUT "$text";
708 close(OUT);
709}
710
711
712sub create_changelog {
713
714 my ($tag, $date, $file);
715
716 my $datefile = &util::filename_cat ($for_distributions_dir, "DistDates");
717 if ($changelogdate !~ /\w/) {
718 # get date from for-distributions/DistDates (and update DistDates)
719 open (DATES, $datefile) || die "can't open $datefile\n";
720 my $line = "";
721 while (defined ($line = <DATES>)) {
722 if ($line =~ /\w/) {
723 ($tag, $date) = $line =~ /^(\S+)\t(.*)$/;
724 $changelogdate = $date unless ($tag eq $svn_tag);
725 }
726 $file .= $line;
727 }
728 close DATES;
729 }
730
731 if ((!defined $tag) || ($tag ne $svn_tag)) {
732 open (DATES, ">$datefile") || die;
733 print DATES $file if defined $file;
734 print DATES "$svn_tag\t" . `date`;
735 close DATES;
736 }
737
738 print STDERR "Creating ChangeLog from $changelogdate to most recent\n";
739
740 chdir($ENV{'GSDLHOME'});
741 my $cmd = "$for_distributions_dir/bin/script/cvs2cl.pl -P -F trunk -r -S -l \"-d'$changelogdate<tomorrow'\"";
742 system ($cmd);
743}
744
745# simply recurses directory structure beginning at $dir
746# and deletes any .svn administrative directories it comes
747# across
748sub remove_svn_dirs {
749 my ($dir) = @_;
750
751 if (!-d $dir) {return;}
752
753 opendir (DIR, $dir) || die;
754 my @files = readdir DIR;
755 closedir DIR;
756
757 foreach my $file (@files) {
758 next if $file =~ /^\.\.?$/;
759 my $fullpath = &util::filename_cat ($dir, $file);
760 if (-d $fullpath) {
761 if ($file eq ".svn") {
762 &util::rm_r ($fullpath);
763 } else {
764 &remove_svn_dirs ($fullpath);
765 }
766 }
767 }
768}
769
770# mode is 0 to create .zip and .tgz, 1 to create .zip only, and 2 to create
771# .tgz only
772sub zip {
773 my ($zip_to, $zip_from, $dir, $mode) = @_;
774
775 chdir ($dir);
776
777 if ($mode != 2) {
778 my $to = $zip_to . ".zip";
779 unlink ($to) if -e $to;
780 print STDERR "zipping up $to\n";
781 `zip -r $to $zip_from`;
782 }
783 if ($mode != 1) {
784 my $to2 = $zip_to . ".tgz";
785 unlink ($to2) if -e $to2;
786 print STDERR "tarring and gzipping $to2\n";
787 print STDERR "tar cvzf $to2 $zip_from\n";
788 system ("tar cvzf $to2 $zip_from");
789 }
790}
791
792sub edit_files {
793 # edit VERSION file
794 my $version_file = &util::filename_cat ($tmpdir, "gsdl", "etc" , "VERSION");
795 open (VERSION, $version_file) || die "failed to open $version_file\n";
796 my $found = 0; my $line = ""; my $file = "";
797 while (defined ($line = <VERSION>)) {
798 if ($line =~ s/(gsdl version: )x\.xx/$1$version_num/) {
799 $found ++;
800 } elsif ($line =~ s/(svn tag: )gsdl-x_xx-distribution/$1$svn_tag/) {
801 $found ++;
802 }
803 $file .= $line;
804 }
805 close VERSION;
806 if ($found != 2) {
807 die "error while editing $version_file\n";
808 }
809
810 open (VERSION, ">$version_file") || die;
811 print VERSION $file;
812 close VERSION;
813
814 # edit gsdlconf.h
815 my $gsdlconf_file = &util::filename_cat ($tmpdir, "gsdl", "lib", "gsdlconf.h");
816 open (GSDLCONF, $gsdlconf_file) || die;
817 $found = 0; $line = ""; $file = "";
818 while (defined ($line = <GSDLCONF>)) {
819
820 if ($line =~ s/(\#define GSDL_VERSION \")x\.xx(\")/$1$version_num$2/) {
821 $found ++;
822 }
823 $file .= $line;
824 }
825 close GSDLCONF;
826
827 if ( !$found ) {
828 die "error while editing $gsdlconf_file\n";
829 }
830
831 open (GSDLCONF, ">$gsdlconf_file") || die;
832 print GSDLCONF $file;
833 close GSDLCONF;
834}
835
836END {
837 # remove any temporary files we created
838 print STDERR "\ndeleting temporary files\n";
839 my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
840 if (-e $tmp_gsdlsite_file) {
841 print STDERR "$tmp_gsdlsite_file\n";
842 unlink($tmp_gsdlsite_file);
843 }
844 my $tmp_gsdlhome = &util::filename_cat ($tmpdir, "gsdl");
845 if (-d $tmp_gsdlhome) {
846 print STDERR "$tmp_gsdlhome\n";
847 &util::rm_r ($tmp_gsdlhome);
848 }
849}
Note: See TracBrowser for help on using the repository browser.