On Thursday, January 9, 2003, at 01:29 AM, [EMAIL PROTECTED] wrote:
Message: 11
Date: Wed, 8 Jan 2003 23:28:57 -0800
Subject: Re: [Fink-users] Bluefish, Apple X11, and xfree86-threaded?
Cc: [EMAIL PROTECTED]
To: Douglas Theobald <[EMAIL PROTECTED]>
From: Kow K <[EMAIL PROTECTED]>

...stuff deleted...

Currently, I'm checking out what tools need to be rebuild.

Kow

I wrote the following script awhile back to determine what I had installed but forgot to remove when I found that I didn't use it... The script checks the specified installed package to determine what depends upon them... no promises that it catches everything, but it's worked for me so far... if someone wants to use this as a starting point to determine what may need to be recompiled, invoke the script with x11 (or xfree86-base) for a list... it should deal with the "aliases" that some package variants use.

Sorry it's long, and yeah, I know the code is probably not the most elegant way to do it, but I cobbled it together from some other scripts I had written for other reasons...

At any rate, for those interested, here it is... as always, no responsibility is assumed for what this code does or doesn't do... and since you have the code visible here, review it yourself before trusting it... standard disclaimer stuff...

#! /usr/bin/perl

$Top_Package = shift ;

if ($Top_Package eq "") {
print "\n" ;
print "$0 <package>\n" ;
print "\n" ;
print "This tool will list the packages that depend upon the specified package.\n" ;
print "It is limited to displaying dependency information about already installed\n" ;
print "packages, so it is primarily for determining what is safe to remove.\n" ;
print "\n" ;
exit ;
}

open(DPKG,"</sw/var/lib/dpkg/status") ;

while(<DPKG>) {
chop ;
if (/^Package: (.+)$/) {
$Current_Package = $1 ;
if ($Top_Package eq $Current_Package) { $found = "true" ; }
} elsif (/^Depends: (.+)$/) {
$Depends = $1 ;
foreach $entry (split(/,/,$Depends)) {
$entry =~ tr/\ //d ;
(@parts) = split(/\(/,$entry) ;
if ($Packages{$Current_Package} ne "") {
$Packages{$Current_Package} .= "," ;
}
$Packages{$Current_Package} .= $parts[0] ;
}
} elsif (/^Provides: (.+)$/) {
$Provides = $1 ;
foreach $entry (split(/,/,$Provides)) {
$entry =~ tr/\ //d ;
(@parts) = split(/\(/,$entry) ;
$Provided_By{$parts[0]} = $Current_Package ;
if ($Top_Package eq $parts[0]) { $found = "true" ; }
}
}
}

close(DPKG) ;

foreach $package (sort keys %Provided_By) {
if ($Top_Package eq $Provided_By{$package}) {
$Look_For = $package ;
}
}

undef @Users ;

foreach $package (sort keys %Packages) {
undef @list ;
@list = split(/,/,$Packages{$package}) ;
foreach $item (@list) {
if ($item eq $Look_For || $item eq $Top_Package) {
push(@Users,$package) ;
}
}
}

if ($Look_For ne '') {
$Look_For = " (".$Look_For.")" ;
}
if (@Users == 0) {
print "$Top_Package$Look_For is not required by any other package.\n" ;
} else {
print "$Top_Package$Look_For is required by the following:\n" ;
foreach $package (@Users) {
print "\t$package\n" ;
}
}

Please be gentle in your critiques! Hope this helps someone.

--
Aaron Magill



-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
Fink-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-users

Reply via email to