From 2c24163a5de27d7b061b707e7e97ac4521a40f9e Mon Sep 17 00:00:00 2001 From: stevenpritchard Date: Tue, 3 Oct 2006 17:58:44 +0000 Subject: [PATCH] Add patch from Chris Weyl to add --prefer-macros and handle modules specified as Foo-Bar instead of Foo::Bar (SF#1546966). --- Changes | 4 +++- cpanspec | 55 ++++++++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/Changes b/Changes index da40ef9..a4f6290 100644 --- a/Changes +++ b/Changes @@ -1,8 +1,10 @@ -1.69 +1.69 2006-10-03 * Exclude autobuild.sh. * Change regex to also drop leading "an" or "the" from Summary. * Tiny whitespace fix. +* Add patch from Chris Weyl to add --prefer-macros and handle modules + specified as Foo-Bar instead of Foo::Bar (SF#1546966). 1.68 2006-07-20 diff --git a/cpanspec b/cpanspec index ea147a2..6b129da 100755 --- a/cpanspec +++ b/cpanspec @@ -10,7 +10,7 @@ # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # -# $Id: cpanspec,v 1.37 2006/09/04 19:38:23 stevenpritchard Exp $ +# $Id: cpanspec,v 1.38 2006/10/03 17:58:44 stevenpritchard Exp $ our $NAME="cpanspec"; our $VERSION='1.69'; @@ -37,6 +37,7 @@ cpanspec [options] [file [...]] --build -b Build source and binary rpms --cpan -c CPAN mirror URL --verbose -v Be more verbose + --prefer-macros -m Prefer macros over environment variables in the spec Long options: --follow Process build dependencies @@ -166,6 +167,11 @@ Add Provides for this item. Add BuildRequires for this item. +=item B<-m>, B<--prefer-macros> + +Prefer the macro form of common spec constructs over the environment variable +form (e.g. %{buildroot} vs $RPM_BUILD_ROOT). + =item B<-V>, B<--version> Print the version number and exit. @@ -217,6 +223,7 @@ our $buildsrpm=0; our $buildrpm=0; our $verbose=0; our $follow=0; +our $macros=0; our $source; our $cpan=$ENV{'CPAN'} || "http://www.cpan.org"; @@ -235,6 +242,25 @@ our @add_requires; our @add_provides; our @add_buildrequires; +# env. vars and their macro analogues +my @MACROS => ( + + # 0 is for the full expansions.... + { + 'optimize' => '$RPM_OPT_FLAGS', + 'buildroot' => '$RPM_BUILD_ROOT', + }, + + # 1 is for the macros. + { + 'optimize' => '%{optimize}', + 'buildroot' => '%{buildroot}', + }, +); + +# this is set after the parameters are passed +our %macro; + sub print_version { print "$NAME version $VERSION\n"; exit 0; @@ -508,6 +534,7 @@ GetOptions( 'add-provides=s' => \@add_provides, 'add-buildrequires=s' => \@add_buildrequires, 'version' => \&print_version, + 'prefer-macros|m' => \$macros, ) or pod2usage({ -exitval => 1, -verbose => 0 }); pod2usage({ -exitval => 0, -verbose => 1 }) if ($help); @@ -519,6 +546,8 @@ if ($follow and $buildrpm) { $buildrpm=0; } +%macro = %{ $MACROS[$macros] }; + my $prefix=$noprefix ? "" : "perl-"; $packager=$packager || `rpm --eval '\%packager'`; @@ -552,6 +581,10 @@ for my $file (@args) { $version=$2; $type=$3; } else { + + # keep things happy if we get "Foo-Bar" instead of "Foo::Bar" + $file =~ s/-/::/g; + # Look up $file in 02packages.details.txt. update_packages(); $packages=Parse::CPAN::Packages->new($pkgdetails) @@ -991,12 +1024,12 @@ END if ($usebuildpl) { print $spec </dev/null \\; +find $macro{buildroot} -depth -type d -exec rmdir {} 2>/dev/null \\; -chmod -R u+rwX,go+rX,go-w \$RPM_BUILD_ROOT/* +\%{_fixperms} $macro{buildroot}/* END @@ -1061,7 +1094,7 @@ END print $spec <