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