Re: Gzipping man files
>Mostly I'm not sure it's a sensible optimization. All my machines
>are truly multitasking, so spending more CPU time on one thing will
>definitely slow down other things. And disk space is *so* cheap
>these days that it's not worth it for a directory tree that is only a
>few megs large.
>
>At worst, I would like this to be user-configurable somehow, because
>I do *not* want gzipped manpages.
I'm tempted to agree with this, myself. Having the option of using
compressed man pages would be a good thing, but IMHO man page
formatting is already slow enough as it is. OTOH, I've currently got
lots of free disc space, so perhaps I would say that.
A script not a million miles from the one below (which hasn't been
tested AT ALL) should do something useful; it's more complex than just
compressing all the man pages as AIUI you have to keep dpkg au fait
with what's going on. One could run this script after a major
install, or out of cron.
Ian, do you have any comments about this? Such a script would be best
located in the dpkg package so it can best remain in step with the
structure of dpkg's databases.
#!/usr/bin/perl
$dir = "/var/lib/dpkg/info";
(opendir(DIR, $dir)
&& (@listfiles = readdir DIR)
&& (closedir DIR)) || die "$0: $dir: $!\n";
while $file (@listfiles)
{
next unless $page =~ /\.list$/;
(open(FILES, "<$dir/$listfile)
&& (@pkgfiles = <FILES>)
&& close FILES) || die "$0: $dir/$listfile: $!\n";
$changed = 0;
$s = 0;
for $page (@pkgfiles)
{
next unless $page =~ /^\/usr\/man\/man[^\/]*\//;
next if $page =~ /^\.(gz|Z|z)$/;
next unless -f $page;
last if (($s = system("gzip","-9f",$page)));
$page .= ".gz";
$changed = 1;
}
if($changed)
{
(open(OUT, ">$dir/$listfile.$$")
&& (print OUT @pkgfiles)
&& (close OUT)) || die "$0: $dir/$listfile.$$: $!\n";
(rename "$dir/$listfile.$$", "$dir/$listfile")
|| die "$0: "$dir/$listfile: $!\n"
}
die "$0: gzip returned status $s\n" if($s);
}
--
Richard Kettlewell
http://www.elmail.co.uk/staff/richard/ richard@elmail.co.uk
Reply to: