ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.35 by root, Sun Jun 3 15:32:51 2007 UTC vs.
Revision 1.43 by root, Mon Jul 23 23:38:18 2007 UTC

6my $exec_prefix = "@exec_prefix@"; 6my $exec_prefix = "@exec_prefix@";
7my $datarootdir = "@datarootdir@"; 7my $datarootdir = "@datarootdir@";
8my $DATADIR = "@datadir@/@PACKAGE@"; 8my $DATADIR = "@datadir@/@PACKAGE@";
9 9
10my $CONVERT = "@CONVERT@"; 10my $CONVERT = "@CONVERT@";
11my $IDENTIFY = "@IDENTIFY@"; 11#my $IDENTIFY = "@IDENTIFY@";
12my $OPTIPNG = "@OPTIPNG@"; 12my $OPTIPNG = "@OPTIPNG@";
13my $RSYNC = "@RSYNC@"; 13my $RSYNC = "@RSYNC@";
14my $PNGNQ = "@PNGNQ@"; 14my $PNGNQ = "@PNGNQ@";
15 15
16use Getopt::Long; 16use Getopt::Long;
21use Crossfire; 21use Crossfire;
22use Coro; 22use Coro;
23use Coro::AIO; 23use Coro::AIO;
24use POSIX (); 24use POSIX ();
25use Digest::MD5; 25use Digest::MD5;
26use Carp;
26use Coro::Storable; $Storable::canonical = 1; 27use Coro::Storable; $Storable::canonical = 1;
28
29$SIG{QUIT} = sub { Carp::cluck "QUIT" };
27 30
28sub usage { 31sub usage {
29 warn <<EOF; 32 warn <<EOF;
30Usage: cfutil [-v] [-q] [--force] [--cache] 33Usage: cfutil [-v] [-q] [--force] [--cache]
31 [--install-arch path] 34 [--install-arch path]
92 if (!-f "$path/regions") { 95 if (!-f "$path/regions") {
93 warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; 96 warn "'$path' does not look like a maps directory ('regions' file is missing).\n";
94 exit 1 unless $FORCE; 97 exit 1 unless $FORCE;
95 } 98 }
96 99
97 system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" 100 system $RSYNC, "-a", "--chmod=u=rwX,go=rX", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded"
98 and die "map installation failed.\n"; 101 and die "map installation failed.\n";
99 102
100 print "maps installed successfully.\n"; 103 print "maps installed successfully.\n";
101} 104}
102 105
103{ 106{
104 our %ANIMINFO; 107 our %ANIMINFO;
105 our %FACEINFO; 108 our %FACEINFO;
109 our %RESOURCE;
106 our @ARC; 110 our @ARC;
107 our %ARC; 111 our %ARC;
108 our $TRS; 112 our $TRS;
109 our $NFILE; 113 our $NFILE;
114 our $PATH;
110 115
111 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 116 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
112 117
113 our (@png, @trs, @arc); # files we are interested in 118 our (@png, @trs, @arc, @res); # files we are interested in
114 119
115 sub commit_png($$$) { 120 sub commit_png($$$) {
116 my ($name, $data, $T) = @_; 121 my ($name, $data, $T) = @_;
117 122
118 $FACEINFO{$name}{"data$T"} = $data; 123 $FACEINFO{$name}{"data$T"} = $data;
383 388
384 $TRS .= $trs; 389 $TRS .= $trs;
385 } 390 }
386 } 391 }
387 392
393 sub process_res {
394 while (@res) {
395 my ($dir, $file) = @{pop @res};
396
397 my $data;
398 aio_load "$dir/$file", $data;
399
400 my $copyright;
401 aio_load "$dir/copyright", $copyright;
402
403 $file =~ s/\.res$//;
404 $file =~ /\.([^.]+)$/
405 or next;
406
407 my $type = $1;
408
409 substr $dir, 0, 1 + length $PATH, "";
410
411 $RESOURCE{"$dir/$file"} = {
412 type => $1,
413 copyright => $copyright,
414 data => $data,
415 chksum => Digest::MD5::md5 $data,
416 };
417 }
418 }
419
388 sub find_files; 420 sub find_files;
389 sub find_files { 421 sub find_files {
390 my ($path) = @_; 422 my ($path) = @_;
391 423
392 IO::AIO::aioreq_pri 4; 424 IO::AIO::aioreq_pri 4;
394 my ($dirs, $nondirs) = @_; 426 my ($dirs, $nondirs) = @_;
395 427
396 find_files "$path/$_" 428 find_files "$path/$_"
397 for grep $_ !~ /^(?:CVS|dev)$/, @$dirs; 429 for grep $_ !~ /^(?:CVS|dev)$/, @$dirs;
398 430
431 my $dir = $path;
432 substr $dir, 0, 1 + length $PATH, "";
433
399 for my $file (@$nondirs) { 434 for my $file (@$nondirs) {
435 if ($file =~ /\.(ogg|jpg|res)$/ || $dir =~ /^res(?:\/|$)/) {
436 push @res, [$path, $file];
400 if ($file =~ /\.png$/) { 437 } elsif ($file =~ /\.png$/) {
401 push @png, ["$path/$file", 0]; 438 push @png, ["$path/$file", 0];
402 } elsif ($file =~ /\.trs$/) { 439 } elsif ($file =~ /\.trs$/) {
403 push @trs, [$path, $file]; 440 push @trs, [$path, $file];
404 } elsif ($file =~ /\.arc$/) { 441 } elsif ($file =~ /\.arc$/) {
405 push @arc, [$path, $file]; 442 push @arc, [$path, $file];
410 }; 447 };
411 } 448 }
412 449
413 sub inst_arch($) { 450 sub inst_arch($) {
414 my (undef, $path) = @_; 451 my (undef, $path) = @_;
452
453 $PATH = $path;
415 454
416 print "\n", 455 print "\n",
417 "Installing '$path' to '$DATADIR'\n", 456 "Installing '$path' to '$DATADIR'\n",
418 "\n", 457 "\n",
419 "This can take a long time if you run this\n", 458 "This can take a long time if you run this\n",
434 $_->join for ( 473 $_->join for (
435 # four png crunchers work fine for my 2x smp machine 474 # four png crunchers work fine for my 2x smp machine
436 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), 475 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png),
437 (async \&process_trs), (async \&process_trs), 476 (async \&process_trs), (async \&process_trs),
438 (async \&process_arc), (async \&process_arc), 477 (async \&process_arc), (async \&process_arc),
478 (async \&process_res), (async \&process_res),
439 ); 479 );
440 480
441 { 481 {
442 # remove path prefix from editor_folder 482 # remove path prefix from editor_folder
443 substr $_->{editor_folder}, 0, 1 + length $path, "" 483 substr $_->{editor_folder}, 0, 1 + length $path, ""
511 551
512 print $fh freeze { 552 print $fh freeze {
513 version => 2, 553 version => 2,
514 faceinfo => \%FACEINFO, 554 faceinfo => \%FACEINFO,
515 animinfo => \%ANIMINFO, 555 animinfo => \%ANIMINFO,
556 resource => \%RESOURCE,
516 }; 557 };
517 } 558 }
518 559
519 for (qw(archetypes facedata treasures)) { 560 for (qw(archetypes facedata treasures)) {
520 chmod 0644, "$DATADIR/$_~"; 561 chmod 0644, "$DATADIR/$_~";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines