Changeset 1454 for trunk/gsdl/bin/script/build
- Timestamp:
- 2000-08-27T23:04:47+12:00 (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/build
r1452 r1454 4 4 # windows (build.bat is in bin\windows) 5 5 6 package build; 7 6 8 use FileHandle; 9 use File::Copy; 7 10 8 11 BEGIN { … … 20 23 use parsargv; 21 24 use util; 22 23 if (!parsargv::parse(\@ARGV, 24 'append', \$append, 25 'remove_archives', \$remove_archives, 26 'remove_import', \$remove_import, 27 'buildtype/^(build|import)$/import', \$buildtype, 28 'maxdocs/^\-?\d+/-1', \$maxdocs, 29 'download/.+', \@download, 30 'out/.*/STDERR', \$out)) { 31 32 &print_usage(); 33 die "\n"; 34 } 25 use cfgread; 26 27 &parse_args (\@ARGV); 35 28 36 29 my ($collection) = @ARGV; … … 42 35 } 43 36 37 if ($optionfile =~ /\w/) { 38 open (OPTIONS, $optionfile) || die "Couldn't open $optionfile\n"; 39 my $line = []; 40 my $options = []; 41 while (defined ($line = &cfgread::read_cfg_line ('build::OPTIONS'))) { 42 push (@$options, @$line); 43 } 44 close OPTIONS; 45 &parse_args ($options); 46 } 47 44 48 if ($maxdocs == -1) { 45 49 $maxdocs = ""; … … 48 52 } 49 53 50 my $collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $collection); 51 my $importdir = &util::filename_cat ($collectdir, "import"); 52 my $archivedir = &util::filename_cat ($collectdir, "archives"); 53 my $buildingdir = &util::filename_cat ($collectdir, "building"); 54 my $indexdir = &util::filename_cat ($collectdir, "index"); 54 my $cdir = $collectdir; 55 $cdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect") unless $collectdir =~ /\w/; 56 my $importdir = &util::filename_cat ($cdir, $collection, "import"); 57 my $archivedir = &util::filename_cat ($cdir, $collection, "archives"); 58 my $buildingdir = &util::filename_cat ($cdir, $collection, "building"); 59 my $indexdir = &util::filename_cat ($cdir, $collection, "index"); 55 60 my $bindir = &util::filename_cat ($ENV{'GSDLHOME'}, "bin"); 56 61 … … 68 73 $out->autoflush(1); 69 74 75 # delete any .kill file left laying around from a previously aborted build 76 if (-e &util::filename_cat ($cdir, $collection, ".kill")) { 77 &util::rm (&util::filename_cat ($cdir, $collection, ".kill")); 78 } 79 70 80 &main(); 71 81 … … 75 85 print STDERR "\n usage: $0 [options] collection-name\n\n"; 76 86 print STDERR " options:\n"; 87 print STDERR " -optionfile file Get options from file, useful on systems where\n"; 88 print STDERR " long command lines may cause problems\n"; 77 89 print STDERR " -append Add new files to existing collection\n"; 78 90 print STDERR " -remove_archives Remove archives directory after successfully\n"; … … 90 102 print STDERR " deleted to make way for the downloaded data if\n"; 91 103 print STDERR " a -download option is supplied\n"; 104 print STDERR " -collectdir directory Collection directory (defaults to " . 105 &util::filename_cat ($ENV{'GSDLHOME'}, "collect") . ")\n"; 106 print STDERR " -dontinstall Only applicable if -collectdir is set to something\n"; 107 print STDERR " other than the default. -dontinstall will suppress the\n"; 108 print STDERR " default behaviour which is to install the collection to\n"; 109 print STDERR " the gsdl/collect directory once it has been built.\n"; 110 print STDERR " -save_archives Create a copy of the existing archives directory called\n"; 111 print STDERR " archives.org\n"; 92 112 print STDERR " -out Filename or handle to print output status to.\n"; 93 113 print STDERR " The default is STDERR\n\n"; … … 95 115 96 116 sub main { 97 117 118 if ($save_archives && -d $archivedir) { 119 print $out "caching original archives to ${archivedir}.org\n"; 120 &util::cp_r ($archivedir, "${archivedir}.org"); 121 } 122 98 123 # do the download thing if we have any -download options 99 124 if (scalar (@download)) { … … 103 128 &util::rm_r ($importdir); 104 129 } 105 130 106 131 foreach $download_dir (@download) { 107 132 … … 120 145 # copy download_dir and all it contains to the import directory 121 146 my $download_cmd = "perl " . &util::filename_cat ($bindir, "script", "filecopy.pl"); 147 $download_cmd .= " -collectdir \"$collectdir\"" if $collectdir =~ /\w/; 122 148 $download_cmd .= " -out \"$outfile.download\"" if $use_out; 123 149 $download_cmd .= " \"" . $download_dir . "\" " . $collection; … … 165 191 } 166 192 } 193 194 if ($collectdir ne "" && !$dontinstall) { 195 my $install_collectdir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect"); 196 if (!&util::filenames_equal ($collectdir, $install_collectdir)) { 197 198 # install collection to gsdl/collect 199 print $out "installing the $collection collection\n"; 200 my $newdir = &util::filename_cat ($install_collectdir, $collection); 201 my $olddir = &util::filename_cat ($collectdir, $collection); 202 if (-d $newdir) { 203 print $out "build: Could not install collection as $newdir\n"; 204 print $out " already exists. Collection will remain at\n"; 205 print $out " $olddir\n"; 206 &final_out (4) if $use_out; 207 die "\n"; 208 } 209 if (!&File::Copy::move ($olddir, $newdir)) { 210 print $out "build: Failed to install collection to $newdir\n"; 211 print $out " Collection will remain at $olddir\n"; 212 &final_out (5) if $use_out; 213 die "\n"; 214 } 215 } 216 } 217 167 218 &final_out (0) if $use_out; 168 219 } … … 175 226 $import_cmd .= " -out \"$outfile.import\"" if $use_out; 176 227 $import_cmd .= " -removeold" unless $append; 228 $import_cmd .= " -collectdir \"$collectdir\"" if $collectdir =~ /\w/; 177 229 $import_cmd .= " $maxdocs $collection"; 178 230 system ($import_cmd); … … 188 240 } else { 189 241 &final_out (2) if $use_out; 190 die "\nimport.pl failed\n"; 242 print $out "\nimport.pl failed\n"; 243 die "\n"; 191 244 } 192 245 } … … 198 251 my $build_cmd = "perl " . &util::filename_cat ($bindir, "script", "buildcol.pl"); 199 252 $build_cmd .= " -out \"$outfile.build\"" if $use_out; 253 $build_cmd .= " -collectdir \"$collectdir\"" if $collectdir =~ /\w/; 200 254 $build_cmd .= " $maxdocs $collection"; 201 255 system ($build_cmd); … … 211 265 } 212 266 } else { 213 &final_out (2) if $use_out; 214 die "\nbuildcol.pl failed\n"; 267 &final_out (3) if $use_out; 268 print $out "\nbuildcol.pl failed\n"; 269 die "\n"; 215 270 } 216 271 … … 221 276 } 222 277 rmdir ($indexdir) if -d $indexdir; 223 rename ($buildingdir, $indexdir); 278 &File::Copy::move ($buildingdir, $indexdir); 279 280 # remove the cached arhives 281 if ($save_archives) -d "${archivedir}.org") { 282 &util::rm_r ("${archivedir}.org"); 283 } 224 284 } 225 285 … … 263 323 } 264 324 } 325 326 sub parse_args { 327 my ($argref) = @_; 328 329 if (!parsargv::parse($argref, 330 'optionfile/.*/', \$optionfile, 331 'append', \$append, 332 'remove_archives', \$remove_archives, 333 'remove_import', \$remove_import, 334 'buildtype/^(build|import)$/import', \$buildtype, 335 'maxdocs/^\-?\d+/-1', \$maxdocs, 336 'download/.+', \@download, 337 'collectdir/.*/', \$collectdir, 338 'dontinstall', \$dontinstall, 339 'save_archives', \$save_archives, 340 'out/.*/STDERR', \$out)) { 341 342 &print_usage(); 343 die "\n"; 344 } 345 }
Note:
See TracChangeset
for help on using the changeset viewer.