Re: Finding left-over libraries

1999-12-11 Thread Keith Harbaugh
On Tue, 1999-12-07 at 23:13:32 +0100, peter karlsson wrote:
> Is there any way in Debian to find out what packages no other packages
> depend on?
> 
> When I install a couple of packages, all the libraries they depend on are
> installed as well, which is quite nice, but the reverse doesn't hold - when
> I remove packages, unnecessary libraries are not removed. Because of this, I
> would like to get a list of packages that no packages depend on (restricted,
> for instance, to packages starting with lib).

You might want to check out the package pkg-order,
in particular, its programs pkg-deptree and pkg-revdeps.

Keith


Re: Finding left-over libraries

1999-12-10 Thread Paul J. Keenan
Matthias Hertel wrote:

> Well, its not clean, and it doesn't even work correctly (it doesn't
> correctly handle |-dependecies), and there are probably other bugs,
> but here is a perl script that I threw together when I was new to
> Debian (and perl) that does what you want: It lists all packages
> nothing depends on and that are not essential, and also says whether
> they are suggested or recommended by other packages. It occasionally
> gives false positives (I think the missing |-handling is to be
> blamed), and I also found a case where it gives false negatives (some
> gnome packages have circular dependencies, I think).
> 
> I wonder if all this could be done much more cleanly with libapt
> (never looked into that).
> 
> Anyway, if anybody wants to improve on this, you're welcome. Perhaps
> post it back to the list.


Hi Matthias,

Thanks for the script - I was thinking about this issue myself,
but you've saved me the trouble.

I've enclosed an updated version which handles the "or" situation.
It now splits the whole line on whitespace and then rejects any
tokens which start with an open parenthesis or the or "or" symbol,
or end with a closing parenthesis.

If you call the program with option "-l", it'll now show all packages
if no others depend on it (as before), but now they must also contain
the string "lib" in the package name.  Crude form of filtering, but
effective.

I also caught the numeric vs string compare near the top; -w is your
friend ...

Thanks again,
Paul


#!/usr/bin/perl -w

use English;

open PKGLIST, "dpkg --get-selections |";
while () {
  ($pkg, $sel) = split;
  push @pkglist, $pkg if $sel eq "install";
}

open STATUS, "dpkg --status @pkglist |";
$INPUT_RECORD_SEPARATOR = "";
while () {
  ($package) = /^Package: (.*)$/m;
  ($essential) = /^Essential: (.*)$/m;
  ($priority) = /^Priority: (.*)$/m;
  ($size) = /^Installed-Size: (.*)$/m;
  unless ($essential) {
push @packages, $package;
$priorities{$package} = $priority.", ".$size."k";
  }

  do {
foreach $p (grep {!(/^[|(]/|/\)$/)} split ' ', $foo) {
  push @{$pre_depends{$p}}, $package; 
}
  } if ($foo) = /^Pre-Depends: (.*)$/m;

  do {
foreach $p (grep {!(/^[|(]/|/\)$/)} split ' ', $foo) {
  { push @{$depends{$p}}, $package; }
}
  } if ($foo) = /^Depends: (.*)$/m;

  do {
foreach $p (grep {!(/^[|(]/|/\)$/)} split ' ', $foo) {
  { push @{$provides{$p}}, $package; }
}
  } if ($foo) = /^Provides: (.*)$/m;

  do {
foreach $p (grep {!(/^[|(]/|/\)$/)} split ' ', $foo) {
  { push @{$suggests{$p}}, $package; }
}
  } if ($foo) = /^Suggests: (.*)$/m;

  do {
foreach $p (grep {!(/^[|(]/|/\)$/)} split ' ', $foo) {
  { push @{$recommends{$p}}, $package; }
}
  } if ($foo) = /^Recommends: (.*)$/m;
}

foreach $p (keys %provides) {
  foreach $pp (@{$provides{$p}}) {
push @{$pre_depends{$pp}}, map $_." (via $p)", @{$pre_depends{$p}}
  if defined $pre_depends{$p};
push @{$depends{$pp}}, map $_." (via $p)", @{$depends{$p}}
  if defined $depends{$p};
push @{$suggests{$pp}}, map $_." (via $p)", @{$suggests{$p}}
  if defined $suggests{$p};
push @{$recommends{$pp}}, map $_." (via $p)", @{$recommends{$p}}
  if defined $recommends{$p};
  }
}

$LIST_SEPARATOR = ", ";

