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

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

corrected the line in the create_distributions.pl script which tells it where it will run from

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