fink-package-precedence stable port information

Package: fink-package-precedence
Version: 0.12
Revision: 1

BuildDepends: fink (>= 0.24.12-1)

Source: none
PatchFile: %n.patch
PatchFile-MD5: 7316adc840802d17fdd20eae8a301218
PatchScript: sed 's,@PREFIX@,%p,' < %{PatchFile} | patch -p1

CompileScript: #
InstallScript: <<
mkdir -p %i/bin
install -m755 fink-package-precedence %i/bin
<<

Description: Check fink masking of system libs
DescUsage: <<
fink-package-precedence [options]

See 'fink-package-precedence --help' for details
<<
#Homepage:
License: GPL
Maintainer: Daniel Macks

fink-package-precedence stable port .patch

diff -Nurd -x'*~' fink-package-precedence-0.12.orig/fink-package-precedence fink-package-precedence-0.12/fink-package-precedence
--- fink-package-precedence-0.12.orig/fink-package-precedence 1969-12-31 19:00:00.000000000 -0500
+++ fink-package-precedence-0.12/fink-package-precedence 2011-10-27 09:56:23.000000000 -0400
@@ -0,0 +1,295 @@
+#!/usr/bin/perl
+# -*- mode: Perl; tab-width: 4; -*-
+
+# A dirty hack by Daniel Macks
+
+use warnings;
+use strict;
+
+use File::Find;
+use Getopt::Long;
+use Cwd qw/ abs_path /;
+
+my %opts = (
+ 'headers' => 1, # scan .h in -M dependency files?
+ 'depfile-ext' => [], # extensions for header-dep scan
+ 'prohibit-bdep' => [], # whine if .h supplied by these packages
+ 'libs' => 1, # scan otool -L of compiled binaries?
+ 'help' => 0, # print usage msg?
+ );
+
+GetOptions(
+ \%opts,
+ 'headers!',
+ 'depfile-ext=s@',
+ 'prohibit-bdep=s@',
+ 'libs!',
+ 'help|?',
+ ) or $opts{'help'} = 1;
+if (!$opts{'headers'} && !$opts{'libs'}) {
+ # must specify at least one mode
+ $opts{'help'} = 1;
+};
+if (@{$opts{'prohibit-bdep'}}) {
+ # handle comma-separated list like multiply-passed flag
+ $opts{'prohibit-bdep'} = [ split /,/, join ',', @{$opts{'prohibit-bdep'}} ];
+
+ if (!$opts{'headers'}) {
+ # can't disallow bdep based on header scan if not scanning headers
+ $opts{'help'} = 1;
+ }
+}
+if (@{$opts{'depfile-ext'}}) {
+ # handle comma-separated list like multiply-passed flag
+ $opts{'depfile-ext'} = [ split /,/, join ',', @{$opts{'depfile-ext'}} ];
+
+ if (!$opts{'headers'}) {
+ # can't specify header depfile extensions if not scanning headers
+ $opts{'help'} = 1;
+ }
+} else {
+ $opts{'depfile-ext'} = ['\.Plo', '\.Po'];
+}
+if (!@ARGV) {
+ # must specify at least one location
+ $opts{'help'} = 1;
+}
+if ($opts{'help'}) {
+ my $msg = < +
+Usage: $0 [options]
+
+Options:
+
+ --headers/--no-headers Scan dependency files (*1) for:
+ * Use of system headers that should be
+ masked by fink ones (*2)
+ (bad -I ordering or missing BuildDepends)
+ * Fink packages that supply headers used
+ (packages to list in BuildDepends)
+
+ --depfile-ext= Which files to scan for --headers scan
+ * Defaults to {\.Plo,\.Po} if not specified (*3)
+ * Left-truncated regex for full pathname
+ (beware of regex-quoting and shell-quoting)
+
+ --prohibit-bdep= Test if --headers finds a .h that is supplied
+ by installed fink package (*2)
+ (comma-separated list or multiple use of this
+ flag is allowed)
+
+ --libs/--no-libs Scan compiled binaries for:
+ * System libraries that should be masked by
+ fink ones (*2)
+ (bad -L ordering or missing BuildDepends)
+
+ --help Display this help message and exit
+
+ *1 For example, generated by gcc -M flags as activated by
+ ./configure --enable-dependency-tracking
+
+ *2 error-code on exit if this condition occurs
+
+ *3 These are usually correct for most autotools/libtool-based
+ projects that support --enable-dependency-tracking (*1). Passing
+ -MD directly (perhaps via CPPFLAGS) usually gives .d instead.
+
+ can be dependency filenames, compiled-
+ binary filenames, or directories to scan for these files.
+
+EOMSG
+
+ die $msg;
+}
+# / <-- this slash keeps emacs syntax-highlighting less confused
+
+if ($opts{'headers'}) {
+
+print "Scanning /", join( ",", @{$opts{'depfile-ext'}} ), "\$/ dependency files...\n";
+
+my $dep_re = '(' . join( '|', @{$opts{'depfile-ext'}} ) . ')$';
+$dep_re = qr/$dep_re/;
+
+my %deps; # key=included file
+ # value=first dependencies file where it's listed
+
+my $plo_count = 0;
+foreach my $argv (@ARGV) {
+ my $argv_abs_dir_regex;
+ if (-d $argv) {
+ $argv_abs_dir_regex = abs_path($argv);
+ $argv_abs_dir_regex = qr/^\Q$argv_abs_dir_regex\E/;
+ }
+
+find sub {
+ return unless $File::Find::name =~ /$dep_re/; # skip files that aren't our dependency lists
+
+ print "\t$File::Find::name\n";
+ $plo_count++;
+ open my $plo, '<', $_ or die "Could not read $_: $!\n";
+ while ( defined ( $_ = <$plo> ) ) {
+ next if /^\s*$/; # usually lots of blank lines
+ s/^[^:]*://; # only care deps; filename is key dependant
+ foreach (split) {
+ next unless /^\//; # skip continuation markers and
+ # build-dir local files
+ next if /$argv_abs_dir_regex/; # alt format of build-dir local
+ $deps{$_} = $File::Find::name if ! exists $deps{$_};
+ }
+ }
+ close $plo;
+}, $argv;
+}
+
+if (! $plo_count) {
+ die "No dependency files found.\n";
+}
+
+print "Looking for incorrect headers in ", $plo_count, " dependency files...\n";
+
+# regexes for headers to disallow.
+# * /usr/local is bad news!
+# * OSX or X11 files for which fink has replacements
+# * /opt/local is cross-contamination from MacPorts
+my $repl_regex = '^' . join '|', (
+ '/usr/local/include',
+ '/usr/include/curses\.h',
+ '/usr/include/iconv\.h',
+ '/usr/include/libxml2',
+ '/usr/include/libxslt',
+ '/usr/include/(curses|ncurses|form|menu|panel|term|termcap)\.h',
+ '/usr/include/pcap',
+ '/usr/include/readline',
+ '/usr/.*/ft2build\.h',
+ '/usr/.*/freetype2',
+ '/usr/.*/fontconfig',
+ '/usr/.*/expat\.h',
+ '/usr/.*/Xft',
+ '/usr/.*/cairo',
+ '/usr/.*/glitz',
+ '/usr/.*/pixman',
+ '/usr/.*/png.h',
+ '/usr/.*/pngconf.h',
+ '/opt/local',
+);
+$repl_regex = qr/$repl_regex/; # pre-compile (will use many times)
+my $fink_prefix = '@PREFIX@';
+my $fink_prefix_regex = qr/^\Q$fink_prefix\E/;
+
+my @fink_headers;
+
+my $bad_system = 0;
+foreach (sort keys %deps) {
+ if (/$repl_regex/) {
+ print "\t $deps{$_} uses $_\n";
+ $bad_system = 1;
+ } elsif (/$fink_prefix_regex/) {
+ push @fink_headers, $_;
+ }
+}
+if ($bad_system) {
+ die "Please fix build process to get consistent use of fink's headers.\n";
+}
+
+
+my %fink_pkgs;
+my @not_found;
+my $dpkg_S = "$fink_prefix/bin/dpkg -S";
+my $progress = 1;
+print "Determining fink providers of ", scalar(@fink_headers), " headers...\n";
+while (@fink_headers) {
+ # do in blocks of files using heuristic to avoid shell cmd-line limit
+ # ('dpkg -S' is expensive!)
+ my @chunk = splice @fink_headers, 0, 100;
+ print "\t$progress - ", ($progress+=@chunk)-1, "\n";
+
+ open my $dpkg_S_fh, "$dpkg_S @chunk 2>&1 |" or die "Could not fork $dpkg_S: $!\n";
+ while (<$dpkg_S_fh>) {
+ if (/^dpkg: (.*\.)$/) {
+ # 'dpkg: $filename not found.' but "not found" may be localized
+ push @not_found, $1;
+ } elsif (/^([^:]+):/) {
+ $fink_pkgs{$1} = 1;
+ }
+ }
+ close $dpkg_S_fh; # or die "Error reading $dpkg_S: $! $?\n";
+ # must not trap close() error, since that is expected if a file is
+ # not found in dpkh -S database
+}
+
+print "Found use of headers from ", scalar(keys %fink_pkgs), " fink packages:\n";
+map { print "\t$_\n" } sort keys %fink_pkgs;
+if (@not_found) {
+ print "Could not determine fink package for ", scalar(@not_found), " headers:\n";
+ map { print "\t$_\n" } sort @not_found;
+}
+
+my @bad_bdep = grep { exists $fink_pkgs{$_} } @{$opts{'prohibit-bdep'}};
+if (@bad_bdep) {
+ print "Use of headers from prohibited installed packages:\n";
+ map { print "\t$_\n" } sort @bad_bdep;
+ die "Please fix build process to avoid seeing them.\n";
+}
+
+}
+
+if ($opts{'libs'}) {
+ my $otool = '/usr/bin/otool';
+ if (!-x $otool) {
+ die "Cannot scan binary linking without $otool\n";
+ }
+
+print "Scanning binaries for incorrect dyld linking...\n";
+
+my %deps; # key=linked lib
+ # value=first binary that links against it
+
+find sub {
+ return unless -f;
+ return if /\.class$/;
+ open my $otool_L_fh, '-|', $otool, '-L', $_ or die "Could not fork $otool -L $_: $!\n";
+ while ( defined ( $_ = <$otool_L_fh> ) ) {
+ next unless /^\t(.+) \(/; # only read dyld links
+ $deps{$1} = $File::Find::name if ! exists $deps{$1};
+ }
+ close $otool_L_fh or die "Error reading $otool -L: $! $?\n";
+}, @ARGV;
+
+# regexes for libraries to disallow.
+# * /usr/local is bad news!
+# * OSX or X11 files for which fink has replacements
+# * /opt/local is cross-contamination from MacPorts
+my $repl_regex = '^' . join '|', (
+ '/usr/local/lib',
+ '/usr/lib/libcurses',
+ '/usr/lib/libiconv',
+ '/usr/lib/lib(curses|ncurses|form|menu|panel)',
+ '/usr/lib/libpcap',
+ '/usr/lib/libreadline',
+ '/usr/lib/libxml',
+ '/usr/lib/libxslt',
+ '/usr/X11.*/libfreetype',
+ '/usr/X11.*/libfontconfig',
+ '/usr/.*/libexpat',
+ '/usr/X11.*/libXft',
+ '/usr/X11.*/libcairo',
+ '/usr/X11.*/libglitz',
+ '/usr/X11.*/libpixman',
+ '/usr/X11.*/libpng',
+ '/opt/local',
+);
+$repl_regex = qr/$repl_regex/; # pre-compile (will use many times)
+
+my $bad_system = 0;
+foreach (sort keys %deps) {
+ if (/$repl_regex/) {
+ print "\t $deps{$_} uses $_\n";
+ $bad_system = 1;
+ }
+}
+if ($bad_system) {
+ die "Please fix build process to get consistent use of fink's libraries.\n";
+}
+
+
+}

fink-package-precedence _unstable_ port .patch