$lib_flag = (defined $ARGV[0] and $ARGV[0] eq "-l");
foreach $p (@packages) {
  next if defined($pre_depends{$p}) || defined($depends{$p});
  next if $lib_flag and $p !~ /lib/;

  print "$p ($priorities{$p})";
  print "\nsuggested by: @{$suggests{$p}}" if defined $suggests{$p};
  print "\nrecommended by: @{$recommends{$p}}" if defined
$recommends{$p};
  print "\n\n";
}


Re: Finding left-over libraries]

1999-12-10 Thread Wayne Topa

Subject: Finding left-over libraries
Date: Tue, Dec 07, 1999 at 11:13:32PM +0100

In reply to:peter karlsson

Quoting peter karlsson([EMAIL PROTECTED]):
>| Is there any way in Debian to find out what packages no other packages
>| depend on?

Take a look at the binstats package.  From the
/usr/doc/binstats/README file

Features include:
 1) tally of a.out and ELF binaries, dynamically and statically linked,
unstripped and setuid
 2) tally of Java bytecode binaries (if you run file-3.20+)
 3) tally of text files distinguishing between Bourne, bash and [T]C shells,
other interpreted scripts, perl scripts & unidentified texts
 4) tally of duplicated executable names
 5) tally of binaries with missing dynamic libraries
 6) tally of DLL and ELF dynamic libraries, used and unused
 7) a log of all the above tallies plus listing a.out binaries, statically
linked binaries, unstripped binaries, setuid binaries, duplicated
executables, missing library binaries, all unidentified text files,
all used and unused dynamic libraries
 8) a C program that dereferences symbolic links
 9) a command line interface(!)

HTH

-- 
User n.:
A programmer who will believe anything you tell him.
___


Re: Finding left-over libraries

1999-12-10 Thread Armin Joellenbeck
Hello,

You might try the program binstats contained in the package binstats,
at least in slink. It's not exactly the tool you are talking about,
but it might be useful.


Armin


Re: Finding left-over libraries

1999-12-10 Thread Matthias Hertel
Hi,

Brian Servis <[EMAIL PROTECTED]> writes:
> *- On  7 Dec, peter karlsson wrote about "Finding left-over libraries"
> > I remove packages, unnecessary libraries are not removed. Because
> > of this, I would like to get a list of packages that no packages
> > depend on (restricted, for instance, to packages starting with
> > lib).
...
> 
> Unforunately there is no way to do this cleanly now.  There has been/is
> active discussion on this very subject on the the -devel list.  One of
> the issues to be concerned with is on a machine used for development
> where nothing directly depends on a lib*-dev package except at build
> time when you need to link to the headers.

Well, its not clean, and it doesn't even work correctly (it doesn't
correctly handle |-dependecies), and there are probably other bugs,
but here is a perl script that I threw together when I was new to
Debian (and perl) that does what you want: It lists all packages
nothing depends on and that are not essential, and also says whether
they are suggested or recommended by other packages. It occasionally
gives false positives (I think the missing |-handling is to be
blamed), and I also found a case where it gives false negatives (some
gnome packages have circular dependencies, I think).

I wonder if all this could be done much more cleanly with libapt
(never looked into that).

Anyway, if anybody wants to improve on this, you're welcome. Perhaps
post it back to the list.

Matthias




#!/usr/bin/perl

# TODO
# handle OR

use English;

open PKGLIST, "dpkg --get-selections |";
while () {
  ($pkg, $sel) = split;
  push @pkglist, $pkg if $sel == "install";
}

open STATUS, "dpkg --status @pkglist |";
$INPUT_RECORD_SEPARATOR = "";
while () {
  ($package) = /^Package: (.*)$/m;
  ($essential) = /^Essential: (.*)$/m;
  ($priority) = /^Priority: (.*)$/m;
  ($size) = /^Installed-Size: (.*)$/m;
  unless ($essential) {
push @packages, $package;
$priorities{$package} = $priority.", ".$size."k";
  }

  ($foo) = /^Pre-Depends: (.*)$/m;
  foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo)
{ push @{$pre_depends{$p}}, $package; }

  ($foo) = /^Depends: (.*)$/m;
  foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo)
{ push @{$depends{$p}}, $package; }

  ($foo) = /^Provides: (.*)$/m;
  foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo)
{ push @{$provides{$p}}, $package; }

  ($foo) = /^Suggests: (.*)$/m;
  foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo)
{ push @{$suggests{$p}}, $package; }

  ($foo) = /^Recommends: (.*)$/m;
  foreach $p (map {/^\S*/; $MATCH;} split /, */, $foo)
{ push @{$recommends{$p}}, $package; }
}

