Changeset 13517


Ignore:
Timestamp:
2006-12-15T10:21:12+13:00 (15 years ago)
Author:
nzdl
Message:

I tidied this up heaps, changed some of the options, removed unnecessary code - kjdon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/for-distributions/bin/script/create_distributions.pl

    r13474 r13517  
    88
    99
    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 
     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 CVS 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.
    3018
    3119#    creates ChangeLog using `cvs2cl.pl -P -F trunk -r -S -l "-d'date<tomorrow'"
     
    3624#    so ChangeLog contains lots of ancient stuff
    3725
    38 #    sets a cvs tag called gsdl-x_xx-distribution (unless -cvs_tag is set
    39 #    in which case it uses that)
    40 
    4126#    creates a copy of everything in cvs repository in $tmpdir
    4227
     
    4631
    4732# temporary working directory
    48 my $tmpdir = '/tmp';
     33my $tmpdir = '/tmp/';
    4934
    5035# docs directory - up-to-date copy of everything to go in the docs directory
     
    7964    print STDERR "  usage: $0 [options]\n\n";
    8065    print STDERR "  options:\n";
     66    print STDERR "   -tmpdir                temporary directory to use instead of $tmpdir\n";
     67    print STDERR "   -output_dir            directory to output distributions to\n";
    8168    print STDERR "   -version_num           version number of distribution (x.xx)\n";
    8269    print STDERR "   -cvs_tag               cvs tag from which to create distributions\n";
    83     print STDERR "                          - if not set latest versions will be used and\n";
    84     print STDERR "                          a tag will be set\n";
    85     print STDERR "   -no_cdrom              don't create cd-rom version\n";
     70    print STDERR "                          - if not set latest versions will be used.\n";
    8671    print STDERR "   -unesco                create unesco style release, i.e. only 4 languages enabled\n";
    87     print STDERR "   -no_cols               don't attempt to create any collection distributions\n";
    88     print STDERR "   -only_cols             create collection distributions only\n";
    89     print STDERR "   -includecol            collection to include (by default all collections in\n";
    90     print STDERR "                          $ENV{'GSDLHOME'}/collect will be included\n";
    91     print STDERR "   -ignorecol             directory in $ENV{'GSDLHOME'}/collect to ignore (i.e.\n";
    92     print STDERR "                          don't include as collection in distribution)\n";
    93     print STDERR "   -output_dir            directory to output distributions to\n";
    9472    print STDERR "   -NoChangeLog           don't create ChangeLog\n";
    9573    print STDERR "   -UseExistingLog        use $ENV{'GSDLHOME'}/ChangeLog rather than creating one\n";
     
    10179&main ();
    10280
     81my $newtmpdir;
    10382my $version_num;
    10483my $cvs_tag;
    105 my $no_cdrom;
    10684my $unesco;
    107 my $no_cols;
    108 my $only_cols;
    10985my $nochangelog;
    11086my $useexistinglog;
    11187my $changelogdate;
    11288my $output_dir;
    113 my @includecols;
    114 my @ignorecols;
    11589
    11690sub main
    11791{
    11892    if (!parsargv::parse(\@ARGV,
     93             'tmpdir/.*/', \$newtmpdir,
    11994             'version_num/\d\.\d\d[a-z]?', \$version_num,
    12095             'cvs_tag/.*/', \$cvs_tag,
    121              'no_cdrom', \$no_cdrom,
    12296             'unesco', \$unesco,
    123              'no_cols', \$no_cols,
    124              'only_cols', \$only_cols,
    125              'includecol/.*', \@includecols,
    126              'ignorecol/.*', \@ignorecols,
    12797             'NoChangeLog', \$nochangelog,
    12898             'UseExistingLog', \$useexistinglog,
     
    133103    }
    134104
     105    $tmpdir = $newtmpdir if (defined $newtmpdir && -d $newtmpdir);
    135106    $output_dir = "." unless $output_dir =~ /\w/;
    136107    mkdir ($output_dir, 0777) unless -d $output_dir;
    137108
    138     my $have_tag = 0;
    139109    if ($cvs_tag !~ /\w/) {
    140110    $cvs_tag = $version_num;
    141111    $cvs_tag =~ s/\./\_/g;
    142112    $cvs_tag = "gsdl-" . $cvs_tag . "-distribution";
    143     $have_tag = 1;
    144113    }
    145114
    146115    &create_changelog() unless ($nochangelog || $useexistinglog);
    147 
    148     if (!$only_cols) {
    149 
    150     if ($have_tag) {
    151         # Tag gsdl repository
    152         #chdir ($ENV{'GSDLHOME'});
    153         #print STDERR "\ntagging gsdl with $cvs_tag\n";
    154         # `cvs tag -F $cvs_tag`;
    155 
    156         # Tag gli repository
    157         #chdir (&util::filename_cat($ENV{'GSDLHOME'}, "gli"));
    158         #print STDERR "\ntagging gli with $cvs_tag\n";
    159         # `cvs tag -F $cvs_tag`;
    160     }
    161 
    162     # Export gsdl to $tmpdir
    163     print STDERR "\nexporting gsdl ($cvs_tag) to $tmpdir\n\n";
    164     chdir($tmpdir);
    165     # `cvs -d $cvsanon export -r $cvs_tag gsdl`;
    166     `cvs -d $cvsanon export -D "1 second ago" gsdl`;
    167     #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gsdl`;
    168 
    169     # Export gli to $tmpdir/gli
    170     print STDERR "\nexporting gli ($cvs_tag) to " . &util::filename_cat($tmpdir, "gsdl") . "\n\n";
    171     chdir(&util::filename_cat($tmpdir, "gsdl"));
    172     # `cvs -d $cvsanon export -r $cvs_tag gli`;
    173     `cvs -d $cvsanon export -D "1 second ago" gli`;
    174         #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gli`;
    175 
    176     # Compile gli
    177     print STDERR "\ncompiling gli...\n";
    178     chdir(&util::filename_cat($tmpdir, "gsdl", "gli"));
    179     `./makegli.sh`;
    180 
    181     # JAR up the gli, then delete the class files
    182     print STDERR "jarring gli...\n";
    183     `./makejar.sh`;
    184     &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "jar"));
    185     &util::rm(&util::filename_cat($tmpdir, "gsdl", "gli", "metadata.zip"));
    186     &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "classes", "org"));
    187 
    188     # Move the GLIServer.jar file created by makejar.sh into bin/java
    189     &util::mv(&util::filename_cat($tmpdir, "gsdl", "gli", "GLIServer.jar"),
    190           &util::filename_cat($tmpdir, "gsdl", "bin", "java"));
    191 
    192     # Remove bits used by none of the distributions
    193     &util::rm(&util::filename_cat($tmpdir, "gsdl", "packages", "cpan", "XML-Parser-2.27.tar.gz"));
    194 
    195     # copy ChangeLog into $tmpdir/gsdl
    196     &util::cp(&util::filename_cat($ENV{'GSDLHOME'}, "ChangeLog"),
    197           &util::filename_cat($tmpdir, "gsdl")) unless $nochangelog;
    198 
    199     # edit the VERSION and fnord.cpp files
    200     &edit_files();
    201 
    202     &create_unix_distribution();
    203     &create_source_distribution();
    204     &create_cdrom_distribution() unless $no_cdrom;
    205     }
    206 
    207     # &create_collection_distributions() unless $no_cols;
    208 }
    209 
     116   
     117    # Export gsdl to $tmpdir
     118    print STDERR "\nexporting gsdl to $tmpdir\n\n";
     119    chdir($tmpdir);
     120    `cvs -d $cvsanon export -D "1 second ago" gsdl`;
     121    # use something like the following if you want a previous version
     122    #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gsdl`;
     123   
     124    # Export gli to $tmpdir/gli
     125    print STDERR "\nexporting gli to " . &util::filename_cat($tmpdir, "gsdl") . "\n\n";
     126    chdir(&util::filename_cat($tmpdir, "gsdl"));
     127    `cvs -d $cvsanon export -D "1 second ago" gli`;
     128    # use something like the following if you want a previous version
     129    #`cvs -d $cvsanon export -r gsdl-2_70-distribution-branch gli`;
     130   
     131    # Compile gli
     132    &compile_gli();
     133   
     134    # Remove bits used by none of the distributions
     135    &util::rm(&util::filename_cat($tmpdir, "gsdl", "packages", "cpan", "XML-Parser-2.27.tar.gz"));
     136   
     137    # copy ChangeLog into $tmpdir/gsdl
     138    &util::cp(&util::filename_cat($ENV{'GSDLHOME'}, "ChangeLog"),
     139          &util::filename_cat($tmpdir, "gsdl")) unless $nochangelog;
     140   
     141    # edit the VERSION and fnord.cpp files
     142    &edit_files();
     143   
     144    &create_unix_distribution();
     145    &create_source_distribution();
     146    &create_cdrom_distribution();
     147}
     148
     149
     150sub compile_gli
     151{
     152    print STDERR "\ncompiling gli...\n";
     153    chdir(&util::filename_cat($tmpdir, "gsdl", "gli"));
     154    `./makegli.sh`;
     155   
     156    # JAR up the gli, then delete the class files
     157    print STDERR "jarring gli...\n";
     158    `./makejar.sh`;
     159    &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "jar"));
     160    &util::rm(&util::filename_cat($tmpdir, "gsdl", "gli", "metadata.zip"));
     161    &util::rm_r(&util::filename_cat($tmpdir, "gsdl", "gli", "classes", "org"));
     162   
     163    # Move the GLIServer.jar file created by makejar.sh into bin/java
     164    &util::mv(&util::filename_cat($tmpdir, "gsdl", "gli", "GLIServer.jar"),
     165          &util::filename_cat($tmpdir, "gsdl", "bin", "java"));
     166
     167    # Make the gli-client.zip file
     168    chdir($tmpdir);
     169   
     170    # take a copy of GLI directory
     171    &util::cp_r(&util::filename_cat($tmpdir, "gsdl", "gli"), $tmpdir);
     172   
     173    my $client_dirname = "gli-client-" . $version_num;
     174    rename ("gli", $client_dirname);
     175    chdir(&util::filename_cat($tmpdir, $client_dirname));
     176
     177   
     178    # delete unnecessary stuff
     179    `rm -rf clean.* document.* gems.* gli*.sh gli*.bat make*.sh make*.bat lib src`;
     180    # make sure permissions are ok
     181    `chmod a+x client-gli.sh client-gli.bat`;
     182    chdir($tmpdir);
     183   
     184    # zip up the client
     185    &zip($client_dirname, $client_dirname, $tmpdir, 1);
     186   
     187    # Move the zip file to the destination directory
     188   
     189    &util::cp(&util::filename_cat($tmpdir, "$client_dirname.zip"), $output_dir);
     190    &util::rm_r(&util::filename_cat($tmpdir, $client_dirname));
     191    &util::rm(&util::filename_cat($tmpdir, "$client_dirname.zip"));
     192
     193}
    210194
    211195sub create_unix_distribution
     
    261245    }
    262246
    263     # Don't need the "images/garish" directory for web releases
    264     #&util::rm_r(&util::filename_cat($gsdldir, "images", "garish"));
    265 
    266     # Remove the copied "macros" folder and copy over just the core language macros
    267     #my $gsdlmacrosdir = &util::filename_cat($source_dist_dir, "gsdl", "macros");
    268     #&util::rm_r($gsdlmacrosdir);
    269     #&install_only_core_language_macros(&util::filename_cat($tmpdir, "gsdl", "macros"), $gsdlmacrosdir);
    270 
    271247    # We don't want the compiled GLI classes in the source distribution (or the GS3 scripts)
    272248    &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", ".greenstonestore"));
     
    275251    &util::rm(&util::filename_cat($source_dist_dir, "gsdl", "gli", "gli4gs3.sh"));
    276252
    277     # (We don't include the built demo collection in the source distribution)
    278253}
    279254
     
    305280
    306281    # for the cd-rom we want to include the unbuilt bits of the demo collection too
    307     my $demodir = &util::filename_cat($cdrom_dist_dir, "gsdl", "collect", "demo");
    308     my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
    309     die "oops, no demo dir\n" unless -d $demodir;
    310     &util::cp (&util::filename_cat ($tmpdemo, "demo.col"), $demodir);
    311     &util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
    312     &util::cp_r (&util::filename_cat ($tmpdemo, "metadata"), $demodir);
    313 
    314     # collect directory, with documented example collections and customised home.dm file
    315     # no longer use customised home.dm
     282    #my $demodir = &util::filename_cat($cdrom_dist_dir, "gsdl", "collect", "demo");
     283    #my $tmpdemo = &util::filename_cat($tmpdir, "gsdl", "collect", "demo");
     284    #die "oops, no demo dir\n" unless -d $demodir;
     285    #&util::cp (&util::filename_cat ($tmpdemo, "demo.col"), $demodir);
     286    #&util::cp_r (&util::filename_cat ($tmpdemo, "import"), $demodir);
     287    #&util::cp_r (&util::filename_cat ($tmpdemo, "metadata"), $demodir);
     288
     289    # collect directory, with documented example collections
    316290    my $cdrom_collect_dir = &util::filename_cat ($cdrom_dist_dir, "collect");
    317291    mkdir($cdrom_collect_dir, 0777);
     
    320294    my $target_collect_dir = &util::filename_cat($cdrom_dist_dir, "collect");
    321295
    322 # *****
    323296    &util::cp_r(&util::filename_cat($source_collect_dir, "MARC-e"), $target_collect_dir);
    324297    &util::cp_r(&util::filename_cat($source_collect_dir, "authen-e"), $target_collect_dir);
     
    335308    &util::cp_r(&util::filename_cat($source_collect_dir, "style-e"), $target_collect_dir);
    336309    &util::cp_r(&util::filename_cat($source_collect_dir, "pagedimg-e"), $target_collect_dir);
    337     # The customised home.dm file must have a modified date after the gsdl/macros/home.dm file
    338     # no longer use customised home.dm
    339     #&util::cp(&util::filename_cat($for_distributions_dir, "macros", "home.dm"), $cdrom_collect_dir);
    340310
    341311    # Make sure the whole thing is user-writeable
     
    437407    }
    438408
    439     # Install all images (non-core languages are now not included)
    440409    &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "images"), $gsdldir);
    441 
    442     #my $gsdlmacrosdir = &util::filename_cat ($gsdldir, "macros");
    443     #&install_only_core_language_macros(&util::filename_cat($tmpdir, "gsdl", "macros"), $gsdlmacrosdir);
    444     # Install all macrofiles now
    445410    &util::cp_r(&util::filename_cat ($tmpdir, "gsdl", "macros"), $gsdldir);
    446411    &util::cp_r (&util::filename_cat ($tmpdir, "gsdl", "mappings"), $gsdldir);
     
    493458}
    494459
    495 # no longer used!
    496 sub install_only_core_language_macros
    497 {
    498     my ($source_dir, $target_dir) = @_;
    499     mkdir($target_dir, 0777);
    500 
    501     # Language independent (theoretically) macrofiles
    502     my @basicmacrofiles = ("about.dm", "authen.dm", "base.dm", "browse.dm", "bsummary.dm",
    503                "collect.dm", "dateqry.dm", "docs.dm", "document.dm",
    504                "exported_home.dm", "extlink.dm", "extra.dm",
    505                "garish.dm", "gli.dm", "gsdl.dm", "gti.dm", "help.dm", "home.dm", "html.dm", "nav_css.dm",
    506                "nzdlhome.dm", "pref.dm", "query.dm", "status.dm", "style.dm",
    507                "tip.dm", "users.dm", "yourhome.dm");
    508 
    509     # Core language (English, French, Spanish, Russian) macrofiles
    510     my @corelanguagemacrofiles = ("english.dm", "english2.dm", "french.dm", "french2.dm",
    511                   "spanish.dm", "spanish2.dm", "russian.dm", "russian2.dm",
    512                   "yourhome-es.dm", "yourhome-fr.dm");
    513 
    514     # Copy the macrofiles
    515     foreach my $file ((@basicmacrofiles, @corelanguagemacrofiles)) {
    516     &util::cp(&util::filename_cat($source_dir, $file), $target_dir);
    517     }
    518 }
    519 
    520460
    521461sub install_gli
     
    632572}
    633573
    634 # if $cd_rom is not true then we don't want to include the net16, net32,
    635 # Win32s or netscape directories in the bin/windows directory (note that
    636 # this currently means exportcol.pl will fail for all but cd-rom installed
    637 # distributions)
    638574sub install_windows_specific {
    639575    my ($install_dir, $cd_rom) = @_;
     
    645581    &util::cp_r ($winbin, $winbindir);
    646582
    647     if (!$cd_rom) {
    648     &util::rm_r (&util::filename_cat ($winbindir, "windows", "Win32s"));
    649     &util::rm_r (&util::filename_cat ($winbindir, "windows", "netscape"));
    650     }
    651 
    652583    # make sure there aren't any CVS directories laying around
    653584    &remove_cvs_dirs ($windir);
     
    684615}
    685616
    686 sub create_collection_distributions {
    687    
    688     # work out which collections we want
    689     my @cols = ();
    690     if (scalar @includecols) {
    691     @cols = @includecols;
    692     } else {
    693     my $collectdir = &util::filename_cat($ENV{'GSDLHOME'}, "collect");
    694 
    695     opendir (COLLECTDIR, $collectdir) || die;
    696     my @cdirs = readdir COLLECTDIR;
    697     closedir COLLECTDIR;
    698     my %ignore = ();
    699     map { $ignore{$_} = ""; } @ignorecols;
    700     foreach my $d (@cdirs) {
    701         if ((-d &util::filename_cat($collectdir, $d)) && ($d ne ".") && ($d ne "..") &&
    702         ($d ne "modelcol") && ($d ne "CVS") && (!defined $ignore{$d})) {
    703         push (@cols, $d);
    704         }
    705     }
    706     }
    707    
    708     return unless scalar @cols;
    709 
    710     # create distributions
    711     foreach my $collection (@cols) {
    712     if (&get_built_collection ($collection, $tmpdir)) {
    713         &zip ("$collection-prebuilt", $collection, $tmpdir, 0);
    714         &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.tgz"), $output_dir);
    715         &util::cp (&util::filename_cat($tmpdir, "$collection-prebuilt.zip"), $output_dir);
    716     } else {
    717         print STDERR "ERROR: Couldn't create pre-built $collection collection\n";
    718     }
    719     &util::rm_r (&util::filename_cat ($tmpdir, $collection))
    720         if -d &util::filename_cat ($tmpdir, $collection);
    721 
    722     if (&get_unbuilt_collection ($collection, $tmpdir)) {
    723         &zip ($collection, $collection, $tmpdir, 0);
    724         &util::cp (&util::filename_cat($tmpdir, "$collection.tgz"), $output_dir);
    725         &util::cp (&util::filename_cat($tmpdir, "$collection.zip"), $output_dir);
    726     } else {
    727         print STDERR "ERROR: Couldn't create unbuilt $collection collection\n";
    728     }
    729     &util::rm_r (&util::filename_cat ($tmpdir, $collection))
    730         if -d &util::filename_cat ($tmpdir, $collection);
    731     }
    732 }
    733617
    734618# gets all the right bits of a built collection from
     
    769653           &util::filename_cat($to_dir, "etc"));
    770654
    771     # get the images directory
     655    # get the .col file
     656    &util::cp (&util::filename_cat($from_dir, "$colname.col"),
     657           $to_dir);
     658    # get any other directories - import, metadata, images, macros, perllib
     659    my $from_import = &util::filename_cat ($from_dir, "import");
     660    &util::cp_r ($from_import, $to_dir) if -d $from_import;
     661    my $from_metadata = &util::filename_cat ($from_dir, "metadata");
     662    &util::cp_r ($from_metadata, $to_dir) if -d $from_metadata;
    772663    my $from_images = &util::filename_cat ($from_dir, "images");
    773664    &util::cp_r ($from_images, $to_dir) if -d $from_images;
    774    
     665    my $from_macros = &util::filename_cat ($from_dir, "macros");
     666    &util::cp_r ($from_macros, $to_dir) if -d $from_macros;
     667    my $from_perllib = &util::filename_cat ($from_dir, "perllib");
     668    &util::cp_r ($from_perllib, $to_dir) if -d $from_perllib;
     669
    775670    # make sure there aren't any CVS directories laying around
    776671    &remove_cvs_dirs ($to_dir);
    777672
    778     &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
    779     &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), 0);
    780 
    781673    return 1;
    782674}
    783 
    784 # gets all the right bits of an unbuilt collection from
    785 # $GSDLHOME/collect and copies them to $collect_dir
    786 # returns 1 if successful, 0 if not
    787 sub get_unbuilt_collection {
    788     my ($colname, $collect_dir) = @_;
    789 
    790     my $from_dir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $colname);
    791     if (!-d $from_dir) {
    792     print STDERR "\nERROR: No collection at $from_dir\n";
    793     return 0;
    794     }
    795    
    796     my $to_dir = &util::filename_cat ($collect_dir, $colname);
    797     mkdir ($to_dir, 0777) unless -d $to_dir;
    798 
    799     # get the unbuilt data (either import or archives)
    800     my $have_import = 0;
    801     my $import_dir = &util::filename_cat ($from_dir, "import");
    802     if (-d $import_dir && opendir (IMPORTDIR, $import_dir)) {
    803     my @importfiles = readdir IMPORTDIR;
    804     closedir IMPORTDIR;
    805     # if the import directory isn't empty we'll assume everything's ok
    806     if (scalar @importfiles) {
    807         $have_import = 1;
    808         &util::cp_r ($import_dir, $to_dir);
    809         mkdir (&util::filename_cat ($to_dir, "archives"), 0777);
    810     }
    811     }
    812     if (!$have_import) {
    813     # see if we've got archives then (check for archives.inf)
    814     if (-e &util::filename_cat ($from_dir, "archives", "archives.inf")) {
    815         &util::cp_r (&util::filename_cat($from_dir, "archives"), $to_dir);
    816     } else {
    817 
    818         print STDERR "$colname collection appears to have no valid\n";
    819         print STDERR "import or archives data\n";
    820         &util::rm_r ($to_dir);
    821         return 0;
    822     }
    823     }
    824    
    825     # get the etc directory
    826     &util::cp_r (&util::filename_cat ($from_dir, "etc"), $to_dir);
    827 
    828     # get the perllib directory
    829     &util::cp_r (&util::filename_cat ($from_dir, "perllib"), $to_dir);
    830 
    831     # get the images
    832     &util::cp_r (&util::filename_cat ($from_dir, "images"), $to_dir);
    833    
    834     mkdir (&util::filename_cat ($to_dir, "building"), 0777);
    835     mkdir (&util::filename_cat ($to_dir, "index"), 0777);
    836 
    837     # make sure there aren't any CVS directories laying around
    838     &remove_cvs_dirs ($to_dir);
    839 
    840     &edit_collect_cfg (&util::filename_cat($to_dir, "etc", "collect.cfg"), $colname);
    841     my $preimported = 0;
    842     $preimported = 1 unless $have_import;
    843     &create_version_file (&util::filename_cat($to_dir, "etc", "VERSION"), $preimported);
    844 
    845     return 1;
    846 }
    847 
    848675
    849676sub force_windows_line_endings
     
    897724}
    898725
    899 # edits the gsdlsite.cfg file to set GSDLHOME
    900 # makes a copy of the initial version of gsdlsite.cfg in
    901 # /tmp (if it doesn't exist already).
    902 # sub edit_gsdlsite {
    903 #     my ($gsdlhome) = @_;
    904 
    905 #     my $gsdlsite_file = &util::filename_cat ($tmpdir, "gsdl", "cgi-bin", "gsdlsite.cfg");
    906 #     my $tmp_gsdlsite_file = &util::filename_cat ($tmpdir, "gsdlsite.cfg");
    907 
    908 #     if (-e $tmp_gsdlsite_file) {
    909 #   &util::cp ($tmp_gsdlsite_file, $gsdlsite_file);
    910 #     } else {
    911 #   &util::cp ($gsdlsite_file, $tmp_gsdlsite_file);
    912 #     }
    913 
    914 #     open (GSDLSITE, $gsdlsite_file) || die;
    915 #     my $line = ""; my $file = ""; my $found = 0;
    916 #     while (defined ($line = <GSDLSITE>)) {
    917 #   if ($line =~ s/\*\*GSDLHOME\*\*/$gsdlhome/g) {
    918 #       $found = 1;
    919 #   }
    920 #   $file .= $line;
    921 #     }
    922 #     close GSDLSITE;
    923 
    924 #     if (!$found) {
    925 #   die "ERROR: $gsdlsite_file contains no **GSDLHOME** string\n";
    926 #     }
    927 
    928 #     open (GSDLSITE, ">$gsdlsite_file") || die;
    929 #     print GSDLSITE $file;
    930 #     close GSDLSITE;
    931 # }
    932 
    933 # currently just checks that iconcollection fields are correct and that
    934 # creator and maintainer fields are set to greenstone@cs.waikato.ac.nz
    935 sub edit_collect_cfg {
    936     my ($collect_cfg_file, $collname) = @_;
    937 
    938     open (FILE, $collect_cfg_file) || die "couldn't open $collect_cfg_file\n";
    939     my $line = ""; my $file = "";
    940     while (defined ($line = <FILE>)) {
    941     $line =~ s/^((?:creator|maintainer)\s+\"?)[\w\.]+@[\w\.]+(\"?)/$1greenstone\@cs.waikato.ac.nz$2/ix;
    942     # !! This will stuff up if there are handle language qualifiers eg. [l=en] !!
    943     # $line =~ s/^(collectionmeta\s+\"?iconcollection(?:small)?\"?\s+\"?).*?($collname\/images\/)/$1_httpprefix_\/collect\/$2/ix;
    944     $file .= $line;
    945     }
    946     close FILE;
    947 
    948     open (FILE, ">$collect_cfg_file") || die;
    949     print FILE $file;
    950     close FILE;
    951 }
    952 
    953 # the "collection release" is the version of the content - it should only change if the
    954 # collections content is changed in some way
    955 # the "build version" is the build version of Greenstone when the collection distribution
    956 # was created
    957 
    958 # recent build version changes were:
    959 # 2.0 - 2.1: plugins were altered to take input_encoding (and other) options. GB plugins
    960 #            were removed. numwords and numsections statistics were added.
    961 #            All build version 2.0 collections other than those that suddenly required
    962 #            the input_encoding option (i.e. Arabic and Chinese) may still be built and
    963 #            viewed using build verion 2.1 software (numwords and numsections won't be
    964 #            available though).
    965 
    966 sub create_version_file {
    967     my ($version_file, $preimported) = @_;
    968    
    969     open (FILE, ">$version_file") || die;
    970    
    971     print FILE "collection release: 1.1\n";
    972     print FILE "build version: 2.1\n";
    973     print FILE "pre-imported\n" if $preimported;
    974 
    975     close FILE;
    976 }
    977 
    978726# simply recurses directory structure beginning at $dir
    979727# and deletes any CVS administrative directories it comes
Note: See TracChangeset for help on using the changeset viewer.