Changeset 18491 for gsdl/trunk/bin/script/incremental-import.pl
- Timestamp:
- 2009-02-10T13:55:05+13:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/bin/script/incremental-import.pl
r18470 r18491 31 31 32 32 33 34 BEGIN { 35 die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'}; 36 die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'}; 37 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 38 } 39 40 33 41 use strict; 34 42 35 my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);43 use util; 36 44 37 45 38 my $import_cmd = "import.pl -incremental $quoted_argv"; 46 sub main 47 { 48 my ($argc,@argv) = @_; 39 49 40 my $import_status = system($import_cmd)/256; 50 if (($argc==0) || (($argc==1) && ($argv[0] =~ m/^--?h(elp)?$/))) { 51 my ($progname) = ($0 =~ m/^.*\/(.*?)$/); 41 52 42 if ($import_status != 0) { 43 print STDERR "Error: Failed to run: $import_cmd\n"; 44 print STDERR " $!\n" if ($! ne ""); 45 exit(-1); 53 54 print STDERR "\n"; 55 print STDERR "Usage: $progname [import.pl options] collection\n"; 56 print STDERR "\n"; 57 58 exit(-1); 59 } 60 61 62 my $collect = pop @argv; 63 64 my @filtered_argv = (); 65 66 my $collect_dir = undef; 67 my $archive_dir = undef; 68 69 while (my $arg = shift @argv) { 70 # No actual filtering happens at the moment (@filterd_argv == @argv) 71 # Useful to do it this way if we want incremental-import.pl 72 # to start accepting its own arguments that are different to import.pl 73 74 if ($arg eq "-collectdir") { 75 $collect_dir = shift @argv; 76 push(@filtered_argv,$arg,$collect_dir); 77 } 78 elsif ($arg eq "-archivedir") { 79 $archive_dir = shift @argv; 80 push(@filtered_argv,$arg,$archive_dir); 81 } 82 else { 83 push(@filtered_argv,$arg); 84 } 85 } 86 87 88 if (!defined $collect_dir) { 89 $collect_dir = &util::filename_cat($ENV{'GSDLHOME'},"collect",$collect); 90 } 91 if (!-d $collect_dir) { 92 print STDERR "Error: $collect_dir does not exist\n"; 93 exit(-1); 94 } 95 96 97 if (!defined $archive_dir) { 98 $archive_dir = &util::filename_cat($collect_dir,"archive_dir"); 99 } 100 101 my $db_ext = (&util::is_little_endian() ? ".ldb" : ".bdb"); 102 103 my $archiveinf_doc = &util::filename_cat($archive_dir,"archiveinf-doc$db_ext"); 104 105 my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv); 106 107 108 my $import_cmd = "import.pl"; 109 if (-e $archiveinf_doc) { 110 $import_cmd .= " -incremental"; 111 112 } 113 else { 114 print STDERR "$archiveinf_doc does not exist.\n"; 115 print STDERR "First time built. Switching to full import.pl.\n"; 116 $import_cmd .= " -removeold"; 117 } 118 119 $import_cmd .= " $quoted_argv"; 120 121 122 my $import_status = system($import_cmd)/256; 123 124 if ($import_status != 0) { 125 print STDERR "Error: Failed to run: $import_cmd\n"; 126 print STDERR " $!\n" if ($! ne ""); 127 exit(-1); 128 } 46 129 } 47 130 131 &main(scalar(@ARGV),@ARGV);
Note:
See TracChangeset
for help on using the changeset viewer.