Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv28500/perlmod/Fink

Modified Files:
        ChangeLog PkgVersion.pm VirtPackage.pm 
Log Message:
add pkgconfig virtuals, adjust x11 to force a version if it finds them

Index: VirtPackage.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/VirtPackage.pm,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -d -r1.139 -r1.140
--- VirtPackage.pm      16 Oct 2007 18:29:31 -0000      1.139
+++ VirtPackage.pm      12 Dec 2007 17:31:40 -0000      1.140
@@ -1,4 +1,4 @@
-# -*- mode: Perl; tab-width: 4; -*-
+# -*- mode: Perl; tab-width: 4; -*-'
 #
 # Fink::VirtPackage class
 #
@@ -49,6 +49,7 @@
 use Fink::Config qw($config $basepath);
 use POSIX qw(uname tmpnam);
 use Fink::Status;
+use File::Basename;
 
 use constant STATUS_PRESENT => "install ok installed";
 use constant STATUS_ABSENT  => "purge ok not-installed";
@@ -71,8 +72,9 @@
 }
 our @EXPORT_OK;
 
-my @xservers     = ('XDarwin', 'Xquartz', 'XDarwinQuartz');
-my $the_instance = undef;
+my $pkgconfig_virtual_prefix = 'system-pkgconfig-';
+my @xservers                 = ('XDarwin', 'Xquartz', 'XDarwinQuartz');
+my $the_instance             = undef;
 
 END { }                                # module clean-up code here (global 
destructor)
 
@@ -997,6 +999,26 @@
        }
        $self->{$hash->{package}} = $hash;
 
