Changeset 1431 for trunk/gsdl/bin/script/build
- Timestamp:
- 2000-08-20T20:42:28+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/build
r1424 r1431 18 18 19 19 if (!parsargv::parse(\@ARGV, 20 'append', \$append, 20 21 'remove_archives', \$remove_archives, 21 22 'remove_import', \$remove_import, … … 50 51 my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin"); 51 52 52 my $ close_out = 0;53 my $use_out = 0; 53 54 my $outfile = $out; 54 55 if ($out !~ /^(STDERR|STDOUT)$/i) { 55 56 open (OUT, ">$out") || die "Couldn't open output file $out\n"; 56 57 $out = "OUT"; 57 $ close_out = 1;58 $use_out = 1; 58 59 } 59 60 $out->autoflush(1); … … 61 62 &main(); 62 63 63 close OUT if $ close_out;64 close OUT if $use_out; 64 65 65 66 sub print_usage { 66 67 print STDERR "\n usage: $0 [options] collection-name\n\n"; 67 68 print STDERR " options:\n"; 69 print STDERR " -append Add new files to existing collection\n"; 68 70 print STDERR " -remove_archives Remove archives directory after successfully\n"; 69 71 print STDERR " building the collection.\n"; … … 89 91 if (scalar (@download)) { 90 92 # remove any existing import data 91 &util::rm_r ($importdir) if -d $importdir; 93 if (&has_content ($importdir)) { 94 print $out "build: WARNING: removing contents of $importdir\n"; 95 &util::rm_r ($importdir); 96 } 92 97 93 98 foreach $download_dir (@download) { … … 107 112 # copy download_dir and all it contains to the import directory 108 113 my $download_cmd = "perl " . &util::filename_cat ($bindir, "script", "filecopy.pl"); 109 $download_cmd .= " -out \"$outfile\" \"" . $download_dir . "\" " . $collection; 114 $download_cmd .= " -out \"$outfile.download\"" if $use_out; 115 $download_cmd .= " \"" . $download_dir . "\" " . $collection; 110 116 system ($download_cmd); 117 # if using output directory append the file download output to it 118 &append_file ($out, "$outfile.download"); 111 119 } else { 112 120 print $out "WARNING: $download_dir does not exist\n"; … … 154 162 print $out "importing the $collection collection\n\n"; 155 163 156 my $import = &util::filename_cat ($bindir, "script", "import.pl"); 157 system ("perl $import -removeold $maxdocs -out \"$outfile\" $collection"); 164 my $import_cmd = "perl " . &util::filename_cat ($bindir, "script", "import.pl"); 165 $import_cmd .= " -out \"$outfile.import\"" if $use_out; 166 $import_cmd .= " -removeold" unless $append; 167 $import_cmd .= " $maxdocs $collection"; 168 system ($import_cmd); 169 # if using output directory append the import output to it 170 &append_file ($out, "$outfile.import"); 171 158 172 if (-e &util::filename_cat ($archivedir, "archives.inf")) { 159 173 print $out "$collection collection imported successfully\n\n"; … … 171 185 print $out "building the $collection collection\n\n"; 172 186 173 my $buildcol = &util::filename_cat ($bindir, "script", "buildcol.pl"); 174 system ("perl $buildcol $maxdocs -out \"$outfile\" $collection"); 187 my $build_cmd = "perl " . &util::filename_cat ($bindir, "script", "buildcol.pl"); 188 $build_cmd .= " -out \"$outfile.build\"" if $use_out; 189 $build_cmd .= " $maxdocs $collection"; 190 system ($build_cmd); 191 # if using output directory append the buildcol output to it 192 &append_file ($out, "$outfile.build"); 193 175 194 if (-e &util::filename_cat ($buildingdir, "text", "$collection.ldb") || 176 195 -e &util::filename_cat ($buildingdir, "text", "$collection.bdb")) { … … 209 228 return 0; 210 229 } 230 231 sub append_file { 232 my ($handle, $file) = @_; 233 234 open (FILE, $file) || return; 235 undef $/; 236 print $handle <FILE>; 237 $/ = "\n"; 238 close FILE; 239 &util::rm ($file); 240 }
Note:
See TracChangeset
for help on using the changeset viewer.