2 # $Id: html-install.in,v 1.4 2002/11/17 22:45:16 cjwatson Exp $
3 # Takes 1 argument - directory tree to install into
4 # Tree _must_ be synch'd with one used by db2html to generate file
7 $config_path = '/etc/debbugs';
9 require("$config_path/config");
10 $ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
12 $dirtree= shift(@ARGV);
13 defined($dirtree) or die 'usage';
14 chdir $dirtree or die $!;
16 $filenamere= '[0-9a-z]{2}/[0-9a-z][-+_:,.0-9a-zA-Z]*';
18 opendir(D,".") or die " opendir: $!";
19 while ($dir=readdir(D)) {
20 next if $dir =~ m/^\.\.?$/;
24 opendir(E,"$dir") or die " opendir $dir: $!";
25 while ($_=readdir(E)) {
26 next if $_ =~ m/^\.\.?$/;
27 $remove{"$dir/$_"}= 1;
29 closedir(E) or die " closedir $dir: $!";
33 closedir(D) or die " closedir: $!";
38 print "end, removing\n";
39 for $k (keys %remove) { unlink($k) || $!==&ENOENT or die "$k: $!"; }
40 for $k (keys %rmdir) { rmdir($k) || $!==&ENOTEMPTY || $!==EEXIST or die "$k: $!"; }
42 } elsif (s/^progress //) {
43 y/-+:._!#=,0-9a-zA-Z //cd;
44 print " progress $_\n";
45 } elsif (m/^preserve ($filenamere)$/o) {
47 delete $remove{"$1.ref"};
48 print " preserve $1\n";
49 } elsif (m/^(file|diff) (\d+) (ref|def|non) ($filenamere)$/o) {
50 $filediff= $1; $linestodo= $2; $ii= $3; $file= $4;
51 print " $filediff $ii $file\n";
52 delete $remove{$file};
53 delete $remove{"$file.ref"} if $ii eq 'ref';
54 $file =~ m,^(..)/, or die $file;
55 mkdir($1,0777) || $!==EEXIST or die $!;
57 $tranfile.= '.ref' if $ii eq 'ref';
58 open(DT,"> recv.tmp") or die $!;
59 if ($filediff eq 'diff') { print DT "r $tranfile\n" or die $!; }
61 while ($linestodo--) {
63 if ($filediff eq 'diff') {
64 if ($indata) { $indata=0 if $incmd && m/^\.$/; }
65 elsif ($z =~ m/^[0-9,]+[ac]/) { $indata= 1; }
66 elsif ($z !~ m/^[0-9,]+[ds]/) { die "SECURITY $file >$z<"; }
68 print DT $z or die $!;
70 if ($filediff eq 'diff') { print DT "w new.tmp\nq\n" or die $!; }
72 ($z=<STDIN>) eq "that$filediff $file\n" or die die "not confirmed >$z<";
73 if ($filediff eq 'diff') {
74 $q= `ed -s <recv.tmp 2>&1`;
75 length($q) || $? and die "ed $q $?";
76 rename("new.tmp","$tranfile") or die "$tranfile $!";
77 unlink("recv.tmp") or die $!;
79 rename("recv.tmp","$tranfile") or die "$tranfile $!";
82 open(I,"$tranfile") or die $!;
83 open(O,"> ref.tmp") or die $!;
85 if (m/^\<\!\-\-ii (\d+)\-\-\>$/) {
86 defined($iival{$1}) or die "$tranfile $1";
87 print O $iival{$1} or die $!;
94 rename("ref.tmp","$file") or die $!;
95 } elsif ($ii eq 'def') {
96 open(I,"$file") or die $!;
97 undef $cdef; $ctext= '';
99 if (s/^\<\!\-\-iid (\d+)\-\-\>//) {
100 defined($cdef) and die $file;
103 } elsif (s/\<\!\-\-\/iid\-\-\>\n$//) {
104 defined($cdef) or die $file;
105 $iival{$cdef}= $ctext.$_."\n";
106 $ctext=''; undef $cdef;
108 $ctext.= $_ if defined($cdef);
112 } elsif (m/^noremoves$/) {