Update of /cvsroot/fink/fix-fink
In directory sc8-pr-cvs1:/tmp/cvs-serv28821

Modified Files:
        fix-fink.in 
Added Files:
        .cvsignore Makefile fix-fink.info.in 
Log Message:
made a real package out of fix-fink
also added documentation!
and added a check for things that link against /usr/lib libraries that
they shouldn't.  probably needs to be refactored to look for specifics
rather than just ignoring libsystem, etc.


--- NEW FILE: .cvsignore ---
fix-fink *.1
.*.swp
*.info

--- NEW FILE: Makefile ---
DESTDIR=
PREFIX=/usr/local
MANDIR=$(PREFIX)/man
VERSION=2.2

SCRIPTS=fix-fink
MANPAGES=fix-fink.1

all: $(SCRIPTS) doc fix-fink.info
doc: $(MANPAGES)

%.1: % Makefile
        pod2man --section=1 --release=$(VERSION) $< > $@

clean:
        rm -rf fix-fink $(MANPAGES) fix-fink.info

check: $(SCRIPTS)
        @for script in $(SCRIPTS); do perl -c $$script; done

install: $(SCRIPTS) $(MANPAGES)
        install -d -m 755 $(DESTDIR)$(PREFIX)/bin
        install    -m 755 $(SCRIPTS) $(DESTDIR)$(PREFIX)/bin/
        install -d -m 755 $(DESTDIR)$(PREFIX)/share/man/man1
        install    -m 755 $(MANPAGES) $(DESTDIR)$(PREFIX)/share/man/man1

%.info: %.info.in Makefile
        sed -e "s,@VERSION@,$(VERSION),g" $< > $@

%: %.in Makefile
        sed -e "s,@PREFIX@,$(PREFIX),g" -e "s,@VERSION@,$(VERSION),g" $< > $@

--- NEW FILE: fix-fink.info.in ---
Package: fix-fink
Version: @VERSION@
Revision: 1
Depends: fink, dpkg
Source: mirror:sourceforge:fink/%n-%v.tar.gz
#Source-MD5: 2bae91810592f6eb5636b8db275ae954
Description: Utility to fix libSystem/libpng probs in a fink installation
License: GPL
CompileScript: <<
        make PREFIX=%p
<<
InstallScript: <<
        make install PREFIX=%p DESTDIR=%d
<<
DocFiles: COPYING ChangeLog README
Maintainer: Dave Morrison <[EMAIL PROTECTED]>
Homepage: http://fink.sourceforge.net/

Index: fix-fink.in
===================================================================
RCS file: /cvsroot/fink/fix-fink/fix-fink.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- fix-fink.in 19 Mar 2003 02:32:48 -0000      1.3
+++ fix-fink.in 10 Oct 2003 19:42:50 -0000      1.4
@@ -1,9 +1,16 @@
 #!/usr/bin/perl -w
 
+=head1 NAME
+
+fix-fink - a script for doing various maintenance tasks to fix
+problems that are hard to detect within fink.
+
+=cut
+
 #    fix-fink
 #
 #    Copyright 2002, 2003 Max Horn and David R. Morrison
-# 
+#
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
 #    the Free Software Foundation; either version 2 of the License, or
@@ -20,13 +27,34 @@
 #
 
 # Depends: fink, dpkg
-use lib "@PREFIX@/lib/perl5";
+use lib '@PREFIX@/lib/perl5';
 use Fink::Services "&prompt_boolean";
+use File::Find;
 
-my $version="@VERSION@";
+my %usr_lib_packages;
+my $version = '@VERSION@';
+my $prefix  = '@PREFIX@';
 
 my $answer;
 
+=head1 SYNOPSIS
+
+fix-fink
+
+=head1 DESCRIPTION
+
+This program will check your fink installation for certain problems which
+are difficult to detect directly with fink.  If problems are found, you
+will be asked if you wish to update certain parts of fink, and if so,
+fink will be called to do the updating.
+
+=head1 COMMAND-LINE OPTIONS
+
+There are no command-line options for fix-fink.  It is exclusively
+an interactive program.
+
+=cut
+
 print <<"EOF";
 Welcome to fix-fink version $version.
 
@@ -35,164 +63,261 @@
 will be asked if you wish to update certain parts of fink, and if so,
 fink will be called to do the updating.
 
-At the moment, this program can check for two things.  This first possible
-check is whether your executables and dynamic libraries have been linked
+I can check whether your executables and dynamic libraries have been linked
 EOF
-$answer=&prompt_boolean("to an outdated version of libpng.  Do you wish to perform 
this check?");
+$answer =
+  &prompt_boolean(
+       "to an outdated version of libpng.  Shall I perform this check?");
 print "\n";
 
-if ($answer) {&check_libpng} ;
+check_libpng() if ($answer);
 
 print <<"EOF";
-The second possible check is whether your dynamic libraries have been 
-linked to an outdated version of libSystem.  (This might have happened 
-during the upgrade from OS X 10.0 to OS X 10.1 in mid-2001.)  Do you 
+I can check whether your dynamic libraries have been linked to an
+outdated version of libSystem.  (This might have happened during the
+upgrade from OS X 10.0 to OS X 10.1 in mid-2001.)  Shall I perform
 EOF
-    $answer=&prompt_boolean("wish to perform this check?");
+$answer = &prompt_boolean("this check?");
 print "\n";
 
-if ($answer) {&check_libSystem} ;
+check_libSystem() if ($answer);
 
+print <<"EOF";
+I can check whether you have packages linked against libraries in /usr/lib
+that have fink equivalents.  This generally happens when you build an
+old package from source on OS X 10.3 (or higher).  Shall I perform this
+EOF
+$answer = &prompt_boolean("check?");
+print "\n";
 
+check_usr_lib_link() if ($answer);
 
 print "Thank you for using fix-fink.\n";
 
-sub check_libSystem {
-    chdir "@PREFIX@/lib" or die "Cannot change directory to @PREFIX@/lib: $!\n";
-    my @dylibs = glob "*.dylib";
+=head1 TESTS
 
-    print "Examining your dynamic libraries with otool";
-    my @badlibs = grep { &otool_libSystem("$_") } @dylibs;
-    print "\n\n";
+Currently fix-fink checks for the following problems:
 
-    if (! @badlibs) { print "Your dynamic libraries are OK.\n\n"; return}
+=over 4
 
-    print "Using dpkg to determine the list of packages to rebuild";
-    my %dpkghash;
-    foreach $dylib (@badlibs) {
-    my $package = [EMAIL PROTECTED]@/bin/dpkg -S "@PREFIX@/lib/$dylib"`; # dpkg 
returns one item
-    $package =~ s/:.*\n// ; # get rid of everything after :, including \n
-    $dpkghash{$package}=1;
-    print "."; # let users see that something is happening
-};
-    print "\n\n";
+=item outdated libpng links
 
-    my @sortedkeys = sort keys %dpkghash;
+Check for executables and libraries that have been linked against libpng
+(which has been removed in favor of libpng3).
 
-    print <<"EOF";
-Some of your installed packages were linked against an outdated version
-of libSystem.B.dylib (version 50.0.0), and should be rebuilt.  The list
-of affected packages is:
+=cut
 
-EOF
-    print "@sortedkeys\n\n";
-    print <<"EOF";
-You can rebuild these by issuing the command "fink rebuild" followed by the
-EOF
-    $answer=&prompt_boolean("package names.  Do you wish to do this now 
(automatically)?");
-    print "\n";
-    if ($answer) {
-       print <<"EOF";
-If fink gets interrupted during this process, you can always call fink 
-directly at a later time to rebuild these yourself.
+sub check_libpng {
+       chdir "$prefix/lib" or die "Cannot change directory to $prefix/lib: $!\n";
+       my @dylibs = glob "*.dylib";
 
-EOF
-       system "@PREFIX@/bin/fink", "rebuild", @sortedkeys;
-       print "\n";
-} else {
-    print <<"EOF";
-You can call fink directly to rebuild these yourself, or rerun fix-fink
-to rebuild them automatically at a later date.
+       print "Examining your dynamic libraries with otool";
+       my @badlibs = grep { &otool_libpng("$_") } @dylibs;
+       print "\n\n";
+
+       chdir "$prefix/bin" or die "Cannot change directory to $prefix/bin: $!\n";
+       my @bins = glob "*";
+
+       print "Examining your executables with otool";
+       my @badbins = grep { &otool_libpng("$_") } @bins;
+       print "\n\n";
+
+       if ( @badlibs ) {
+               print "Using dpkg to determine the list of packages to rebuild";
+               my %dpkghash;
+               foreach $dylib (@badlibs) {
+                       my $package =
+                         `$prefix/bin/dpkg -S "$prefix/lib/$dylib"`;    # dpkg 
returns one item
+                       $package =~ s/:.*\n//;    # get rid of everything after :, 
including \n
+                       $dpkghash{$package} = 1;
+                       print ".";                # let users see that something is 
happening
+               }
+               foreach $bin (@badbins) {
+                       my $package =
+                         `$prefix/bin/dpkg -S "$prefix/bin/$bin"`;    # dpkg returns 
one item
+                       $package =~ s/:.*\n//;    # get rid of everything after :, 
including \n
+                       $dpkghash{$package} = 1;
+                       print ".";                # let users see that something is 
happening
+               }
+               print "\n\n";
+       
+               my @keys = grep !/libpng/, keys %dpkghash;
+       
+               if ( @keys > 0 ) {
+                       do_rebuild(@keys);
+               }
+               else {
+                       print <<"EOF";
+Nothing to rebuild.
 
 EOF
+               }
+
+       }
+       else {
+               print "Your dynamic libraries are OK.\n\n";
+       }
+
+       return 1;
 }
+
+=item outdated libSystem
+
+Check for libraries that have been linked to an outdated version of
+libSystem.
+
+=cut
+
+sub check_libSystem {
+       chdir "$prefix/lib" or die "Cannot change directory to $prefix/lib: $!\n";
+       my @dylibs = glob "*.dylib";
+
+       print "Examining your dynamic libraries with otool";
+       my @badlibs = grep { &otool_libSystem("$_") } @dylibs;
+       print "\n\n";
+
+       if ( @badlibs ) {
+               print "Using dpkg to determine the list of packages to rebuild";
+               my %dpkghash;
+               foreach $dylib (@badlibs) {
+                       my $package =
+                         `$prefix/bin/dpkg -S "$prefix/lib/$dylib"`;    # dpkg 
returns one item
+                       $package =~ s/:.*\n//;    # get rid of everything after :, 
including \n
+                       $dpkghash{$package} = 1;
+                       print ".";                # let users see that something is 
happening
+               }
+               print "\n\n";
+
+               do_rebuild( keys %dpkghash );
+
+       }
+       else {
+               print "Your dynamic libraries are OK.\n\n";
+       }
+
+       return 1;
 }
 
-sub check_libpng {
-    chdir "@PREFIX@/lib" or die "Cannot change directory to @PREFIX@/lib: $!\n";
-    my @dylibs = glob "*.dylib";
+=item wrong library
 
-    print "Examining your dynamic libraries with otool";
-    my @badlibs = grep { &otool_libpng("$_") } @dylibs;
-    print "\n\n";
+Check for libraries that are linked against the Apple version of a
+library that Fink provides.  Generally this will cause Bus Errors
+at runtime for software that links against the wrong library.
 
-    chdir "@PREFIX@/bin" or die "Cannot change directory to @PREFIX@/bin: $!\n";
-    my @bins = glob "*";
+=cut
 
-    print "Examining your executables with otool";
-    my @badbins = grep { &otool_libpng("$_") } @bins;
-    print "\n\n";
+sub check_usr_lib_link {
+       find( \&get_usrlibs, "$prefix/bin", "$prefix/sbin", glob("$prefix/lib*") );
 
-    if (! @badlibs) { print "Your dynamic libraries are OK.\n\n"; return}
+       if ( keys %usr_lib_packages ) {
+               do_rebuild( keys %usr_lib_packages );
+       } else {
+               print "Your dynamic libraries are OK.\n\n";
+       }
 
-    print "Using dpkg to determine the list of packages to rebuild";
-    my %dpkghash;
-    foreach $dylib (@badlibs) {
-    my $package = [EMAIL PROTECTED]@/bin/dpkg -S "@PREFIX@/lib/$dylib"`; # dpkg 
returns one item
-    $package =~ s/:.*\n// ; # get rid of everything after :, including \n
-    $dpkghash{$package}=1;
-    print "."; # let users see that something is happening
-};
-    foreach $bin (@badbins) {
-    my $package = [EMAIL PROTECTED]@/bin/dpkg -S "@PREFIX@/bin/$bin"`; # dpkg returns 
one item
-    $package =~ s/:.*\n// ; # get rid of everything after :, including \n
-    $dpkghash{$package}=1;
-    print "."; # let users see that something is happening
-};
-    print "\n\n";
+       return 1;
+}
 
-    my @sortedkeys = grep !/libpng/, sort keys %dpkghash;
+sub do_rebuild {
+       my @packages = sort(@_);
 
-    if ($#sortedkeys > -1) {
-    print <<"EOF";
-Some of your installed packages were linked against an outdated version
-of libpng (version 1.0.12), and should be rebuilt.  The list of affected 
-packages is:
+       print <<"EOF";
+Some of your installed packages are out of date and need to be updated
+or rebuilt.  The list of affected packages is:
 
 EOF
-    print "@sortedkeys\n\n";
-    print <<"EOF";
+       print "@packages\n\n";
+       print <<"EOF";
 You can rebuild these by issuing the command "fink rebuild" followed by the
 package names, and then reinstall them by issuing the command "fink 
 reinstall" followed again by the package names.  Do you wish to do this now 
 EOF
-    $answer=&prompt_boolean("(automatically)?");
-    print "\n";
-    if ($answer) {
-       print <<"EOF";
+       $answer = &prompt_boolean("(automatically)?");
+       print "\n";
+       if ($answer) {
+               print <<"EOF";
 If fink gets interrupted during this process, you can always call fink 
 directly at a later time to rebuild and reinstall these yourself.
 
 EOF
-       system "@PREFIX@/bin/fink", "rebuild", @sortedkeys;
-       system "@PREFIX@/bin/fink", "reinstall" , @sortedkeys;
-       print "\n";
-} else {
-    print <<"EOF";
+               system "$prefix/bin/fink", "rebuild",   @packages;
+               system "$prefix/bin/fink", "reinstall", @packages;
+               print "\n";
+       }
+       else {
+               print <<"EOF";
 You can call fink directly to rebuild and reinstall these yourself, or rerun 
 fix-fink to rebuild and reinstall them automatically at a later date.
 
 EOF
+       }
 }
-} else {
-    print <<"EOF";
-Nothing to rebuild.
 
-EOF
-}
+sub get_usrlibs {
+       my $found = 0;
+       return if ( -l $_ );
+       if ( open( OTOOL, "otool -L $_ 2>/dev/null |" ) ) {
+               <OTOOL>;
+               while (<OTOOL>) {
+                       chomp;
+                       s/^\s*//;
+                       my ($lib) = split(/\s+/);
+                       if (    $lib =~ m#^/usr/lib#
+                               and $lib !~ m#^/usr/lib/libz#
+                               and $lib !~ m#^/usr/lib/libSystem#
+                               and $lib !~ m#^/usr/lib/libresolv#
+                               and $lib !~ m#^/usr/lib/libpam#
+                               and $lib !~ m#^/usr/lib/libcups# )
+                       {
+                               $found++;
+                               last;
+                       }
+               }
+               close(OTOOL);
+       }
+       if ($found) {
+               if ( open( DPKG, "dpkg -S '$File::Find::name' |" ) ) {
+                       while (<DPKG>) {
+                               if (/^([^:]+):/) {
+                                       $usr_lib_packages{$1}++;
+                               }
+                       }
+                       close(DPKG);
+               }
+       }
 }
 
 sub otool_libSystem {
-    my ($dylib) = @_;
-    my @answer  = grep { /current.version.50\.0\.0/ } `/usr/bin/otool -L "$dylib"`;
-    print "."; # let users see that something is happening
-    @answer;
+       my ($dylib) = @_;
+       my @answer =
+         grep { /current.version.50\.0\.0/ } `/usr/bin/otool -L "$dylib"`;
+       print ".";    # let users see that something is happening
+       @answer;
 }
 
 sub otool_libpng {
-    my ($dylib) = @_;
-    my @answer  = grep { /\/lib\/libpng\.2\.dylib/ } `/usr/bin/otool -L "$dylib"`;
-    print "."; # let users see that something is happening
-    @answer;
+       my ($dylib) = @_;
+       my @answer =
+         grep { /\/lib\/libpng\.2\.dylib/ } `/usr/bin/otool -L "$dylib"`;
+       print ".";    # let users see that something is happening
+       @answer;
 }
+
+=back
+
+=head1 SEE ALSO
+
+L<fink>
+
+=head1 COPYRIGHT
+
+Copyright 2002-2003 Max Horn, David R. Morrison, and Benjamin Reed
+
+=head1 AUTHORS
+
+Max Horn <[EMAIL PROTECTED]>,
+David R. Morrison <[EMAIL PROTECTED]>,
+Benjamin Reed <[EMAIL PROTECTED]>
+
+=cut
 




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to