foreach $p (keys %provides) {
  foreach $pp (@{$provides{$p}}) {
push @{$pre_depends{$pp}}, map $_." (via $p)", @{$pre_depends{$p}}
  if defined $pre_depends{$p};
push @{$depends{$pp}}, map $_." (via $p)", @{$depends{$p}}
  if defined $depends{$p};
push @{$suggests{$pp}}, map $_." (via $p)", @{$suggests{$p}}
  if defined $suggests{$p};
push @{$recommends{$pp}}, map $_." (via $p)", @{$recommends{$p}}
  if defined $recommends{$p};
  }
}

$LIST_SEPARATOR = ", ";

foreach $p (@packages) {
  next if defined($pre_depends{$p}) || defined($depends{$p});

  print "$p ($priorities{$p})";
  print "\nsuggested by: @{$suggests{$p}}" if defined $suggests{$p};
  print "\nrecommended by: @{$recommends{$p}}" if defined $recommends{$p};
  print "\n\n";
}


Re: Finding left-over libraries

1999-12-09 Thread Gary Hennigan
peter karlsson <[EMAIL PROTECTED]> writes:
> Brian Servis:
> 
> > Unforunately there is no way to do this cleanly now.  
> 
> That's too bad.
> 
> > One of the issues to be concerned with is on a machine used for
> > development where nothing directly depends on a lib*-dev package except at
> > build time when you need to link to the headers.
> 
> Yeah, well, all I want is a *report* on what is installed that nothing
> depends on. I don't want it to automatically purge everything for me...
> 
> > There is a Debian package called cruft that can do some system searching
> > and can give you a very rough idea of file usage. 
> 
> I couldn't get it to work.

I believe the current version in potato is broken (take a look at the
bug reports for it). However, I used it on my slink system some time
ago and it is very helpful in finding files and such on your system
that aren't associated with a package, but I don't believe it'll find
packages without dependents, at least from reading the documentation,
and using my poor memory, I don't get that impression.

I do agree with you, it'd be nice to have such a utility.

Gary


Re: Finding left-over libraries

1999-12-09 Thread peter karlsson
Brian Servis:

> Unforunately there is no way to do this cleanly now.  

That's too bad.

> One of the issues to be concerned with is on a machine used for
> development where nothing directly depends on a lib*-dev package except at
> build time when you need to link to the headers.

Yeah, well, all I want is a *report* on what is installed that nothing
depends on. I don't want it to automatically purge everything for me...

> There is a Debian package called cruft that can do some system searching
> and can give you a very rough idea of file usage. 

I couldn't get it to work.

-- 
\\//
peter - http://www.softwolves.pp.se/


Re: Finding left-over libraries

1999-12-08 Thread Brian Servis
*- On  7 Dec, peter karlsson wrote about "Finding left-over libraries"
> Is there any way in Debian to find out what packages no other packages
> depend on?
> 
> When I install a couple of packages, all the libraries they depend on are
> installed as well, which is quite nice, but the reverse doesn't hold - when
> I remove packages, unnecessary libraries are not removed. Because of this, I
> would like to get a list of packages that no packages depend on (restricted,
> for instance, to packages starting with lib).
> 

Unforunately there is no way to do this cleanly now.  There has been/is
active discussion on this very subject on the the -devel list.  One of
the issues to be concerned with is on a machine used for development
where nothing directly depends on a lib*-dev package except at build
time when you need to link to the headers. 

There is a Debian package called cruft that can do some system searching
and can give you a very rough idea of file usage. 
 

Brian Servis
-- 

Mechanical Engineering  |  Never criticize anybody until you  
Purdue University   |  have walked a mile in their shoes,
[EMAIL PROTECTED]   |  because by that time you will be a
http://www.ecn.purdue.edu/~servis   |  mile away and have their shoes.


Finding left-over libraries

1999-12-07 Thread peter karlsson
Is there any way in Debian to find out what packages no other packages
depend on?

When I install a couple of packages, all the libraries they depend on are
installed as well, which is quite nice, but the reverse doesn't hold - when
I remove packages, unnecessary libraries are not removed. Because of this, I
would like to get a list of packages that no packages depend on (restricted,
for instance, to packages starting with lib).

-- 
\\//
peter - http://www.softwolves.pp.se/