/usr/lib/debbugs/html-install is in debbugs 2.4.1.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | #!/usr/bin/perl
# $Id: html-install.in,v 1.4 2002/11/17 22:45:16 cjwatson Exp $
# Takes 1 argument - directory tree to install into
# Tree _must_ be synch'd with one used by db2html to generate file
use POSIX;
$config_path = '/etc/debbugs';
require("$config_path/config");
$ENV{'PATH'} = $lib_path.':'.$ENV{'PATH'};
$dirtree= shift(@ARGV);
defined($dirtree) or die 'usage';
chdir $dirtree or die $!;
$filenamere= '[0-9a-z]{2}/[0-9a-z][-+_:,.0-9a-zA-Z]*';
opendir(D,".") or die " opendir: $!";
while ($dir=readdir(D)) {
next if $dir =~ m/^\.\.?$/;
if (-f $dir) {
$remove{$dir}= 1;
} else {
opendir(E,"$dir") or die " opendir $dir: $!";
while ($_=readdir(E)) {
next if $_ =~ m/^\.\.?$/;
$remove{"$dir/$_"}= 1;
}
closedir(E) or die " closedir $dir: $!";
$rmdir{$dir}= 1;
}
}
closedir(D) or die " closedir: $!";
while(<>) {
chomp;
if (m/^end$/) {
print "end, removing\n";
for $k (keys %remove) { unlink($k) || $!==&ENOENT or die "$k: $!"; }
for $k (keys %rmdir) { rmdir($k) || $!==&ENOTEMPTY || $!==EEXIST or die "$k: $!"; }
exit 0;
} elsif (s/^progress //) {
y/-+:._!#=,0-9a-zA-Z //cd;
print " progress $_\n";
} elsif (m/^preserve ($filenamere)$/o) {
delete $remove{$1};
delete $remove{"$1.ref"};
print " preserve $1\n";
} elsif (m/^(file|diff) (\d+) (ref|def|non) ($filenamere)$/o) {
$filediff= $1; $linestodo= $2; $ii= $3; $file= $4;
print " $filediff $ii $file\n";
delete $remove{$file};
delete $remove{"$file.ref"} if $ii eq 'ref';
$file =~ m,^(..)/, or die $file;
mkdir($1,0777) || $!==EEXIST or die $!;
$tranfile= $file;
$tranfile.= '.ref' if $ii eq 'ref';
open(DT,"> recv.tmp") or die $!;
if ($filediff eq 'diff') { print DT "r $tranfile\n" or die $!; }
$indata= 0;
while ($linestodo--) {
$z=<STDIN>;
if ($filediff eq 'diff') {
if ($indata) { $indata=0 if $incmd && m/^\.$/; }
elsif ($z =~ m/^[0-9,]+[ac]/) { $indata= 1; }
elsif ($z !~ m/^[0-9,]+[ds]/) { die "SECURITY $file >$z<"; }
}
print DT $z or die $!;
}
if ($filediff eq 'diff') { print DT "w new.tmp\nq\n" or die $!; }
close(DT) or die $!;
($z=<STDIN>) eq "that$filediff $file\n" or die die "not confirmed >$z<";
if ($filediff eq 'diff') {
$q= `ed -s <recv.tmp 2>&1`;
length($q) || $? and die "ed $q $?";
rename("new.tmp","$tranfile") or die "$tranfile $!";
unlink("recv.tmp") or die $!;
} else {
rename("recv.tmp","$tranfile") or die "$tranfile $!";
}
if ($ii eq 'ref') {
open(I,"$tranfile") or die $!;
open(O,"> ref.tmp") or die $!;
while (<I>) {
if (m/^\<\!\-\-ii (\d+)\-\-\>$/) {
defined($iival{$1}) or die "$tranfile $1";
print O $iival{$1} or die $!;
} else {
print O or die $!;
}
}
close(I) or die $!;
close(O) or die $!;
rename("ref.tmp","$file") or die $!;
} elsif ($ii eq 'def') {
open(I,"$file") or die $!;
undef $cdef; $ctext= '';
while (<I>) {
if (s/^\<\!\-\-iid (\d+)\-\-\>//) {
defined($cdef) and die $file;
$cdef= $1;
$ctext= $_;
} elsif (s/\<\!\-\-\/iid\-\-\>\n$//) {
defined($cdef) or die $file;
$iival{$cdef}= $ctext.$_."\n";
$ctext=''; undef $cdef;
} else {
$ctext.= $_ if defined($cdef);
}
}
}
} elsif (m/^noremoves$/) {
print "noremoves\n";
exit 0;
} else {
die " huh ? $_";
}
}
die "eof $!";
|