[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please don't remove size info from pkgs.



Hi,
>>"Jim" == Jim  <jim@laney.edu> writes:

Jim> As intimated to below, I (who has no official vote :) think that
Jim> debian packages should have enough information in them to allow
Jim> the determination of how much disk space would be used by
Jim> installing, or freed by removing, said package.

	Yes. The issue is the time required to gather that
 information. For larger packages like xbooks, that may well take over
 a minute on slow machines, which is unacceptable if a large number of
 packages are to be ugdated.

Jim> If this were the case, then deity, dselect or something else
Jim> could also show the space left on each mounted partition, to
Jim> better allow a debian user to definitively determine whether s/he
Jim> had the space required to install any given set of packages at a
Jim> glance.

Jim> In my opinion, this would be _very_ helpful.

	If packages were to include a du -S output (unlike the du -s
output included by some helper packages before), this script, a
modification of Kai' script, could be used to gather the data. This
has yet to be discussed and passed into policy.

	patience.

	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;



-- 
 FIELD TESTED: manufacturer lacks test equipment.
Manoj Srivastava  <srivasta@acm.org> <http://www.datasync.com/%7Esrivasta/>
Key C7261095 fingerprint = CB D9 F4 12 68 07 E4 05  CC 2D 27 12 1D F5 E8 6E


Reply to: