Changeset 6054
- Timestamp:
- 2003-12-01T11:40:59+13:00 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/exportcol.pl
r5920 r6054 33 33 use util; 34 34 use parsargv; 35 36 sub print_usage { 37 print STDERR "\n"; 38 print STDERR "exportcol.pl: Exports a collection for writing to CD-ROM.\n\n"; 39 print STDERR " usage: $0 [options] collection-name\n\n"; 40 print STDERR " -out Filename or handle to print debug info to.\n"; 41 print STDERR " The default is STDERR\n"; 42 print STDERR " -cdname The name of the cd - this is what will appear in the start menu once the cd is installed.\n"; 43 print STDERR " The default is 'Greenstone Collections'.\n\n"; 44 } 35 use printusage; 36 37 my $arguments = 38 [ { 'name' => "out", 39 'desc' => "{exportcol.out}", 40 'type' => "string", 41 'deft' => "STDERR", 42 'reqd' => "no" }, 43 { 'name' => "cdname", 44 'desc' => "{exportcol.cdname}", 45 'type' => "string", 46 'deft' => "Greenstone Collections", 47 'reqd' => "no" }, ]; 48 49 my $options = { 'name' => "exportcol.pl", 50 'desc' => "{exportcol.desc}", 51 'args' => $arguments }; 52 53 sub print_xml_usage 54 { 55 local $language = shift(@_); 56 57 &PrintUsage::print_xml_header(); 58 59 print STDERR "<Info>\n"; 60 print STDERR " <Name>$options->{'name'}</Name>\n"; 61 print STDERR " <Desc>" . &lookup_string($options->{'desc'}) . "</Desc>\n"; 62 print STDERR " <Arguments>\n"; 63 if (defined($options->{'args'})) { 64 &PrintUsage::print_options_xml($language, $options->{'args'}); 65 } 66 print STDERR " </Arguments>\n"; 67 print STDERR "</Info>\n"; 68 } 69 70 sub print_txt_usage 71 { 72 local $language = shift(@_); 73 74 local $programname = $options->{'name'}; 75 local $programargs = $options->{'args'}; 76 77 # Find the length of the longest option string 78 local $descoffset = 0; 79 if (defined($programargs)) { 80 $descoffset = &PrintUsage::find_longest_option_string($programargs); 81 } 82 83 # Produce the usage information using the data structure above 84 print STDERR " " . &lookup_string("{common.usage}") . ": $programname"; 85 print STDERR " " . &lookup_string("{exportcol.params}") . "\n\n"; 86 87 # Display the program options, if there are some 88 if (defined($programargs)) { 89 # Calculate the column offset of the option descriptions 90 local $optiondescoffset = $descoffset + 2; # 2 spaces between options & descriptions 91 92 print STDERR " " . &lookup_string("{common.options}") . ":\n"; 93 94 # Display the program options 95 &PrintUsage::print_options_txt($language, $programargs, $optiondescoffset); 96 } 97 } 98 99 100 sub lookup_string 101 { 102 return &gsprintf::lookup_string($language, shift(@_)); 103 } 104 105 sub gsprintf 106 { 107 return &gsprintf::gsprintf(@_); 108 } 109 110 #sub print_usage { 111 # print STDERR "\n"; 112 # print STDERR "exportcol.pl: Exports collection for writing to CD-ROM.\n\n"; 113 # print STDERR " usage: $0 [options] collection-name\n\n"; 114 # print STDERR " -out Filename or handle to print debug info to.\n"; 115 # print STDERR " The default is STDERR\n"; 116 # print STDERR " -cdname The name of the cd - this is what will appear in the start menu once the cd is installed.\n"; 117 # print STDERR " The default is 'Greenstone Collections'.\n\n"; 118 #} 45 119 46 120 &main(); … … 48 122 sub main { 49 123 my ($out, $cdname); 124 125 my $xml = 0; 126 50 127 if (!parsargv::parse(\@ARGV, 51 128 'out/.*/STDERR', \$out, 52 'cdname/.*/', \$cdname)) { 129 'cdname/.*/', \$cdname, 130 q^xml^, \$xml)) { 53 131 54 &print_usage(); 55 die "\n"; 56 } 132 &print_txt_usage(); 133 die "\n"; 134 } 135 136 if ($xml) { 137 &print_xml_usage($language); 138 die "\n"; 139 } 140 57 141 my $dirname=""; 58 142 if ($cdname eq "") { … … 68 152 69 153 if (not @coll_list) { # empty list 70 &print_ usage();154 &print_txt_usage(); 71 155 exit(1); 72 156 } … … 74 158 my $close_out = 0; 75 159 if ($out !~ /^(STDERR|STDOUT)$/i) { 76 open (OUT, ">$out") || die "Couldn't open output file $out\n"; 160 open (OUT, ">$out") || 161 die &lookup_string("{common.cannot_open_output_file}") . " $out\n"; 77 162 $out = OUT; 78 163 $close_out = 1; … … 84 169 my $colldir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $c); 85 170 if (! -d $colldir) { 86 print $out "Invalid collection $c, collection not found at $colldir, ignoring\n";171 &gsprintf($out, "{exportcol.coll_not_found}\n", $c, $colldir); 87 172 next; 88 173 } … … 90 175 my $coletcdir = &util::filename_cat ($colldir, "etc"); 91 176 if ((!-d $colindexdir) || (!-d $coletcdir)) { 92 print $out "Invalid collection $c, one of the following directories does not exist\n\n";177 &gsprintf($out, "{exportcol.coll_dirs_not_found}\n", $c); 93 178 print $out " $colindexdir\n"; 94 179 print $out " $coletcdir\n"; … … 102 187 if (not @valid_coll_list) { 103 188 # no valid colls left 104 print $out "exportcol.pl failed: no valid collections specified to export\n"; 189 &gsprintf($out, "{exportcol.fail}"); 190 &gsprintf($out, "{exportcol.no_valid_colls}\n"); 105 191 die "\n"; 106 192 } … … 110 196 &util::mk_all_dir ($topdir); 111 197 if (!-d $topdir) { 112 print $out "exportcol.pl failed: couldn't create directory $topdir\n"; 198 &gsprintf($out, "{exportcol.fail}"); 199 &gsprintf($out, "{exportcol.couldnt_create_dir}\n", $topdir); 113 200 die "\n"; 114 201 } … … 128 215 my $installcfg = &util::filename_cat ($topdir, "install.cfg"); 129 216 if (!open (INSTALLCFG, ">$installcfg")) { 130 print $out "exportcol.pl failed: Could not create $installcfg\n"; 217 &gsprintf($out, "{exportcol.fail}"); 218 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $installcfg ); 131 219 die "\n"; 132 220 } … … 142 230 my $manifestcfg = &util::filename_cat ($topdir, "manifest.cfg"); 143 231 if (!open (MANIFESTCFG, ">$manifestcfg")) { 144 print $out "exportcol.pl failed: Could not create $manifestcfg\n"; 232 &gsprintf($out, "{exportcol.fail}"); 233 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $manifestcfg ); 145 234 die "\n"; 146 235 } … … 162 251 my $autoruninf = &util::filename_cat ($topdir, "Autorun.inf"); 163 252 if (!open (AUTORUNINF, ">$autoruninf")) { 164 print $out "exportcol.pl failed: Could not create $autoruninf\n"; 253 &gsprintf($out, "{exportcol.fail}"); 254 &gsprintf($out, "{exportcol.couldnt_create_file}\n", $autoruninf ); 165 255 die "\n"; 166 256 } … … 187 277 (!-e $serverexe) || (!-e $gssetupexe) || (!-e $setupexe) || (!-d $net32dir) || 188 278 (!-d $net16dir) || (!-d $netscapedir) || (!-d $win32sdir) || (!-e $phindjar)) { 189 print $out "exportcol.pl failed: One or more of the following necessary\n";190 print $out "files and directories does not exist\n\n";279 &gsprintf($out, "{exportcol.fail}"); 280 &gsprintf($out, "{exportcol.non_exist_files}\n"); 191 281 print $out " $imagesdir\n"; 192 282 print $out " $macrosdir\n"; … … 261 351 &util::mv("$collectcfg.tmp", $collectcfg); 262 352 } 263 print $out "exportcol.pl succeeded: The exported collections are in $topdir\n"; 353 &gsprintf($out, "{exportcol.success}"); 354 &gsprintf($out, "{exportcol.output_dir}\n", $topdir); 264 355 close OUT if $close_out; 265 356 }
Note:
See TracChangeset
for help on using the changeset viewer.