+=item [pkgconfig packages]
+
+Fink will scan for .pc files in common places, and create
+virtual packages. (See &package_from_pkgconfig).
+
+=cut
+
+       for my $dir ('/usr/X11/lib/pkgconfig', '/usr/X11R6/lib/pkgconfig', 
'/usr/lib/pkgconfig') {
+               next unless (-d $dir);
+               if (opendir(PKGCONFIG_DIR, $dir)) {
+                       while (my $file = readdir(PKGCONFIG_DIR)) {
+                               next unless ($file =~ /\.pc$/);
+                               my $hash = package_from_pkgconfig($dir . '/' . 
$file);
+                               $self->{$hash->{package}} = $hash;
+                       }
+               } else {
+                       print STDERR "WARNING: unable to read from $dir: $!\n";
+               }
+       }
+
        if ( has_lib('libX11.6.dylib') )
        {
                # check the status of xfree86 packages
@@ -1094,7 +1116,20 @@
                        $hash->{provides} = join ',', map 
$self->{$_}->{provides}, qw/ system-xfree86 system-xfree86-shlibs 
system-xfree86-dev /;
                        $self->{$hash->{package}} = $hash;
 
-                       my ($xver) = check_x11_version();
+                       my $found_pc_x11 = 1;
+                       for my $pkgname ('applewm', 'fontconfig', 'freetype2', 
'x11', 'xcb', 'xorg-server') {
+                               if (not exists 
$self->{$pkgconfig_virtual_prefix . $pkgname} or 
$self->{$pkgconfig_virtual_prefix . $pkgname}->{status} ne STATUS_PRESENT) {
+                                       $found_pc_x11 = 0;
+                                       last;
+                               }
+                       }
+                       my $xver = 0;
+                       if ($found_pc_x11) {
+                               $xver = '7.2';
+                       } else {
+                               ($xver) = check_x11_version();
+                       }
+
                        if (defined $xver) {
                                $hash = {};
                                my $provides;
@@ -1557,6 +1592,89 @@
        return;
 }
 
+=item &package_from_pkgconfig($name)
+
+Creates a virtual package from a pkgconfig file.
+
+If $name is a relative path, searches /usr, /usr/X11,
+and /usr/X11R6 pkgconfig directories and takes the
+first match.
+
+The package name will be the in the form
+"system-pkgconfig-I<name>".
+
+Returns a package object hash.
+
+=cut
+
+sub package_from_pkgconfig {
+       my $filename = shift;
+       my @search_files;
+
+       print STDERR "- scanning pkgconfig file $filename... " if 
($options{debug});
+       if ($filename =~ /^\//) {
+               push(@search_files, $filename);
+       } else {
+               for my $dir ('/usr', '/usr/X11', '/usr/X11R6') {
+                       push(@search_files, $dir . '/lib/pkgconfig/' . 
$filename);
+               }
+       }
+
+       for my $file (@search_files) {
+               if (-e $file) {
+                       my $hash = {};
+                       my $name = basename($file);
+                       $name =~ s/\.pc$//;
+
+                       my $pkgconfig_hash = {};
+                       $hash->{package} = $pkgconfig_virtual_prefix . $name;
+
+                       if (open(PKGCONFIG, $file)) {
+                               while (my $line = <PKGCONFIG>) {
+                                       chomp($line);
+                                       if ($line =~ 
/^\s*([^\:]+)\s*\:\s*(.*?)\s*$/) {
+                                               $pkgconfig_hash->{lc($1)} = $2;
+                                       }
+                               }
+                               close(PKGCONFIG);
+                       } else {
+                               print STDERR "WARNING: could not read $file: 
$!\n" if ($options{debug});
+                       }
+
+                       $hash->{description} = "[virtual pkgconfig package 
representing $name]";
+                       $hash->{homepage} = 
"http://www.finkproject.org/faq/usage-general.php#virtpackage";;
+                       $hash->{status} = STATUS_PRESENT;
+                       if ($pkgconfig_hash->{'version'}) {
+                               $hash->{version} = $pkgconfig_hash->{'version'} 
. '-1';
+                               print STDERR $hash->{version}, "\n" if 
($options{debug});
+                       } else {
+                               $hash->{version} = '0-0';
+                               print STDERR "unknown\n" if ($options{debug});
+                       }
+                       $hash->{descdetail} = <<END;
+$pkgconfig_hash->{'description'}
+
+This package represents the pkgconfig file found at:
+       $file
+END
+                       my $requires = "";
+                       for ('requires', 'requires.private') {
+                               if (exists $pkgconfig_hash->{$_}) {
+                                       $requires .= " " . 
$pkgconfig_hash->{$_};
+                               }
+                       }
+                       $requires =~ s/^ *//;
+                       if ($requires ne "") {
+                               $hash->{descdetail} .= "\nIt expects the 
following pkgconfig packages to exist:\n\t" . $requires . "\n";
+                       }
+                       $hash->{compilescript} = &gen_compile_script($hash);
+                       return $hash;
+
+                       last;
+               }
+       }
+}
+
 =item &check_x11_version()
 
 Attempts to determine the version of X11 based on a number of

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.604
retrieving revision 1.605
diff -u -d -r1.604 -r1.605
--- PkgVersion.pm       2 Nov 2007 02:49:12 -0000       1.604
+++ PkgVersion.pm       12 Dec 2007 17:31:40 -0000      1.605
@@ -4729,7 +4729,7 @@
        my $self = shift;
 
        # just return cached copy if there is one
-       if (exists $self->{_script_env} and not $self->{_bootstrap}) {
+       if (not $self->{_bootstrap} and exists $self->{_script_env} and defined 
$self->{_script_env} and ref $self->{_script_env} eq "HASH") {
                # return ref to a copy, so caller changes do not modify cached 
value
                return \%{$self->{_script_env}};
        }

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.1517
retrieving revision 1.1518
diff -u -d -r1.1517 -r1.1518
--- ChangeLog   27 Nov 2007 18:35:37 -0000      1.1517
+++ ChangeLog   12 Dec 2007 17:31:40 -0000      1.1518
@@ -1,3 +1,8 @@
+2007-12-11  Benjamin Reed  <[EMAIL PROTECTED]>
+
+       * VirtPackage.pm: add support for .pc file virtuals, force x11
+       release version based on existence of certain .pc virtuals
+
 2007-11-27  Alexander Hansen <[EMAIL PROTECTED]>
 
        * Bootstrap.pm: recognize 10.5.1 and 10.4.11 .


-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services
for just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Fink-commits mailing list
Fink-commits@lists.sourceforge.net
http://news.gmane.org/gmane.os.apple.fink.cvs

Reply via email to