#!/usr/bin/perl -w # create_distributions.pl creates the following distributions from the gsdl # directory pointed to by $GSDLHOME (although it uses the main CVS # repository to get the latest source code distribution). # Windows distribution - gsdl-x.xx-win32.exe # Creates directory structure for this - use installshield and # packagefortheweb to create self-extracting executable # Linux distribution - gsdl-x.xx-linux.tgz # Source distribution - gsdl-x.xx.tgz # cd-rom distribution = gsdl-x.xx-cdrom.tgz # Creates directory structure - use installshield to create media # for writing to cd-rom # all collections in $GSDLHOME/collect (except modelcol and those # explicitly ignored by -ignorecol options): # pre-built (collname-prebuilt) .tgz .zip # unbuilt (collname) .tgz .zip # creates ChangeLog using `cvs2cl.pl -P -F trunk -r -S -l "-d'date)) { if ($line =~ /\w/) { ($tag, $date) = $line =~ /^(\S+)\t(.*)$/; $changelogdate = $date unless ($tag eq $cvs_tag); } $file .= $line; } close DATES; } if ((!defined $tag) || ($tag ne $cvs_tag)) { open (DATES, ">$datefile") || die; print DATES $file if defined $file; print DATES "$cvs_tag\t" . `date`; close DATES; } print STDERR "Creating ChangeLog from $changelogdate to most recent\n"; chdir($ENV{'GSDLHOME'}); my $cmd = "cvs2cl.pl -P -F trunk -r -S -l \"-d'$changelogdate)) { if ($line =~ s/\*\*GSDLHOME\*\*/$gsdlhome/g) { $found = 1; } $file .= $line; } close GSDLSITE; if (!$found) { die "ERROR: $gsdlsite_file contains no **GSDLHOME** string\n"; } open (GSDLSITE, ">$gsdlsite_file") || die; print GSDLSITE $file; close GSDLSITE; } # currently just checks that iconcollection fields are correct and that # creator and maintainer fields are set to greenstone@cs.waikato.ac.nz sub edit_collect_cfg { my ($collect_cfg_file, $collname) = @_; open (FILE, $collect_cfg_file) || die "couldn't open $collect_cfg_file\n"; my $line = ""; my $file = ""; while (defined ($line = )) { $line =~ s/^((?:creator|maintainer)\s+\"?)\w+@\w+(\"?)/$1greenstone\@cs.waikato.ac.nz$2/ix; $line =~ s/^(collectionmeta\s+\"?iconcollection(?:small)?\"?\s+\"?).*?($collname\/images\/)/$1_httpprefix_\/collect\/$2/ix; $file .= $line; } close FILE; open (FILE, ">$collect_cfg_file") || die; print FILE $file; close FILE; } # the "collection release" is the version of the content - it should only change if the # collections content is changed in some way # the "build version" is the build version of Greenstone when the collection distribution # was created # recent build version changes were: # 2.0 - 2.1: plugins were altered to take input_encoding (and other) options. GB plugins # were removed. numwords and numsections statistics were added. # All build version 2.0 collections other than those that suddenly required # the input_encoding option (i.e. Arabic and Chinese) may still be built and # viewed using build verion 2.1 software (numwords and numsections won't be # available though). sub create_version_file { my ($version_file, $preimported) = @_; open (FILE, ">$version_file") || die; print FILE "collection release: 1.1\n"; print FILE "build version: 2.1\n"; print FILE "pre-imported\n" if $preimported; close FILE; } # simply recurses directory structure beginning at $dir # and deletes any CVS administrative directories it comes # across sub remove_cvs_dirs { my ($dir) = @_; if (!-d $dir) {return;} opendir (DIR, $dir) || die; my @files = readdir DIR; closedir DIR; foreach $file (@files) { next if $file =~ /^\.\.?$/; my $fullpath = &util::filename_cat ($dir, $file); if (-d $fullpath) { if ($file eq "CVS") { &util::rm_r ($fullpath); } else { &remove_cvs_dirs ($fullpath); } } } } # mode is 0 to create .zip and .tgz, 1 to create .zip only, and 2 to create # .tgz only sub zip { my ($zip_to, $zip_from, $dir, $mode) = @_; chdir ($dir); if ($mode != 2) { my $to = $zip_to . ".zip"; unlink ($to) if -e $to; print STDERR "zipping up $to\n"; `zip -r $to $zip_from`; } if ($mode != 1) { my $to = $zip_to . ".tgz"; unlink ($to) if -e $to; print STDERR "tarring and gzipping $to\n"; print STDERR "tar cvzf $to $zip_from\n"; system ("tar cvzf $to $zip_from"); } } sub edit_files { # edit VERSION file my $version_file = &util::filename_cat ($tmpdir, "gsdl", "etc" , "VERSION"); open (VERSION, $version_file) || die; my $found = 0; my $line = ""; my $file = ""; while (defined ($line = )) { if ($line =~ s/(gsdl version: )x\.xx/$1$version_num/) { $found ++; } elsif ($line =~ s/(cvs tag: )gsdl-x_xx-distribution/$1$cvs_tag/) { $found ++; } $file .= $line; } close VERSION; if ($found != 2) { die "error while editing $version_file\n"; } open (VERSION, ">$version_file") || die; print VERSION $file; close VERSION; # edit fnord.cpp my $fnord_file = &util::filename_cat ($tmpdir, "gsdl", "src", "w32server", "fnord.cpp"); open (FNORD, $fnord_file) || die; $found = 0; $line = ""; $file = ""; while (defined ($line = )) { if ($line =~ s/(\#define VERSIONSTRING \"version )x\.xx(\")/$1$version_num$2/) { $found ++; } $file .= $line; } close FNORD; if (!$found) { die "error while editing $fnord_file\n"; } open (FNORD, ">$fnord_file") || die; print FNORD $file; close FNORD; } END { # remove any temporary files we created print STDERR "\ndeleting temporary files\n"; my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg"); if (-e $tmp_gsdlsite_file) { print STDERR "$tmp_gsdlsite_file\n"; unlink($tmp_gsdlsite_file); } my $tmp_gsdlhome = &util::filename_cat ($tmpdir, "gsdl"); if (-d $tmp_gsdlhome) { print STDERR "$tmp_gsdlhome\n"; &util::rm_r ($tmp_gsdlhome); } }