Changeset 1679


Ignore:
Timestamp:
2000-11-20T14:03:26+13:00 (23 years ago)
Author:
sjboddie
Message:

Re-Added recent changes that were lost when the CVS repository was moved.
Mostly stuff to do with the collector and building code.

Location:
trunk/gsdl
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/doc.pm

    r1388 r1679  
    220220                       $ENV{'GSDLOS'},"hashfile$osexe");
    221221    my $result = "NULL";
    222 
     222   
    223223    if (-e "$hashfile_exe") {
    224     $result = `$hashfile_exe \"$filename\"`;
     224#   $result = `\"$hashfile_exe\" \"$filename\"`;
     225    $result = `hashfile$osexe \"$filename\"`;
    225226    ($result) = $result =~ /:\s*([0-9a-f]+)/i;
    226227
     
    252253
    253254    } else {
    254        
    255         print STDERR "doc::set_OID source filename undefined/non-existant (continuing)\n";
     255
     256        # this warning causes more confusion than it's worth I think
     257        # -- sorry Gordon.
     258#       print STDERR "doc::set_OID source filename undefined/non-existant (continuing)\n";
    256259       
    257260        $filename = &util::get_tmp_filename();
  • trunk/gsdl/perllib/mgbuilder.pm

    r1483 r1679  
    203203    } else {
    204204    if (!-e "$mg_passes_exe" ||
    205         !open (PIPEOUT, "| $mg_passes_exe -f $fulltextprefix -b $maxdocsize -T1 $osextra")) {
     205#       !open (PIPEOUT, "| \"$mg_passes_exe\" -f \"$fulltextprefix\" -b $maxdocsize -T1 $osextra")) {
     206        !open (PIPEOUT, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T1 $osextra")) {
    206207        die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
    207208    }
     
    234235        die "mgbuilder::compress_text - couldn't run $mg_compression_dict_exe\n";
    235236    }
    236     system ("$mg_compression_dict_exe -f $fulltextprefix -S -H -2 -k 5120 $osextra");
     237#   system ("\"$mg_compression_dict_exe\" -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
     238    system ("mg_compression_dict$exe -f \"$fulltextprefix\" -S -H -2 -k 5120 $osextra");
    237239
    238240    # -b $maxdocsize sets the maximum document size to be 12 meg
    239241    if (!-e "$mg_passes_exe" ||
    240         !open ($handle, "| $mg_passes_exe -f $fulltextprefix -b $maxdocsize -T2 $osextra")) {
     242#       !open ($handle, "| \"$mg_passes_exe\" -f \"$fulltextprefix\" -b $maxdocsize -T2 $osextra")) {
     243        !open ($handle, "| mg_passes$exe -f \"$fulltextprefix\" -b $maxdocsize -T2 $osextra")) {
    241244        die "mgbuilder::compress_text - couldn't run $mg_passes_exe\n";
    242245    }
     
    484487    } else {
    485488    if (!-e "$mg_passes_exe" ||
    486         !open (PIPEOUT, "| $mg_passes_exe -f $fullindexprefix -b $maxdocsize " .
     489#       !open (PIPEOUT, "| \"$mg_passes_exe\" -f \"$fullindexprefix\" -b $maxdocsize " .
     490        !open (PIPEOUT, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
    487491           "-$index_level -m 32 -s 0 -G -t 10 -N1 $osextra")) {
    488492        die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
     
    509513        die "mgbuilder::build_index - couldn't run $mg_perf_hash_build_exe\n";
    510514    }
    511     system ("$mg_perf_hash_build_exe -f $fullindexprefix $osextra");
     515#   system ("\"$mg_perf_hash_build_exe\" -f \"$fullindexprefix\" $osextra");
     516    system ("mg_perf_hash_build$exe -f \"$fullindexprefix\" $osextra");
    512517
    513518    if (!-e "$mg_passes_exe" ||
    514         !open ($handle, "| $mg_passes_exe -f $fullindexprefix -b $maxdocsize " .
     519#       !open ($handle, "| \"$mg_passes_exe\" -f \"$fullindexprefix\" -b $maxdocsize " .
     520        !open ($handle, "| mg_passes$exe -f \"$fullindexprefix\" -b $maxdocsize " .
    515521           "-$index_level -c 3 -G -t 10 -N2 $osextra")) {
    516522        die "mgbuilder::build_index - couldn't run $mg_passes_exe\n";
     
    536542        die "mgbuilder::build_index - couldn't run $mg_weights_build_exe\n";
    537543    }
    538     system ("$mg_weights_build_exe -f $fullindexprefix -t $fulltextprefix $osextra");
     544#   system ("\"$mg_weights_build_exe\" -f \"$fullindexprefix\" -t \"$fulltextprefix\" $osextra");
     545    system ("mg_weights_build$exe -f \"$fullindexprefix\" -t \"$fulltextprefix\" $osextra");
    539546
    540547    # create 'on-disk' stemmed dictionary
     
    543550        die "mgbuilder::build_index - couldn't run $mg_invf_dict_exe\n";
    544551    }
    545     system ("$mg_invf_dict_exe -f $fullindexprefix $osextra");
     552#   system ("\"$mg_invf_dict_exe\" -f \"$fullindexprefix\" $osextra");
     553    system ("mg_invf_dict$exe -f \"$fullindexprefix\" $osextra");
    546554
    547555
     
    551559        die "mgbuilder::build_index - couldn't run $mg_stem_idx_exe\n";
    552560    }
    553     system ("$mg_stem_idx_exe -b 4096 -s1 -f $fullindexprefix $osextra");
    554     system ("$mg_stem_idx_exe -b 4096 -s2 -f $fullindexprefix $osextra");
    555     system ("$mg_stem_idx_exe -b 4096 -s3 -f $fullindexprefix $osextra");
     561#   system ("\"$mg_stem_idx_exe\" -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
     562    system ("mg_stem_idx$exe -b 4096 -s1 -f \"$fullindexprefix\" $osextra");
     563#   system ("\"$mg_stem_idx_exe\" -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
     564    system ("mg_stem_idx$exe -b 4096 -s2 -f \"$fullindexprefix\" $osextra");
     565#   system ("\"$mg_stem_idx_exe\" -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
     566    system ("mg_stem_idx$exe -b 4096 -s3 -f \"$fullindexprefix\" $osextra");
    556567
    557568   
     
    603614    $handle = STDOUT;
    604615    } else {
    605     if (!-e "$txt2db_exe" || !open (PIPEOUT, "| $txt2db_exe $fulldbname")) {
     616#   if (!-e "$txt2db_exe" || !open (PIPEOUT, "| \"$txt2db_exe\" \"$fulldbname\"")) {
     617    if (!-e "$txt2db_exe" || !open (PIPEOUT, "| txt2db$exe \"$fulldbname\"")) {
    606618        die "mgbuilder::make_infodatabase - couldn't run $txt2db_exe\n";
    607619    }
     
    679691    my $mgstat_exe = &util::filename_cat($exedir, "mgstat$exe");
    680692    my $input_file = &util::filename_cat ("text", $self->{'collection'});
    681     if (!-e "$mgstat_exe" || !open (PIPEIN, "$mgstat_exe -d $self->{'build_dir'} -f $input_file |")) {
     693#    if (!-e "$mgstat_exe" || !open (PIPEIN, "\"$mgstat_exe\" -d \"$self->{'build_dir'}\" -f \"$input_file\" |")) {
     694    if (!-e "$mgstat_exe" || !open (PIPEIN, "mgstat$exe -d \"$self->{'build_dir'}\" -f \"$input_file\" |")) {
    682695    print $outhandle "Warning: Couldn't open pipe to $mgstat_exe to get additional stats\n";
    683696    } else {
  • trunk/gsdl/src/recpt/collectoraction.cpp

    r1660 r1679  
    4848  gsdlosc = NULL;
    4949  gsdlhomec = NULL;
     50  pathc = NULL;
    5051
    5152  cgiarginfo arg_ainfo;
     
    217218  if (gsdlosc != NULL) delete gsdlosc;
    218219  if (gsdlhomec != NULL) delete gsdlhomec;
     220  if (pathc != NULL) delete pathc;
    219221}
    220222
    221223bool collectoraction::init (ostream & /*logout*/) {
    222224
    223   // set up GSDLOS and GSDLHOME environment variables
    224   text_t gsdlos;
     225  // set up GSDLOS, GSDLHOME and PATH environment variables
     226  text_t gsdlos, path;
     227  unsigned int path_separator = ':';
    225228#if defined (__WIN32__)
    226229  gsdlos = "windows";
     230  path_separator = ';';
    227231#else
    228232  utsname *buf = new utsname();
     
    233237  lc (gsdlos);
    234238#endif
    235  
     239
     240  pathc = getenv ("PATH");
     241  path = filename_cat (gsdlhome, "bin", gsdlos);
     242  path.push_back (path_separator);
     243  path += filename_cat (gsdlhome, "bin", "script");
     244  if (pathc != NULL) {
     245    path.push_back (path_separator);
     246    path += pathc;
     247  }
     248  path = "PATH=" + path;
     249
    236250  gsdlos = "GSDLOS=" + gsdlos;
    237251  text_t setgsdlhome = "GSDLHOME=" + gsdlhome;
     
    240254  gsdlosc = gsdlos.getcstr();
    241255  gsdlhomec = setgsdlhome.getcstr();
     256  pathc = path.getcstr();
    242257 
    243258  putenv (gsdlosc);
    244259  putenv (gsdlhomec);
     260  putenv (pathc);
    245261
    246262  return true;
     
    272288    // partially built collection laying about -- may need to think about doing
    273289    // this in the background).
    274     text_t cleantmp_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "cleantmp.pl");
    275     char *cleantmp_cmdc = cleantmp_cmd.getcstr();
    276     system (cleantmp_cmdc);
    277     delete cleantmp_cmdc;
     290    gsdl_call_perl ("cleantmp.pl", NULL);
    278291  }
    279292
     
    798811  // _header_ -- may be set for pages that require it
    799812  // _faillog_ - set to last 6 lines of .bld file if build failed
     813  // _gsdlhome_ - the gsdlhome path (dm_safe)
    800814
    801815  text_t &collector_page = args["cp"];
     
    930944      here ++;
    931945    }
    932     disp.setmacro ("faillog", "collector", faillog);
     946    disp.setmacro ("faillog", "collector", dm_safe(faillog));
    933947  }
    934948
     
    942956  if (collector_page == "bildstatus")
    943957    set_statusline (disp, args, logout);
     958
     959  disp.setmacro ("gsdlhome", "collector", dm_safe(gsdlhome));
    944960}
    945961
     
    974990   
    975991    } else {
    976    
    977       text_t delete_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "delcol.pl");
    978       delete_cmd += " -f " + collection;
    979       char *delete_cmdc = delete_cmd.getcstr();
    980       int rv = system (delete_cmdc);
    981       delete delete_cmdc;
     992      // first we need to free up the collection's collection server
     993      // we must do this for the local library (and I guess when using
     994      // fastcgi too) as you can't delete the gdbm file while it's
     995      // being kept open by the collection server
     996      remove_colservr (collection, logout);
     997
     998      char *collectionc = collection.getcstr();
     999      int rv = gsdl_call_perl ("delcol.pl", "-f", collectionc, NULL);
     1000      delete collectionc;
    9821001      if (rv != 0) {
    9831002    // deletion failed -- permissions?
     
    11521171  if (file_exists (createfile)) {
    11531172    return;
     1173  }
     1174
     1175  // set up options
     1176  text_t options = "-creator \"" + args["bc1contactemail"] + "\"";
     1177  options += " -title \"" + args["bc1fullname"] + "\"";
     1178  options += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\"";
     1179  options += " -collectdir \"" + tmpdir + "\" ";
     1180  text_t optionfile = filename_cat (tmpdir, "mkcol.opt");
     1181  char *optionfilec = optionfile.getcstr();
     1182  ofstream ofile_out (optionfilec);
     1183  if (!ofile_out) {
     1184    message = "tmpfail";
     1185    delete optionfilec;
     1186    return;
     1187  }
     1188  outconvertclass text_t2ascii;
     1189  ofile_out << text_t2ascii << options << "\n";
     1190  ofile_out.close();
     1191
     1192  char *collectionc = collection.getcstr();
     1193
     1194  // this is just an ordinary system call running in the foreground. we're assuming (hoping??)
     1195  // that mkcol.pl will run through fast enough that nothing more elaborate is required.
     1196  gsdl_call_perl ("mkcol.pl", "-optionfile", optionfilec, collectionc, NULL);
     1197
     1198  delete optionfilec;
     1199  delete collectionc;
     1200
     1201  // make sure it went ok
     1202  text_t cfgfile = filename_cat (tmpdir, collection, "etc", "collect.cfg");
     1203  if (!file_writable (cfgfile)) {
     1204    message = "mkcolfail";
    11541205  } else {
    11551206    // create the .create file (this file is just a place holder to let any future
     
    11651216      return;
    11661217    }
    1167   }
    1168 
    1169   // set up options
    1170   text_t options = "-creator \"" + args["bc1contactemail"] + "\"";
    1171   options += " -title \"" + args["bc1fullname"] + "\"";
    1172   options += " -about \"" + carriage_replace (args["bc1aboutdesc"], 0) + "\"";
    1173   options += " -collectdir \"" + tmpdir + "\" ";
    1174   text_t optionfile = filename_cat (tmpdir, "mkcol.opt");
    1175   char *optionfilec = optionfile.getcstr();
    1176   ofstream ofile_out (optionfilec);
    1177   delete optionfilec;
    1178   if (!ofile_out) {
    1179     message = "tmpfail";
    1180     return;
    1181   }
    1182   outconvertclass text_t2ascii;
    1183   ofile_out << text_t2ascii << options << "\n";
    1184   ofile_out.close();
    1185  
    1186   // set up the mkcol.pl command
    1187   text_t mkcol_cmd = "perl ";
    1188   mkcol_cmd += filename_cat (gsdlhome, "bin", "script", "mkcol.pl");
    1189   mkcol_cmd += " -optionfile \"" + optionfile + "\" " + collection;
    1190   char *mkcol_cmdc = mkcol_cmd.getcstr();
    1191  
    1192   // just an ordinary system call running in the foreground. we're assuming (hoping??)
    1193   // that mkcol.pl will run through fast enough that nothing more elaborate is required.
    1194   system (mkcol_cmdc);
    1195   delete mkcol_cmdc;
    1196  
    1197   // make sure it went ok
    1198   text_t cfgfile = filename_cat (tmpdir, collection, "etc", "collect.cfg");
    1199   if (!file_writable (cfgfile)) {
    1200     message = "mkcolfail";
    12011218  }
    12021219}
     
    12551272    options += " -download \"" + args["bc1inputdir4"] + "\"";
    12561273  text_t optionfile = filename_cat (tmpdir, "build.opt");
    1257   char *optionfilet = optionfile.getcstr();
    1258   ofstream ofile_out (optionfilet);
    1259   delete optionfilet;
     1274  char *optionfilec = optionfile.getcstr();
     1275  ofstream ofile_out (optionfilec);
     1276  delete optionfilec;
    12601277  if (!ofile_out) {
    12611278    message = "tmpfail";
     
    12671284
    12681285  // set up the build command
    1269   text_t build_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "build");
    1270   build_cmd += " -optionfile \"" + optionfile + "\" " + collection;
    1271 #if !defined (__WIN32__)
    1272   // run in background on unix systems
    1273   //  build_cmd += " &";
    1274 #endif
     1286  // Can't seem to get "perl -S" to work properly here on windows 95...
     1287  //text_t build_cmd = "perl -S build -optionfile \"" + optionfile + "\" " + collection;
     1288  text_t build_cmd = "perl \"" + filename_cat(gsdlhome, "bin", "script", "build") +
     1289    "\" -optionfile \"" + optionfile + "\" " + collection;
    12751290  char *build_cmdc = build_cmd.getcstr();
    1276   //#if defined (__WIN32__)
     1291  // run build command in background
    12771292  gsdl_system (build_cmdc, logout);
    1278   //#else
    1279   //  system (build_cmdc);
    1280   //#endif
    12811293  delete build_cmdc;
    12821294}
     
    12861298  // c++ code. I ran into some problems though (like how do you write a portable
    12871299  // "rm -r" in c++?). One day I'll spend some time sorting it out ... maybe.
    1288   text_t cancel_cmd = "perl " + filename_cat (gsdlhome, "bin", "script", "cancel_build.pl");
    1289   cancel_cmd += " -collectdir \"" + filename_cat (gsdlhome, "tmp", args["bc1tmp"]) +
    1290     "\" " + args["bc1dirname"];
    1291   char *cancel_cmdc = cancel_cmd.getcstr();
    1292   system (cancel_cmdc);
    1293   delete (cancel_cmdc);
     1300  text_t collectdir = filename_cat (gsdlhome, "tmp", args["bc1tmp"]);
     1301  char *collectdirc = collectdir.getcstr();
     1302  char *collectionc = args["bc1dirname"].getcstr();
     1303
     1304  gsdl_call_perl ("cancel_build.pl", "-collectdir", collectdirc, collectionc, NULL);
     1305  delete (collectdirc);
     1306  delete (collectionc);
    12941307}
    12951308
     
    13751388  logout << "collectoraction::create_colserver: no valid nullproto found\n";
    13761389}
     1390
     1391// delete a collection server from the null protocol
     1392void collectoraction::remove_colservr (const text_t &collection, ostream &logout) {
     1393
     1394  recptprotolistclass *protos = recpt->get_recptprotolist_ptr();
     1395  recptprotolistclass::iterator rprotolist_here = protos->begin();
     1396  recptprotolistclass::iterator rprotolist_end = protos->end();
     1397  while (rprotolist_here != rprotolist_end) {
     1398    if ((*rprotolist_here).p != NULL) {
     1399      if ((*rprotolist_here).p->get_protocol_name () == "nullproto") {
     1400    (*rprotolist_here).p->remove_collection (collection, logout);
     1401    return;
     1402      }
     1403    }
     1404    rprotolist_here ++;
     1405  }
     1406
     1407  logout << "collectoraction::create_colserver: no valid nullproto found\n";
     1408}
  • trunk/gsdl/src/recpt/collectoraction.h

    r1649 r1679  
    3838  char *gsdlosc;
    3939  char *gsdlhomec;
     40  char *pathc;
    4041
    4142  text_t message;
     
    7980  void create_colserver (const text_t &collection, ostream &logout);
    8081
     82  void remove_colservr (const text_t &collection, ostream &logout);
     83
    8184public:
    8285  collectoraction ();
  • trunk/gsdl/src/recpt/nullproto.cpp

    r1649 r1679  
    151151}
    152152
     153// remove_collection deletes the collection server of collection.
     154// This only needs to be called if a collectionserver is to be
     155// removed while the library is running. The destructor function
     156// cleans up all collectservers when the program exits.
     157void nullproto::remove_collection (const text_t &collection, ostream &logout) {
     158  collectservermapclass::iterator here = cservers.begin();
     159  collectservermapclass::iterator end = cservers.end();
     160
     161  while (here != end) {
     162    if ((*here).second.c != NULL && (*here).first == collection) {
     163      delete (*here).second.c;
     164      cservers.erase (here);
     165      return;
     166    }
     167    here ++;
     168  }
     169  outconvertclass text_t2ascii;
     170  logout << text_t2ascii << "nullproto::remove_collection: failed to remove collectserver for "
     171     << collection << "\n";
     172}
     173
    153174// this configure will configure each of the collection servers
    154175void nullproto::configure (const text_t &key, const text_tarray &cfgline) {
  • trunk/gsdl/src/recpt/nullproto.h

    r1649 r1679  
    4949    {cservers.addcollectserver(thecserver);}
    5050
     51  // remove_collection deletes the collection server of collection.
     52  // This only needs to be called if a collectionserver is to be
     53  // removed while the library is running as the destructor function
     54  // cleans up all collectservers when the program exits.
     55  void remove_collection (const text_t &collection, ostream &logout);
     56
    5157  // this configure will configure each of the collection servers
    5258  void configure (const text_t &key, const text_tarray &cfgline);
  • trunk/gsdl/src/recpt/recptproto.cpp

    r1649 r1679  
    3131void recptproto::add_collection (const text_t &/*collection*/, void * /*recpt*/,
    3232                 const text_t &/*gsdlhome*/, const text_t &/*gdbmhome*/) {
     33}
     34
     35void recptproto::remove_collection (const text_t &/*collection*/, ostream &/*logout*/) {
    3336}
    3437
  • trunk/gsdl/src/recpt/recptproto.h

    r1649 r1679  
    5757  virtual void add_collection (const text_t &collection, void *recpt,
    5858                   const text_t &gsdlhome, const text_t &gdbmhome);
     59
     60  virtual void remove_collection (const text_t &collection, ostream &logout);
    5961
    6062  // configure should be called for each line in the configuration file
  • trunk/gsdl/src/w32server/cgiwrapper.cpp

    r1649 r1679  
    659659                  RequestInfoT *RequestInfo,
    660660                  RequestFieldsT *RequestFields) {
    661   char tmpstr[1024];
    662   char tailstr[MAX_URL_SIZE];
     661  char tmpstr[MAX_URL_SIZE+1024];
     662  char tailstr[MAX_URL_SIZE+16];
    663663 
    664664  // do any url adjustments necessary
     
    722722}
    723723
    724 int ExamineURIStr(char *URIStr,RequestInfoT *RequestInfo,
     724int ExamineURIStr(char *URIStr, RequestInfoT *RequestInfo,
    725725          RequestFieldsT *RequestFields)
    726726{
     
    740740      }
    741741      URIStr[len] = '\0';
     742    } else {
     743      MessageBox (NULL, "POST data too long", "Greenstone Digital Library Software", MB_OK);
    742744    }
    743745  }
Note: See TracChangeset for help on using the changeset viewer.