Changeset 1198
- Timestamp:
- 2000-05-30T11:34:59+12:00 (24 years ago)
- Location:
- trunk/gsdl/bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/build
r1185 r1198 1 1 #!/usr/bin/perl 2 2 3 # This perl script is intended mostly for use on unix systems (hence no .pl 4 # extension and the use of '/'s in paths). On windows it's suggested you 5 # use build.bat (it's the same perl code with a batch file wrapper). 3 # This perl script may be called directly or by running build.bat on 4 # windows (build.bat is in bin\windows) 6 5 7 6 BEGIN { 8 die "GSDLHOME not set - did you remember to source setup.bash?\n" 9 unless defined $ENV{'GSDLHOME'}; 10 die "GSDLOS not set - did you remember to source setup.bash?\n" 11 unless defined $ENV{'GSDLOS'}; 7 8 die "GSDLHOME not set - did you remember to source setup.bash (unix) or " . 9 "run setup.bat (windows)?\n" unless defined $ENV{'GSDLHOME'}; 10 die "GSDLOS not set - did you remember to source setup.bash (unix) or " . 11 "run setup.bat (windows)?\n" unless defined $ENV{'GSDLOS'}; 12 12 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 13 13 } … … 15 15 use parsargv; 16 16 use util; 17 18 19 if (!parsargv::parse(\@ARGV, 20 'buildtype/^(build|import)$/import', \$buildtype, 21 'maxdocs/^\-?\d+/-1', \$maxdocs)) { 22 &print_usage(); 23 die "\n"; 24 } 25 26 my ($collection) = @ARGV; 27 28 if (!defined $collection || $collection !~ /\w/) { 29 print STDERR "You must specify a collection to build\n"; 30 &print_usage(); 31 die "\n"; 32 } 33 34 if ($maxdocs == -1) { 35 $maxdocs = ""; 36 } else { 37 $maxdocs = "-maxdocs $maxdocs"; 38 } 39 40 41 my $collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collection); 42 my $importdir = &util::filename_cat ($collectdir, "import"); 43 my $archivedir = &util::filename_cat ($collectdir, "archives"); 44 my $buildingdir = &util::filename_cat ($collectdir, "building"); 45 my $indexdir = &util::filename_cat ($collectdir, "index"); 46 my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin"); 17 47 18 48 &main(); … … 29 59 sub main { 30 60 31 if (!parsargv::parse(\@ARGV, 32 'buildtype/^(build|import)$/import', \$buildtype, 33 'maxdocs/^\-?\d+/-1', \$maxdocs)) { 34 &print_usage(); 35 die "\n"; 36 } 37 38 ($collection) = @ARGV; 39 40 if (!defined $collection || $collection !~ /\w/) { 41 print STDERR "You must specify a collection to build\n"; 42 &print_usage(); 43 die "\n"; 44 } 45 46 if ($maxdocs == -1) { 47 $maxdocs = ""; 48 } else { 49 $maxdocs = "-maxdocs $maxdocs"; 50 } 51 52 if (-e "$ENV{'GSDLHOME'}/collect/$collection/archives/archives.inf") { 53 if (&has_content ("$ENV{'GSDLHOME'}/collect/$collection/import")) { 61 if (-e &util::filename_cat ($archivedir, "archives.inf")) { 62 if (&has_content ($importdir)) { 54 63 if ($buildtype eq "build") { 55 64 &gsdl_build(); … … 65 74 } 66 75 } else { 67 if (&has_content ( "$ENV{'GSDLHOME'}/collect/$collection/import")) {76 if (&has_content ($importdir)) { 68 77 if ($buildtype eq "build") { 69 78 print STDERR "build: can't build directly from archives as no\n"; … … 87 96 88 97 print STDERR "importing the $collection collection\n\n"; 89 system ("perl $ENV{'GSDLHOME'}/bin/script/import.pl -removeold $maxdocs $collection"); 90 if (-e "$ENV{'GSDLHOME'}/collect/$collection/archives/archives.inf") { 98 99 my $import = &util::filename_cat ($bindir, "script", "import.pl"); 100 system ("perl $import -removeold $maxdocs $collection"); 101 if (-e &util::filename_cat ($archivedir, "archives.inf")) { 91 102 print STDERR "$collection collection imported successfully\n\n"; 92 103 } else { … … 98 109 99 110 print STDERR "building the $collection collection\n\n"; 100 system ("perl $ENV{'GSDLHOME'}/bin/script/buildcol.pl $maxdocs $collection");101 111 102 if (-e "$ENV{'GSDLHOME'}/collect/$collection/building/text/$collection.ldb" || 103 -e "$ENV{'GSDLHOME'}/collect/$collection/building/text/$collection.bdb") { 112 my $buildcol = &util::filename_cat ($bindir, "script", "buildcol.pl"); 113 system ("perl $buildcol $maxdocs $collection"); 114 if (-e &util::filename_cat ($buildingdir, "text", "$collection.ldb") || 115 -e &util::filename_cat ($buildingdir, "text", "$collection.bdb")) { 104 116 print STDERR "$collection collection built successfully\n\n"; 105 117 } else { … … 108 120 109 121 # replace old indexes with new ones 110 my $indexdir = "$ENV{'GSDLHOME'}/collect/$collection/index";111 122 if (&has_content ($indexdir)) { 112 123 print STDERR "removing old indexes\n"; 113 124 &util::rm_r ($indexdir); 114 rename ( "$ENV{'GSDLHOME'}/collect/$collection/building", $indexdir);125 rename ($buildingdir, $indexdir); 115 126 } 116 127 } … … 132 143 return 0; 133 144 } 134 135 __END__136 :endofperl
Note:
See TracChangeset
for help on using the changeset viewer.