Package: debian-policy Version: 2.5.0.0 Hi,
At several times during the last year or so, there have been proposals about making it possible to do a preinstall space check. This proposal includes a mechanism for doing just that. This requires that we include size information; either in the package .deb file or in ftp.debian.org/debian/indices/, or both, that contain the du -S information for each package. I think that putting the information into the Packages file is a bad idea -- especially for large packages. We need a line per directory and there is no reason to inflate the packages files for packages we ain't even updating. I personally tend to lean towards putting in a du file in each package; since we only need a line per dir in the package, this file should not be too big at all. Any sheme, which calculates whether there is enough space at hand, shall need information about each package; since we do not know mount schemes a priori [my /usr/lib/ is a separate partition from /usr]; we need information about each dir (since the a mount point is a dir). a compressed du -S format is about as compact as the information can get. So, I think, from what I remember about my info theory casses, this scheme is as optimal as we can reasonably expect. (embedding the information in packages files. downloaded over and over by apt, seems a horrible waste of bandwidth; at least, apt only downloades packages we are going to install). The following script, to be run by the likes of apt on the target system, looks at the du -S output for the package, and assigns each dir to the correct device_no -- VOILA, no matter how you have partitioned stuff, checkdu can tell exactly how much space is needed on each partion. There were some comments about patitions mounted via exotic methods may not be visible in /etc/mtab; in which case we can make the checkdu script additionally read /etc/apt/extra-partitions or something foe sites that use such partitions, and still work automagically for the most common case of simpler sites (which use local disks and NFS). I can even make checkdu warn if there is not enough space; all that is needed for this functionality is that the package maintainer provide the du -S data. This requires no retooling of dpkg, which I think is critical for any scheme ;-). This method seems to be simple enough, and I think meets our requirements. I think this is important enough to warrant that the data be collected; we can easily write dh_sizeinfo or whatever to create the properly formatted du -S file; manoj ---------------------------------------------------------------------- #! /usr/bin/perl -w package Check_DU; use strict; use diagnostics; use Carp; require 5.001; sub check_du { my %data; # find out the mount points of the devices open DF, "df |" or die "Could not run df:$!" ; while (<DF>) { m!/dev.*\s(/\S*)! or next; my $device_no = (stat($1))[0]; $data{$device_no}{'Name'} = $1; } close DF or die "Could not close pipe from df:$!" ; # read all the du -S files given on the command line while (<>) { my ($size, $dir_name) = split /\s+/, $_; my $device_no = (stat("/$dir_name"))[0]; $data{$device_no}{'Size'} += $size; } return \%data; } sub print_du { my %params = @_; croak("Need argument 'Size Data'") unless defined $params{'Size Data'}; for (sort keys %{$params{'Size Data'}}) { next unless $params{'Size Data'}{$_}{'Size'}; printf "%10d %s\n", $params{'Size Data'}{$_}{'Size'}, $params{'Size Data'}{$_}{'Name'}; } } sub test_du { my $data = &check_du(); &print_du('Size Data' => $data); } { # Execute simple test if run as a script package main; no strict; eval join('',<main::DATA>) || die "$@ $main::DATA" unless caller(); } 1; __END__ # Test the library &Check_DU::test_du(); 1; ---------------------------------------------------------------------- -- Visit[1] the beautiful Smoky Mountains! [1] visit, v.: Come for a week, spend too much money and pay lots of hidden taxes, then leave. We'll be happy to see your money again next year. You can save time by simply sending the money, if you're too busy. Manoj Srivastava <[EMAIL PROTECTED]> <http://www.debian.org/%7Esrivasta/> Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05 CC 2D 27 12 1D F5 E8 6E