1# Copyright (C) 2002 Rob Brown (bbb@cpan.org) 2# Generic rpm SPEC file generator. 3 4use strict; 5 6my $p = $1 if $0 =~ m%([^/]*)$%; 7my $output = shift or die "create what?"; 8 9### Extract $VERSION from VERSION_FROM 10my $name; 11my $version; 12$INC{"ExtUtils/MakeMaker.pm"} = 1; 13sub WriteMakefile { 14 my %props = @_; 15 $name = $props{NAME} || die "Makefile.PL: Missing NAME"; 16 if ($version = $props{VERSION}) { 17 # done 18 } elsif (my $version_from = $props{VERSION_FROM}) { 19 $@ = ""; 20 $version = eval qq{ 21 do "$version_from"; 22 \$$name\::VERSION || die "$version_from: Missing VERSION"; 23 }; 24 die $@ if $@; 25 if (!defined $version) { 26 die "$version_from: Missing VERSION"; 27 } 28 } else { 29 die "Makefile.PL: Could not determine version!"; 30 } 31} 32do "Makefile.PL"; 33if ($name) { 34 $name =~ s/::/-/g; 35} else { 36 die "Makefile.PL: Missing WriteMakefile"; 37} 38 39$version || die "No version!"; 40my ($class,$subclass) = split(/\-/,$name,2); 41local $/ = undef; 42$_ = <DATA>; 43s/\@CLASS\@/$class/g; 44s/\@SUBCLASS\@/$subclass/g; 45s/\@VERSION\@/$version/g; 46 47open SPEC, ">$output" or die "$output: $!"; 48print SPEC "# Automatically generated by $p\n"; 49print SPEC $_; 50close SPEC; 51 52__DATA__ 53%define class @CLASS@ 54%define subclass @SUBCLASS@ 55%define version @VERSION@ 56%define release 1 57%define defperlver 5.6.1 58 59# Derived values 60%define real_name %{class}-%{subclass} 61%define name perl-%{real_name} 62%define perlver %(rpm -q perl --queryformat '%%{version}' 2> /dev/null || echo %{defperlver}) 63 64# Provide perl-specific find-{provides,requires}. 65%define __find_provides %( echo -n /usr/lib/rpm/find-provides && [ -x /usr/lib/rpm/find-provides.perl ] && echo .perl ) 66%define __find_requires %( echo -n /usr/lib/rpm/find-requires && [ -x /usr/lib/rpm/find-requires.perl ] && echo .perl ) 67 68Summary: Perl module %{class}::%{subclass} 69Name: %{name} 70Version: %{version} 71Release: %{release} 72Group: Development/Perl 73License: Artistic 74Source: http://www.cpan.org./modules/by-module/%{class}/%{real_name}-%{version}.tar.gz 75URL: http://search.cpan.org/search?dist=%{real_name} 76Vendor: Rob Brown <bbb@cpan.org> 77Packager: Rob Brown <bbb@cpan.org> 78BuildRequires: perl 79BuildArch: noarch 80BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot-%(id -u -n) 81Requires: perl = %{perlver} 82Provides: %{real_name} = %{version} 83 84%description 85%{class}::%{subclass} Perl Module 86 87%prep 88%setup -q -n %{real_name}-%{version} 89 90%build 91%{__perl} Makefile.PL 92%{__make} OPTIMIZE="$RPM_OPT_FLAGS" 93 94%install 95rm -rf $RPM_BUILD_ROOT 96%{makeinstall} PREFIX=$RPM_BUILD_ROOT%{_prefix} 97[ -x /usr/lib/rpm/brp-compress ] && /usr/lib/rpm/brp-compress 98# Clean up some files we don't want/need 99rm -rf `find $RPM_BUILD_ROOT -name "perllocal.pod" -o -name ".packlist" -o -name "*.bs"` 100find $RPM_BUILD_ROOT%{_prefix} -type d | tac | xargs rmdir --ign 101 102%clean 103rm -rf $RPM_BUILD_ROOT 104HERE=`pwd` 105cd .. 106rm -rf $HERE 107 108%files 109%defattr(-,root,root) 110%doc README Changes examples 111%{_prefix} 112 113%changelog 114* Thu May 30 2002 Rob Brown <bbb@cpan.org> 115- initial creation 116