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 and
|
---|
16 | # packagefortheweb to create self-extracting executable
|
---|
17 |
|
---|
18 | # Linux distribution - gsdl-x.xx-linux.tgz
|
---|
19 |
|
---|
20 | # Source distribution - gsdl-x.xx.tgz
|
---|
21 |
|
---|
22 | # cd-rom distribution = gsdl-x.xx-cdrom.tgz
|
---|
23 | # Creates directory structure - use installshield to create media
|
---|
24 | # for writing to cd-rom
|
---|
25 |
|
---|
26 | # all collections in $GSDLHOME/collect (except modelcol and those
|
---|
27 | # explicitly ignored by -ignorecol options):
|
---|
28 | # pre-built (collname-prebuilt) .tgz .zip
|
---|
29 | # unbuilt (collname) .tgz .zip
|
---|
30 |
|
---|
31 |
|
---|
32 | # creates ChangeLog using `cvs2cl.pl -P -F trunk -r -S -l "-d'date<tomorrow'"
|
---|
33 | # where date of last distribution is read from the last line of
|
---|
34 | # $GSDLHOME/DistDates or from -ChangeLogDate command line option
|
---|
35 | # should use something like cvs2cl.pl ... -l "-r'last_tag' -r'this_tag'" but
|
---|
36 | # I can't get cvs to ignore files which contain neither last_tag or this_tag
|
---|
37 | # so ChangeLog contains lots of ancient stuff
|
---|
38 |
|
---|
39 | # sets a cvs tag called gsdl-x_xx-distribution (unless -cvs_tag is set
|
---|
40 | # in which case it uses that)
|
---|
41 |
|
---|
42 | # creates a copy of everything in cvs repository in $tmpdir
|
---|
43 |
|
---|
44 | # edits /tmp/gsdl/etc/VERSION, /tmp/gsdl/src/w32server/fnord.cpp
|
---|
45 | # and /tmp/gsdl/cgi-bin/gsdlsite.cfg to use new version number
|
---|
46 | # and default GSDLHOME
|
---|
47 |
|
---|
48 | # temporary working directory
|
---|
49 | my $tmpdir = '/tmp/sjboddie';
|
---|
50 |
|
---|
51 | # docs directory - up-to-date copy of everything to go in the docs directory
|
---|
52 | # (including the README.txt) is expected to live here
|
---|
53 | my $docdir = '/home/nzdl/gsdl-docs';
|
---|
54 |
|
---|
55 | # where the windows binaries live (including library.exe and server.exe)
|
---|
56 | # this currently relies on being a directory ending in "windows"
|
---|
57 | my $winbin = "$ENV{'GSDLHOME'}/bin/windows";
|
---|
58 |
|
---|
59 | # ditto for linux binaries (don't forget getpw)
|
---|
60 | my $linuxbin = "$ENV{'GSDLHOME'}/bin/linux";
|
---|
61 |
|
---|
62 | my $cvsroot = ':ext:[email protected]:/usr/local/global-cvs/gsdl-src';
|
---|
63 |
|
---|
64 | use parsargv;
|
---|
65 | use util;
|
---|
66 |
|
---|
67 | use Cwd;
|
---|
68 |
|
---|
69 | sub print_usage {
|
---|
70 | print STDERR "\n";
|
---|
71 | print STDERR "create_distributions.pl: Packages up Greenstone distributions.\n\n";
|
---|
72 | print STDERR " usage: $0 [options]\n\n";
|
---|
73 | print STDERR " options:\n";
|
---|
74 | print STDERR " -version_num version number of distribution (x.xx)\n";
|
---|
75 | print STDERR " -cvs_tag cvs tag from which to create distributions\n";
|
---|
76 | print STDERR " - if not set latest versions will be used and\n";
|
---|
77 | print STDERR " a tag will be set\n";
|
---|
78 | print STDERR " -no_cdrom don't create cd-rom version\n";
|
---|
79 | print STDERR " -no_cols don't attempt to create any collection distributions\n";
|
---|
80 | print STDERR " -only_cols create collection distributions only\n";
|
---|
81 | print STDERR " -includecol collection to include (by default all collections in\n";
|
---|
82 | print STDERR " $ENV{'GSDLHOME'}/collect will be included\n";
|
---|
83 | print STDERR " -ignorecol directory in $ENV{'GSDLHOME'}/collect to ignore (i.e.\n";
|
---|
84 | print STDERR " don't include as collection in distribution)\n";
|
---|
85 | print STDERR " -output_dir directory to output distributions to\n";
|
---|
86 | print STDERR " -NoChangeLog don't create ChangeLog\n";
|
---|
87 | print STDERR " -UseExistingLog use $ENV{'GSDLHOME'}/ChangeLog rather than creating one\n";
|
---|
88 | print STDERR " -ChangeLogDate date from which to begin ChangeLog - note that ChangeLog\n";
|
---|
89 | print STDERR " will always run from date to most recent commits, even if\n";
|
---|
90 | print STDERR " cvs_tag is for a previous revision\n\n";
|
---|
91 | }
|
---|
92 |
|
---|
93 | &main ();
|
---|
94 |
|
---|
95 | sub main {
|
---|
96 | if (!parsargv::parse(\@ARGV,
|
---|
97 | 'version_num/\d\.\d\d[a-z]?', \$version_num,
|
---|
98 | 'cvs_tag/.*/', \$cvs_tag,
|
---|
99 | 'no_cdrom', \$no_cdrom,
|
---|
100 | 'no_cols', \$no_cols,
|
---|
101 | 'only_cols', \$only_cols,
|
---|
102 | 'includecol/.*', \@includecols,
|
---|
103 | 'ignorecol/.*', \@ignorecols,
|
---|
104 | 'NoChangeLog', \$nochangelog,
|
---|
105 | 'UseExistingLog', \$useexistinglog,
|
---|
106 | 'ChangeLogDate/.*/', \$changelogdate,
|
---|
107 | 'output_dir/.*/', \$output_dir)) {
|
---|
108 | &print_usage();
|
---|
109 | die "\n";
|
---|
110 | }
|
---|
111 |
|
---|
112 | $output_dir = "." unless $output_dir =~ /\w/;
|
---|
113 | mkdir ($output_dir, 0777) unless -d $output_dir;
|
---|
114 |
|
---|
115 | my $have_tag = 1;
|
---|
116 | if ($cvs_tag !~ /\w/) {
|
---|
117 | $cvs_tag = $version_num;
|
---|
118 | $cvs_tag =~ s/\./\_/g;
|
---|
119 | $cvs_tag = "gsdl-" . $cvs_tag . "-distribution";
|
---|
120 | $have_tag = 0;
|
---|
121 | }
|
---|
122 |
|
---|
123 | &create_changelog() unless ($nochangelog || $useexistinglog);
|
---|
124 |
|
---|
125 | if (!$only_cols) {
|
---|
126 |
|
---|
127 | # tag repository
|
---|
128 | if (!$have_tag) {
|
---|
129 | print STDERR "\ntagging with $cvs_tag\n";
|
---|
130 | chdir ($ENV{'GSDLHOME'});
|
---|
131 | `cvs tag $cvs_tag`;
|
---|
132 | }
|
---|
133 |
|
---|
134 | # cvs export gsdl to $tmpdir
|
---|
135 | print STDERR "\nexporting gsdl ($cvs_tag) to $tmpdir\n\n";
|
---|
136 | chdir ($tmpdir);
|
---|
137 | `cvs -d $cvsroot export -r $cvs_tag gsdl`;
|
---|
138 |
|
---|
139 | # copy ChangeLog into $tmpdir/gsdl
|
---|
140 | &util::cp (&util::filename_cat($ENV{'GSDLHOME'}, "ChangeLog"),
|
---|
141 | &util::filename_cat($tmpdir, "gsdl")) unless $nochangelog;
|
---|
142 |
|
---|
143 | # edit the VERSION and fnord.cpp files
|
---|
144 | &edit_files();
|
---|
145 |
|
---|
146 | &create_windows_distribution();
|
---|
147 | &create_linux_distribution();
|
---|
148 | &create_src_distribution();
|
---|
149 | &create_cdrom_distribution() unless $no_cdrom;
|
---|
150 | }
|
---|
151 |
|
---|
152 | &create_collection_distributions() unless $no_cols;
|
---|
153 | }
|
---|
154 |
|
---|
155 | sub create_windows_distribution {
|
---|
156 | my $windows_dist_dir = &util::filename_cat ($output_dir, "gsdl-" . $version_num . "-win32");
|
---|
157 | mkdir ($windows_dist_dir, 0777);
|
---|
158 |
|
---|
159 | # docs directory and README.TXT
|
---|
160 | # &install_docs ($windows_dist_dir, 1); -- just README.TXT for windows web installation
|
---|
161 | &util::cp (&util::filename_cat($docdir, "README.TXT"), $windows_dist_dir);
|
---|
162 |
|
---|
163 | # gsdl directory
|
---|
164 | &install_gsdl ($windows_dist_dir);
|
---|
165 |
|
---|
166 | # src directory
|
---|
167 | &install_src ($windows_dist_dir, "windows");
|
---|
168 |
|
---|
169 | # Windows directory
|
---|
170 | &install_windows_specific ($windows_dist_dir, 0);
|
---|
171 |
|
---|
172 | # we want to include the unbuilt bits of the demo collection too
|
---|
173 | my $demodir = &util::filename_cat($windows_dist_dir, "gsdl", "collect", "demo");
|
---|
174 | my $demoetc = &util::filename_cat($demodir, "etc");
|
---|
175 | my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
|
---|
176 | die "oops, no demo dir\n" unless -d $demodir;
|
---|
177 | &util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
|
---|
178 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "org.txt"), $demoetc);
|
---|
179 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "sub.txt"), $demoetc);
|
---|
180 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "AZList.txt"), $demoetc);
|
---|
181 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "keyword.txt"), $demoetc);
|
---|
182 | &remove_cvs_dirs ($demodir);
|
---|
183 | }
|
---|
184 |
|
---|
185 | sub create_linux_distribution {
|
---|
186 | my $linux_dir = "gsdl-" . $version_num . "-linux";
|
---|
187 | my $linux_dist_dir = &util::filename_cat ($output_dir, $linux_dir);
|
---|
188 | mkdir ($linux_dist_dir, 0777);
|
---|
189 |
|
---|
190 | # empty "collect" directory
|
---|
191 | mkdir (&util::filename_cat($linux_dist_dir, "collect"), 0777);
|
---|
192 |
|
---|
193 | # docs directory, README.TXT, COPYING and Support.htm
|
---|
194 | &install_docs ($linux_dist_dir, 1);
|
---|
195 |
|
---|
196 | # gsdl directory
|
---|
197 | &install_gsdl ($linux_dist_dir);
|
---|
198 |
|
---|
199 | # src directory
|
---|
200 | &install_src ($linux_dist_dir, "unix");
|
---|
201 |
|
---|
202 | # Unix directory
|
---|
203 | &install_unix_specific ($linux_dist_dir);
|
---|
204 |
|
---|
205 | # we want to include the unbuilt bits of the demo collection too
|
---|
206 | my $demodir = &util::filename_cat($linux_dist_dir, "gsdl", "collect", "demo");
|
---|
207 | my $demoetc = &util::filename_cat($demodir, "etc");
|
---|
208 | my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
|
---|
209 | die "oops, no demo dir\n" unless -d $demodir;
|
---|
210 | &util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
|
---|
211 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "org.txt"), $demoetc);
|
---|
212 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "sub.txt"), $demoetc);
|
---|
213 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "title.txt"), $demoetc);
|
---|
214 | &remove_cvs_dirs ($demodir);
|
---|
215 |
|
---|
216 | # tar and gzip it
|
---|
217 | &zip ($linux_dir, $linux_dir, $output_dir, 2);
|
---|
218 | &util::rm_r ($linux_dist_dir);
|
---|
219 | }
|
---|
220 |
|
---|
221 | sub create_src_distribution {
|
---|
222 | my $src_zip = "gsdl-" . $version_num . "-src";
|
---|
223 | # we want the COPYING file in the source distribution too
|
---|
224 | &util::cp (&util::filename_cat($docdir, "COPYING"),
|
---|
225 | &util::filename_cat($tmpdir, "gsdl"));
|
---|
226 | # &edit_gsdlsite("/home/gsdl");
|
---|
227 | &zip ($src_zip, "gsdl", $tmpdir, 2);
|
---|
228 | &util::cp (&util::filename_cat($tmpdir, "$src_zip.tgz"), $output_dir);
|
---|
229 | # remove the COPYING file again to avoid confusion (it's copied to the right
|
---|
230 | # places by install_docs() for other distributions)
|
---|
231 | &util::rm (&util::filename_cat($tmpdir, "COPYING"));
|
---|
232 | }
|
---|
233 |
|
---|
234 | sub create_cdrom_distribution {
|
---|
235 | my $cdrom_dist_dir = &util::filename_cat ($output_dir, "gsdl-" . $version_num . "-cdrom");
|
---|
236 | mkdir ($cdrom_dist_dir, 0777);
|
---|
237 |
|
---|
238 | # collect directory (empty for now. we'll add collections manually)
|
---|
239 | mkdir (&util::filename_cat ($cdrom_dist_dir, "collect"), 0777);
|
---|
240 |
|
---|
241 | # docs directory and README.TXT
|
---|
242 | &install_docs ($cdrom_dist_dir, 0);
|
---|
243 |
|
---|
244 | # gsdl directory
|
---|
245 | &install_gsdl ($cdrom_dist_dir);
|
---|
246 |
|
---|
247 | # src directory
|
---|
248 | &install_src ($cdrom_dist_dir, "cdrom");
|
---|
249 |
|
---|
250 | # Windows directory
|
---|
251 | &install_windows_specific ($cdrom_dist_dir, 1);
|
---|
252 |
|
---|
253 | # Unix directory
|
---|
254 | &install_unix_specific ($cdrom_dist_dir);
|
---|
255 |
|
---|
256 | # for the cd-rom we want to include the unbuilt bits of the demo collection too
|
---|
257 | my $demodir = &util::filename_cat($cdrom_dist_dir, "gsdl", "collect", "demo");
|
---|
258 | my $demoetc = &util::filename_cat($demodir, "etc");
|
---|
259 | my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
|
---|
260 | die "oops, no demo dir\n" unless -d $demodir;
|
---|
261 | &util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
|
---|
262 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "org.txt"), $demoetc);
|
---|
263 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "sub.txt"), $demoetc);
|
---|
264 | &util::cp (&util::filename_cat ($tmpdemo, "etc", "title.txt"), $demoetc);
|
---|
265 | &remove_cvs_dirs ($demodir);
|
---|
266 |
|
---|
267 | }
|
---|
268 |
|
---|
269 | # isweb is 1 if it's one of the web distributions (i.e. if we don't
|
---|
270 | # want to install the manual) - this shouldn't be called at all for
|
---|
271 | # windows web installation as it doesn't use docs at all (not much
|
---|
272 | # point for self-extracting exe).
|
---|
273 | sub install_docs {
|
---|
274 | my ($install_dir, $isweb) = @_;
|
---|
275 |
|
---|
276 | # docs directory, README.TXT, COPYING and Support.htm
|
---|
277 | &util::cp_r (&util::filename_cat($docdir, "docs"), $install_dir);
|
---|
278 | &util::cp (&util::filename_cat($docdir, "README.TXT"), $install_dir);
|
---|
279 | &util::cp (&util::filename_cat($docdir, "COPYING"), $install_dir);
|
---|
280 | &util::cp (&util::filename_cat($docdir, "Support.htm"), $install_dir);
|
---|
281 | # don't want manuals for web distributions
|
---|
282 | if ($isweb) {
|
---|
283 | my $manfile = &util::filename_cat ($install_dir, "docs", "User.pdf");
|
---|
284 | &util::rm ($manfile) if -e $manfile;
|
---|
285 | $manfile = &util::filename_cat ($install_dir, "docs", "Install.pdf");
|
---|
286 | &util::rm ($manfile) if -e $manfile;
|
---|
287 | $manfile = &util::filename_cat ($install_dir, "docs", "Developer.pdf");
|
---|
288 | &util::rm ($manfile) if -e $manfile;
|
---|
289 | }
|
---|
290 | }
|
---|
291 |
|
---|
292 | sub install_gsdl {
|
---|
293 | my ($install_dir) = @_;
|
---|
294 |
|
---|
295 | my $gsdldir = &util::filename_cat ($install_dir, "gsdl");
|
---|
296 | my $gsdlbindir = &util::filename_cat ($gsdldir, "bin");
|
---|
297 | mkdir ($gsdldir, 0777);
|
---|
298 | mkdir ($gsdlbindir, 0777);
|
---|
299 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "script"), $gsdlbindir);
|
---|
300 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "bin", "java"), $gsdlbindir);
|
---|
301 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "cgi-bin"), $gsdldir);
|
---|
302 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "collect"), $gsdldir);
|
---|
303 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "etc"), $gsdldir);
|
---|
304 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "images"), $gsdldir);
|
---|
305 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "macros"), $gsdldir);
|
---|
306 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "perllib"), $gsdldir);
|
---|
307 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "mappings"), $gsdldir);
|
---|
308 |
|
---|
309 | # untar Ping.tgz
|
---|
310 | my $wd = cwd;
|
---|
311 | chdir (&util::filename_cat($gsdldir, "perllib", "cpan"));
|
---|
312 | `tar xvzf Ping.tgz`;
|
---|
313 | unlink ("Ping.tgz");
|
---|
314 | chdir ($wd);
|
---|
315 |
|
---|
316 | # make sure that modelcol collection contains all the right
|
---|
317 | # empty directories
|
---|
318 | my $modelindex = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "index");
|
---|
319 | &util::mk_all_dir ($modelindex) unless -d $modelindex;
|
---|
320 | my $modelbuilding = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "building");
|
---|
321 | &util::mk_all_dir ($modelbuilding) unless -d $modelbuilding;
|
---|
322 | my $modelarchives = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "archives");
|
---|
323 | &util::mk_all_dir ($modelarchives) unless -d $modelarchives;
|
---|
324 | my $modelimport = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "import");
|
---|
325 | &util::mk_all_dir ($modelimport) unless -d $modelimport;
|
---|
326 | my $modelperllib = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "perllib");
|
---|
327 | &util::mk_all_dir ($modelperllib) unless -d $modelperllib;
|
---|
328 | my $modelimages = &util::filename_cat ($tmpdir, "gsdl", "collect", "modelcol", "images");
|
---|
329 | &util::mk_all_dir ($modelimages) unless -d $modelimages;
|
---|
330 |
|
---|
331 | # demo collection needs to be pre-built
|
---|
332 | my $collectdir = &util::filename_cat ($gsdldir, "collect");
|
---|
333 | &util::rm_r (&util::filename_cat($collectdir, "demo"));
|
---|
334 | if (!&get_built_collection ("demo", $collectdir)) {
|
---|
335 | die "Couldn't get built version of demo collection\n";
|
---|
336 | }
|
---|
337 | }
|
---|
338 |
|
---|
339 | sub install_src {
|
---|
340 | my ($install_dir, $type) = @_;
|
---|
341 |
|
---|
342 | my $srcdir = &util::filename_cat ($install_dir, "src");
|
---|
343 | my $srcwindir = &util::filename_cat ($srcdir, "Windows");
|
---|
344 | my $srcunixdir = &util::filename_cat ($srcdir, "Unix");
|
---|
345 | mkdir ($srcdir, 0777);
|
---|
346 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "lib"), $srcdir);
|
---|
347 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "packages"), $srcdir);
|
---|
348 | &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "src"), $srcdir);
|
---|
349 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Install.txt"), $srcdir);
|
---|
350 |
|
---|
351 | if ($type ne "unix") {
|
---|
352 | mkdir ($srcwindir, 0777);
|
---|
353 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bat"), $srcwindir);
|
---|
354 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "win32.mak"), $srcwindir);
|
---|
355 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "WIN32cfg.h"), $srcwindir);
|
---|
356 | }
|
---|
357 |
|
---|
358 | if ($type ne "windows") {
|
---|
359 | mkdir ($srcunixdir, 0777);
|
---|
360 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "Makefile.in"), $srcunixdir);
|
---|
361 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "acconfig.h"), $srcunixdir);
|
---|
362 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "aclocal.m4"), $srcunixdir);
|
---|
363 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.h.in"), $srcunixdir);
|
---|
364 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configtest.pl"), $srcunixdir);
|
---|
365 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure"), $srcunixdir);
|
---|
366 | # make sure configure script is executable
|
---|
367 | my $configure_script = &util::filename_cat ($srcunixdir , "configure");
|
---|
368 | `chmod a+x $configure_script`;
|
---|
369 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "configure.in"), $srcunixdir);
|
---|
370 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.sub"), $srcunixdir);
|
---|
371 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "config.guess"), $srcunixdir);
|
---|
372 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "install-sh"), $srcunixdir);
|
---|
373 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.bash"), $srcunixdir);
|
---|
374 | &util::cp (&util::filename_cat ($tmpdir, "gsdl", "setup.csh"), $srcunixdir);
|
---|
375 | }
|
---|
376 | }
|
---|
377 |
|
---|
378 | # if $cd_rom is not true then we don't want to include the net16, net32,
|
---|
379 | # Win32s or netscape directories in the bin/windows directory (note that
|
---|
380 | # this currently means exportcol.pl will fail for all but cd-rom installed
|
---|
381 | # distributions)
|
---|
382 | sub install_windows_specific {
|
---|
383 | my ($install_dir, $cd_rom) = @_;
|
---|
384 |
|
---|
385 | my $windir = &util::filename_cat ($install_dir, "Windows");
|
---|
386 | my $winbindir = &util::filename_cat ($windir, "bin");
|
---|
387 | mkdir ($windir, 0777);
|
---|
388 | mkdir ($winbindir, 0777);
|
---|
389 | &util::cp_r ($winbin, $winbindir);
|
---|
390 |
|
---|
391 | if (!$cd_rom) {
|
---|
392 | &util::rm_r (&util::filename_cat ($winbindir, "windows", "net16"));
|
---|
393 | &util::rm_r (&util::filename_cat ($winbindir, "windows", "net32"));
|
---|
394 | &util::rm_r (&util::filename_cat ($winbindir, "windows", "Win32s"));
|
---|
395 | &util::rm_r (&util::filename_cat ($winbindir, "windows", "netscape"));
|
---|
396 | }
|
---|
397 |
|
---|
398 | # make sure there aren't any CVS directories laying around
|
---|
399 | &remove_cvs_dirs ($windir);
|
---|
400 | }
|
---|
401 |
|
---|
402 | sub install_unix_specific {
|
---|
403 | my ($install_dir) = @_;
|
---|
404 |
|
---|
405 | my $unixdir = &util::filename_cat ($install_dir, "Unix");
|
---|
406 | my $unixbindir = &util::filename_cat ($unixdir, "bin");
|
---|
407 | mkdir ($unixdir, 0777);
|
---|
408 | mkdir ($unixbindir, 0777);
|
---|
409 | &util::cp (&util::filename_cat($tmpdir, "gsdl", "Install.sh"), $unixdir);
|
---|
410 |
|
---|
411 | # make sure Install.sh is executable
|
---|
412 | my $install_sh = &util::filename_cat ($unixdir, "Install.sh");
|
---|
413 | `chmod a+x $install_sh`;
|
---|
414 | &util::cp_r ($linuxbin, $unixbindir);
|
---|
415 |
|
---|
416 | # make sure there aren't any CVS directories laying around
|
---|
417 | &remove_cvs_dirs ($unixdir);
|
---|
418 | }
|
---|
419 |
|
---|
420 | sub create_collection_distributions {
|
---|
421 |
|
---|
422 | # work out which collections we want
|
---|
423 | my @cols = ();
|
---|
424 | if (scalar @includecols) {
|
---|
425 | @cols = @includecols;
|
---|
426 | } else {
|
---|
427 | my $collectdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect");
|
---|
428 |
|
---|
429 | opendir (COLLECTDIR, $collectdir) || die;
|
---|
430 | my @cdirs = readdir COLLECTDIR;
|
---|
431 | closedir COLLECTDIR;
|
---|
432 | my %ignore = ();
|
---|
433 | map { $ignore{$_} = ""; } @ignorecols;
|
---|
434 | foreach $d (@cdirs) {
|
---|
435 | if ((-d &util::filename_cat($collectdir, $d)) && ($d ne ".") && ($d ne "..") &&
|
---|
436 | ($d ne "modelcol") && ($d ne "CVS") && (!defined $ignore{$d})) {
|
---|
437 | push (@cols, $d);
|
---|
438 | }
|
---|
439 | }
|
---|
440 | }
|
---|
441 |
|
---|
442 | return unless scalar @cols;
|
---|
443 |
|
---|
444 | # create distributions
|
---|
445 | foreach $collection (@cols) {
|
---|
446 | if (&get_built_collection ($collection, $tmpdir)) {
|
---|
447 | &zip ("$collection-prebuilt", $collection, $tmpdir, 0);
|
---|
448 | &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.tgz"), $output_dir);
|
---|
449 | &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.zip"), $output_dir);
|
---|
450 | } else {
|
---|
451 | print STDERR "ERROR: Couldn't create pre-built $collection collection\n";
|
---|
452 | }
|
---|
453 | &util::rm_r (&util::filename_cat ($tmpdir, $collection))
|
---|
454 | if -d &util::filename_cat ($tmpdir, $collection);
|
---|
455 |
|
---|
456 | if (&get_unbuilt_collection ($collection, $tmpdir)) {
|
---|
457 | &zip ($collection, $collection, $tmpdir, 0);
|
---|
458 | &util::cp (&util::filename_cat($tmpdir, "$collection.tgz"), $output_dir);
|
---|
459 | &util::cp (&util::filename_cat($tmpdir, "$collection.zip"), $output_dir);
|
---|
460 | } else {
|
---|
461 | print STDERR "ERROR: Couldn't create unbuilt $collection collection\n";
|
---|
462 | }
|
---|
463 | &util::rm_r (&util::filename_cat ($tmpdir, $collection))
|
---|
464 | if -d &util::filename_cat ($tmpdir, $collection);
|
---|
465 | }
|
---|
466 | }
|
---|
467 |
|
---|
468 | # gets all the right bits of a built collection from
|
---|
469 | # $GSDLHOME/collect and copies them to $collect_dir
|
---|
470 | # returns 1 if successful, 0 if not
|
---|
471 | sub get_built_collection {
|
---|
472 | my ($colname, $collect_dir) = @_;
|
---|
473 |
|
---|
474 | my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
|
---|
475 | if (!-d $from_dir) {
|
---|
476 | print STDERR "\nERROR: No collection at $from_dir\n";
|
---|
477 | return 0;
|
---|
478 | }
|
---|
479 |
|
---|
480 | my $to_dir = &util::filename_cat ($collect_dir, $colname);
|
---|
481 | mkdir ($to_dir, 0777) unless -d $to_dir;
|
---|
482 |
|
---|
483 | # get the built indexes
|
---|
484 | my $index_dir = &util::filename_cat ($from_dir, "index");
|
---|
485 | if (-d $index_dir) {
|
---|
486 | # if build.cfg exists we'll assume collection is built ok
|
---|
487 | if (-e &util::filename_cat ($index_dir, "build.cfg")) {
|
---|
488 | &util::cp_r ($index_dir, $to_dir);
|
---|
489 | } else {
|
---|
490 | print STDERR "\nERROR: no build.cfg at $index_dir (collection not built?)\n";
|
---|
491 | rmdir ($to_dir);
|
---|
492 | return 0;
|
---|
493 | }
|
---|
494 | } else {
|
---|
495 | print STDERR "\nERROR: collection at $from_dir appears unbuilt (no index directory)\n";
|
---|
496 | return 0;
|
---|
497 | }
|
---|
498 | &util::cp_r ($index_dir, $to_dir);
|
---|
499 |
|
---|
500 | # get the collect.cfg file
|
---|
501 | mkdir (&util::filename_cat($to_dir, "etc"), 0777);
|
---|
502 | &util::cp (&util::filename_cat($from_dir, "etc", "collect.cfg"),
|
---|
503 | &util::filename_cat($to_dir, "etc"));
|
---|
504 |
|
---|
505 | # get the images directory
|
---|
506 | my $from_images = &util::filename_cat ($from_dir, "images");
|
---|
507 | &util::cp_r ($from_images, $to_dir) if -d $from_images;
|
---|
508 |
|
---|
509 | # make sure there aren't any CVS directories laying around
|
---|
510 | &remove_cvs_dirs ($to_dir);
|
---|
511 |
|
---|
512 | &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
|
---|
513 | &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), 0);
|
---|
514 |
|
---|
515 | return 1;
|
---|
516 | }
|
---|
517 |
|
---|
518 | # gets all the right bits of an unbuilt collection from
|
---|
519 | # $GSDLHOME/collect and copies them to $collect_dir
|
---|
520 | # returns 1 if successful, 0 if not
|
---|
521 | sub get_unbuilt_collection {
|
---|
522 | my ($colname, $collect_dir) = @_;
|
---|
523 |
|
---|
524 | my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
|
---|
525 | if (!-d $from_dir) {
|
---|
526 | print STDERR "\nERROR: No collection at $from_dir\n";
|
---|
527 | return 0;
|
---|
528 | }
|
---|
529 |
|
---|
530 | my $to_dir = &util::filename_cat ($collect_dir, $colname);
|
---|
531 | mkdir ($to_dir, 0777) unless -d $to_dir;
|
---|
532 |
|
---|
533 | # get the unbuilt data (either import or archives)
|
---|
534 | my $have_import = 0;
|
---|
535 | my $import_dir = &util::filename_cat ($from_dir, "import");
|
---|
536 | if (-d $import_dir && opendir (IMPORTDIR, $import_dir)) {
|
---|
537 | my @importfiles = readdir IMPORTDIR;
|
---|
538 | closedir IMPORTDIR;
|
---|
539 | # if the import directory isn't empty we'll assume everything's ok
|
---|
540 | if (scalar @importfiles) {
|
---|
541 | $have_import = 1;
|
---|
542 | &util::cp_r ($import_dir, $to_dir);
|
---|
543 | mkdir (&util::filename_cat ($to_dir, "archives"), 0777);
|
---|
544 | }
|
---|
545 | }
|
---|
546 | if (!$have_import) {
|
---|
547 | # see if we've got archives then (check for archives.inf)
|
---|
548 | if (-e &util::filename_cat ($from_dir, "archives", "archives.inf")) {
|
---|
549 | &util::cp_r (&util::filename_cat($from_dir, "archives"), $to_dir);
|
---|
550 | } else {
|
---|
551 |
|
---|
552 | print STDERR "$collection collection appears to have no valid\n";
|
---|
553 | print STDERR "import or archives data\n";
|
---|
554 | &util::rm_r ($to_dir);
|
---|
555 | return 0;
|
---|
556 | }
|
---|
557 | }
|
---|
558 |
|
---|
559 | # get the etc directory
|
---|
560 | &util::cp_r (&util::filename_cat ($from_dir, "etc"), $to_dir);
|
---|
561 |
|
---|
562 | # get the perllib directory
|
---|
563 | &util::cp_r (&util::filename_cat ($from_dir, "perllib"), $to_dir);
|
---|
564 |
|
---|
565 | # get the images
|
---|
566 | &util::cp_r (&util::filename_cat ($from_dir, "images"), $to_dir);
|
---|
567 |
|
---|
568 | mkdir (&util::filename_cat ($to_dir, "building"), 0777);
|
---|
569 | mkdir (&util::filename_cat ($to_dir, "index"), 0777);
|
---|
570 |
|
---|
571 | # make sure there aren't any CVS directories laying around
|
---|
572 | &remove_cvs_dirs ($to_dir);
|
---|
573 |
|
---|
574 | &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
|
---|
575 | my $preimported = 0;
|
---|
576 | $preimported = 1 unless $have_import;
|
---|
577 | &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), $preimported);
|
---|
578 |
|
---|
579 | return 1;
|
---|
580 | }
|
---|
581 |
|
---|
582 | sub create_changelog {
|
---|
583 |
|
---|
584 | my ($tag, $date, $file);
|
---|
585 |
|
---|
586 | my $datefile = &util::filename_cat ($ENV{'GSDLHOME'}, "DistDates");
|
---|
587 | if ($changelogdate !~ /\w/) {
|
---|
588 | # get date from $GSDLHOME/DistDates (and update DistDates)
|
---|
589 | open (DATES, $datefile) || die "can't open $datefile\n";
|
---|
590 | my $line = "";
|
---|
591 | while (defined ($line = <DATES>)) {
|
---|
592 | if ($line =~ /\w/) {
|
---|
593 | ($tag, $date) = $line =~ /^(\S+)\t(.*)$/;
|
---|
594 | $changelogdate = $date unless ($tag eq $cvs_tag);
|
---|
595 | }
|
---|
596 | $file .= $line;
|
---|
597 | }
|
---|
598 | close DATES;
|
---|
599 | }
|
---|
600 |
|
---|
601 | if ((!defined $tag) || ($tag ne $cvs_tag)) {
|
---|
602 | open (DATES, ">$datefile") || die;
|
---|
603 | print DATES $file if defined $file;
|
---|
604 | print DATES "$cvs_tag\t" . `date`;
|
---|
605 | close DATES;
|
---|
606 | }
|
---|
607 |
|
---|
608 | print STDERR "Creating ChangeLog from $changelogdate to most recent\n";
|
---|
609 |
|
---|
610 | chdir($ENV{'GSDLHOME'});
|
---|
611 | my $cmd = "cvs2cl.pl -P -F trunk -r -S -l \"-d'$changelogdate<tomorrow'\"";
|
---|
612 | system ($cmd);
|
---|
613 | }
|
---|
614 |
|
---|
615 | # edits the gsdlsite.cfg file to set GSDLHOME
|
---|
616 | # makes a copy of the initial version of gsdlsite.cfg in
|
---|
617 | # /tmp (if it doesn't exist already).
|
---|
618 | sub edit_gsdlsite {
|
---|
619 | my ($gsdlhome) = @_;
|
---|
620 |
|
---|
621 | my $gsdlsite_file = &util::filename_cat ($tmpdir, "gsdl", "cgi-bin", "gsdlsite.cfg");
|
---|
622 | my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
|
---|
623 |
|
---|
624 | if (-e $tmp_gsdlsite_file) {
|
---|
625 | &util::cp ($tmp_gsdlsite_file, $gsdlsite_file);
|
---|
626 | } else {
|
---|
627 | &util::cp ($gsdlsite_file, $tmp_gsdlsite_file);
|
---|
628 | }
|
---|
629 |
|
---|
630 | open (GSDLSITE, $gsdlsite_file) || die;
|
---|
631 | my $line = ""; my $file = ""; my $found = 0;
|
---|
632 | while (defined ($line = <GSDLSITE>)) {
|
---|
633 | if ($line =~ s/\*\*GSDLHOME\*\*/$gsdlhome/g) {
|
---|
634 | $found = 1;
|
---|
635 | }
|
---|
636 | $file .= $line;
|
---|
637 | }
|
---|
638 | close GSDLSITE;
|
---|
639 |
|
---|
640 | if (!$found) {
|
---|
641 | die "ERROR: $gsdlsite_file contains no **GSDLHOME** string\n";
|
---|
642 | }
|
---|
643 |
|
---|
644 | open (GSDLSITE, ">$gsdlsite_file") || die;
|
---|
645 | print GSDLSITE $file;
|
---|
646 | close GSDLSITE;
|
---|
647 | }
|
---|
648 |
|
---|
649 | # currently just checks that iconcollection fields are correct and that
|
---|
650 | # creator and maintainer fields are set to [email protected]
|
---|
651 | sub edit_collect_cfg {
|
---|
652 | my ($collect_cfg_file, $collname) = @_;
|
---|
653 |
|
---|
654 | open (FILE, $collect_cfg_file) || die "couldn't open $collect_cfg_file\n";
|
---|
655 | my $line = ""; my $file = "";
|
---|
656 | while (defined ($line = <FILE>)) {
|
---|
657 | $line =~ s/^((?:creator|maintainer)\s+\"?)\w+@\w+(\"?)/$1greenstone\@cs.waikato.ac.nz$2/ix;
|
---|
658 | $line =~ s/^(collectionmeta\s+\"?iconcollection(?:small)?\"?\s+\"?).*?($collname\/images\/)/$1_httpprefix_\/collect\/$2/ix;
|
---|
659 | $file .= $line;
|
---|
660 | }
|
---|
661 | close FILE;
|
---|
662 |
|
---|
663 | open (FILE, ">$collect_cfg_file") || die;
|
---|
664 | print FILE $file;
|
---|
665 | close FILE;
|
---|
666 | }
|
---|
667 |
|
---|
668 | # the "collection release" is the version of the content - it should only change if the
|
---|
669 | # collections content is changed in some way
|
---|
670 | # the "build version" is the build version of Greenstone when the collection distribution
|
---|
671 | # was created
|
---|
672 |
|
---|
673 | # recent build version changes were:
|
---|
674 | # 2.0 - 2.1: plugins were altered to take input_encoding (and other) options. GB plugins
|
---|
675 | # were removed. numwords and numsections statistics were added.
|
---|
676 | # All build version 2.0 collections other than those that suddenly required
|
---|
677 | # the input_encoding option (i.e. Arabic and Chinese) may still be built and
|
---|
678 | # viewed using build verion 2.1 software (numwords and numsections won't be
|
---|
679 | # available though).
|
---|
680 |
|
---|
681 | sub create_version_file {
|
---|
682 | my ($version_file, $preimported) = @_;
|
---|
683 |
|
---|
684 | open (FILE, ">$version_file") || die;
|
---|
685 |
|
---|
686 | print FILE "collection release: 1.1\n";
|
---|
687 | print FILE "build version: 2.1\n";
|
---|
688 | print FILE "pre-imported\n" if $preimported;
|
---|
689 |
|
---|
690 | close FILE;
|
---|
691 | }
|
---|
692 |
|
---|
693 | # simply recurses directory structure beginning at $dir
|
---|
694 | # and deletes any CVS administrative directories it comes
|
---|
695 | # across
|
---|
696 | sub remove_cvs_dirs {
|
---|
697 | my ($dir) = @_;
|
---|
698 |
|
---|
699 | if (!-d $dir) {return;}
|
---|
700 |
|
---|
701 | opendir (DIR, $dir) || die;
|
---|
702 | my @files = readdir DIR;
|
---|
703 | closedir DIR;
|
---|
704 |
|
---|
705 | foreach $file (@files) {
|
---|
706 | next if $file =~ /^\.\.?$/;
|
---|
707 | my $fullpath = &util::filename_cat ($dir, $file);
|
---|
708 | if (-d $fullpath) {
|
---|
709 | if ($file eq "CVS") {
|
---|
710 | &util::rm_r ($fullpath);
|
---|
711 | } else {
|
---|
712 | &remove_cvs_dirs ($fullpath);
|
---|
713 | }
|
---|
714 | }
|
---|
715 | }
|
---|
716 | }
|
---|
717 |
|
---|
718 | # mode is 0 to create .zip and .tgz, 1 to create .zip only, and 2 to create
|
---|
719 | # .tgz only
|
---|
720 | sub zip {
|
---|
721 | my ($zip_to, $zip_from, $dir, $mode) = @_;
|
---|
722 |
|
---|
723 | chdir ($dir);
|
---|
724 |
|
---|
725 | if ($mode != 2) {
|
---|
726 | my $to = $zip_to . ".zip";
|
---|
727 | unlink ($to) if -e $to;
|
---|
728 | print STDERR "zipping up $to\n";
|
---|
729 | `zip -r $to $zip_from`;
|
---|
730 | }
|
---|
731 | if ($mode != 1) {
|
---|
732 | my $to = $zip_to . ".tgz";
|
---|
733 | unlink ($to) if -e $to;
|
---|
734 | print STDERR "tarring and gzipping $to\n";
|
---|
735 | print STDERR "tar cvzf $to $zip_from\n";
|
---|
736 | system ("tar cvzf $to $zip_from");
|
---|
737 | }
|
---|
738 | }
|
---|
739 |
|
---|
740 | sub edit_files {
|
---|
741 | # edit VERSION file
|
---|
742 | my $version_file = &util::filename_cat ($tmpdir, "gsdl", "etc" , "VERSION");
|
---|
743 | open (VERSION, $version_file) || die "failed to open $version_file\n";
|
---|
744 | my $found = 0; my $line = ""; my $file = "";
|
---|
745 | while (defined ($line = <VERSION>)) {
|
---|
746 | if ($line =~ s/(gsdl version: )x\.xx/$1$version_num/) {
|
---|
747 | $found ++;
|
---|
748 | } elsif ($line =~ s/(cvs tag: )gsdl-x_xx-distribution/$1$cvs_tag/) {
|
---|
749 | $found ++;
|
---|
750 | }
|
---|
751 | $file .= $line;
|
---|
752 | }
|
---|
753 | close VERSION;
|
---|
754 | if ($found != 2) {
|
---|
755 | die "error while editing $version_file\n";
|
---|
756 | }
|
---|
757 |
|
---|
758 | open (VERSION, ">$version_file") || die;
|
---|
759 | print VERSION $file;
|
---|
760 | close VERSION;
|
---|
761 |
|
---|
762 | # edit gsdlconf.h
|
---|
763 | my $gsdlconf_file = &util::filename_cat ($tmpdir, "gsdl", "lib", "gsdlconf.h");
|
---|
764 | open (GSDLCONF, $gsdlconf_file) || die;
|
---|
765 | $found = 0; $line = ""; $file = "";
|
---|
766 | while (defined ($line = <GSDLCONF>)) {
|
---|
767 | if ($line =~ s/(\#define GSDL_VERSION \")x\.xx(\")/$1$version_num$2/) {
|
---|
768 | $found ++;
|
---|
769 | }
|
---|
770 | $file .= $line;
|
---|
771 | }
|
---|
772 | close GSDLCONF;
|
---|
773 | if (!$found) {
|
---|
774 | die "error while editing $gsdlconf_file\n";
|
---|
775 | }
|
---|
776 |
|
---|
777 | open (GSDLCONF, ">$gsdlconf_file") || die;
|
---|
778 | print GSDLCONF $file;
|
---|
779 | close GSDLCONF;
|
---|
780 | }
|
---|
781 |
|
---|
782 | END {
|
---|
783 | # remove any temporary files we created
|
---|
784 | print STDERR "\ndeleting temporary files\n";
|
---|
785 | my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
|
---|
786 | if (-e $tmp_gsdlsite_file) {
|
---|
787 | print STDERR "$tmp_gsdlsite_file\n";
|
---|
788 | unlink($tmp_gsdlsite_file);
|
---|
789 | }
|
---|
790 | my $tmp_gsdlhome = &util::filename_cat ($tmpdir, "gsdl");
|
---|
791 | if (-d $tmp_gsdlhome) {
|
---|
792 | print STDERR "$tmp_gsdlhome\n";
|
---|
793 | &util::rm_r ($tmp_gsdlhome);
|
---|
794 | }
|
---|
795 | }
|
---|