From 2990c493dba554bc4967ff113d58f1996b5e4a07 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 18 Mar 2014 07:05:35 +0100 Subject: use ExtUtils::PkgConfig in order to get detect rpm Thus helping cpan-testers to install the proper packages We need to include {cflags} even if empty on Linux as it contains -I/usr/local/include on eg: FreeBSD --- Makefile.PL | 56 ++++++++++++++++++++++++++------------------------------ NEWS | 1 + 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 8932818..599a627 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,48 +1,44 @@ use strict; use ExtUtils::MakeMaker; +use ExtUtils::PkgConfig; +# minimum required version of dependencies we need to build +our %build_reqs = ( + 'rpm' => '4.12.0', +); our %CONFIGURE_REQUIRES = ( + 'ExtUtils::Depends' => '0.300', 'ExtUtils::MakeMaker' => '6.64', + 'ExtUtils::PkgConfig' => '1.00', # for finding rpm-devel ); -# where to find the rpm utility - -my $rpm_path = $ENV{RPM_PATH}; # this overrides - -unless (defined $rpm_path) { - for (qw(/bin/rpm /usr/bin/rpm)) { - if (-x) { - $rpm_path = $_; - last; - } - } +# Writing a fake Makefile ensures that CPAN will pick up the correct +# dependencies and install them. +unless (eval "use ExtUtils::Depends '$CONFIGURE_REQUIRES{'ExtUtils::Depends'}';" + . "use ExtUtils::PkgConfig '$CONFIGURE_REQUIRES{'ExtUtils::PkgConfig'}';" + . "1") { + warn "$@\n"; + WriteMakefile( + NAME => 'URPM', + PREREQ_FATAL => 1, + PREREQ_PM => \%CONFIGURE_REQUIRES, + ); + exit 1; # not reached } -defined $rpm_path or die "Can't find rpm on this system\n"; - -sub hexversion { - my ($major, $minor, $micro) = (@_[0] =~ /(\d+)\.(\d+)\.?(\d+)?/); - return int($major<<16) + int($minor<<8) + int($micro<<0); +my %cfg; +unless (eval { %cfg = ExtUtils::PkgConfig->find("rpm >= $build_reqs{rpm}"); 1 }) +{ + warn $@; + exit 0; } -my $version = `LC_ALL=C $rpm_path --version`; -# fix compiling with RCs: -$version =~ s/(-.*)|(\.DEVEL)//; -chomp $version; -$version =~ s/(RPM version )|(rpm \(RPM\) )//; -my $hversion = hexversion($version); -$hversion ge hexversion("4.13") or die "Unable to build URPM with too old (or undetected) rpm version $version\n"; my @rpmflags; -my $ldflags = `pkg-config --libs rpm` . ' -lrpmbuild'; -if ($hversion ge hexversion("4.13.0") && $hversion lt hexversion("5.0")) { - # rpm.org version 4.13.0 - push @rpmflags, "-DRPM4140"; -} my $ccflags = join(' ', '-Wall -Wextra -fno-strict-aliasing', @rpmflags); -print "Found RPM version $version (compiling with flags: $ccflags)\n"; +print "Found RPM version $cfg{modversion} (compiling with flags: $ccflags)\n"; WriteMakefile( NAME => 'URPM', @@ -70,7 +66,7 @@ WriteMakefile( MIN_PERL_VERSION => '5.008001', CCFLAGS => $ccflags, VERSION_FROM => 'URPM.pm', - LIBS => [ $ldflags ], + LIBS => [ $cfg{libs} . ' -lrpmbuild' ], INC => '-I/usr/include/rpm', dist => { COMPRESS => "xz -f", SUFFIX => ".xz" }, realclean => { FILES => "t/RPMS/noarch/*" }, diff --git a/NEWS b/NEWS index 24efd3d..47218d0 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ - make clear URPM needs rpm >= 4.14 - revert fix for segfault with rpm-4.14 when checking invalid signatures as rpm got fixed +- use ExtUtils::PkgConfig in order to get rpm installed Version 5.15 - 3 October 2017 -- cgit v1.2.1