Skip Menu |

This queue is for tickets about the Alien-libtermkey CPAN distribution.

Report information
The Basics
Id: 84556
Status: resolved
Priority: 0/
Queue: Alien-libtermkey

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 0.14



Subject: ->atleast_version patch
The ->atleast_version delegation to pkg-config doesn't seem to work for me (Ubuntu 12.04), since the actual option is --atleast-version and it returns via exit code rather than STDOUT. I've worked around it using this, could probably be cleaned up a bit (relying on passing $? between methods is perhaps a bit nasty). cheers, Tom --- lib/Alien/libtermkey.pm 2013-04-10 17:40:01.704722707 +0100 +++ /home/tom/perl5/perlbrew/perls/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux/Alien/libtermkey.pm 2013-04-10 17:39:11.037708475 +0100 @@ -50,6 +50,11 @@ return _get_pkgconfig( $AUTOLOAD, @_ ); } +sub atleast_version { + _get_pkgconfig('atleast-version', @_); + return !($? >> 8); +} + sub _get_pkgconfig { my ( $method, $self, @args ) = @_; @@ -59,6 +64,7 @@ die "Cannot popen pkg-config - $!"; my $ret = do { local $/; <$eupc> }; chomp $ret; + close $eupc; return $ret; }
On Wed Apr 10 12:42:56 2013, TEAM wrote: Show quoted text
> The ->atleast_version delegation to pkg-config doesn't seem to work > for me (Ubuntu 12.04), since the actual option is --atleast-version > and it returns via exit code rather than STDOUT. > > I've worked around it using this, could probably be cleaned up a bit > (relying on passing $? between methods is perhaps a bit nasty).
Ahyes. Find attached what might be a little neater; also fixes the other *-version methods. -- Paul Evans
Subject: rt84556.patch
=== modified file 'lib/Alien/libtermkey.pm' --- lib/Alien/libtermkey.pm 2012-11-30 17:49:17 +0000 +++ lib/Alien/libtermkey.pm 2013-04-10 19:45:23 +0000 @@ -7,6 +7,8 @@ our $VERSION = '0.13'; +use POSIX qw( WEXITSTATUS ); + # libdir is the first @INC path that contains a pkgconfig/ dir my $libdir; foreach my $inc ( @INC ) { @@ -43,10 +45,17 @@ =cut +my %check_methods = map { $_ => 1 } qw( + atleast_version + exact_version + max_version +); + # I AM EVIL sub AUTOLOAD { our $AUTOLOAD =~ s/^.*:://; + return defined _get_pkgconfig( $AUTOLOAD, @_ ) if $check_methods{$AUTOLOAD}; return _get_pkgconfig( $AUTOLOAD, @_ ); } @@ -54,12 +63,16 @@ { my ( $method, $self, @args ) = @_; + $method =~ s/_/-/g; + local $ENV{PKG_CONFIG_PATH} = "$libdir/pkgconfig/"; open my $eupc, "-|", "pkg-config", "--define-variable=libdir=$libdir", "--$method", @args, $module or die "Cannot popen pkg-config - $!"; my $ret = do { local $/; <$eupc> }; chomp $ret; + close $eupc; + return undef if WEXITSTATUS($?); return $ret; }
Was released in 0.14. -- Paul Evans