--- /usr/bin/cpan2rpm 2005-02-07 17:34:43.000000000 +0000 +++ /usr/bin/cpan2rpmmb 2009-09-03 14:57:29.000000000 +0100 @@ -85,7 +85,7 @@ url => "http://www.cpan.org", packager => "Arix International ", group => "Applications/CPAN", - license => "Artistic", + license => "GPL", release => 1, buildroot => "%{_tmppath}/%{name}-%{version}-%(id -u -n)", defattr => "-,root,root", @@ -151,6 +151,9 @@ "help|h" => "this help screen", "V" => "cpan2rpm version", "D" => "runs the perl debugger", + "post=s" => "post install commands", # Mediaburst Bit + "pre=s" => "pre install commands", # Mediaburst Bit + "no-auto-prov" => "suppress RPM provides auto generation", # Mediaburst Bit ); # get user options from config file ~/.cpan2rpm @@ -431,16 +434,37 @@ # grab parameters to function e.g. WriteMakefile() - my $PLFN = "ExtUtils::MakeMaker::WriteMakefile"; - $PLFN = "Module::Build::new" if $info->{PL} =~ /^Build/; +# my $PLFN = "ExtUtils::MakeMaker::WriteMakefile"; +# $PLFN = "Module::Build::new" if $info->{PL} =~ /^Build/; - eval qq/*${PLFN}_orig = \\&$PLFN/; - eval qq/*$PLFN = sub { - die "SAFETY ABORT!" if \$ENV{_DEEP_RECURSION}++ > 10; - %meta = \@_ unless %meta; - *$PLFN = \\&${PLFN}_orig; - goto &$PLFN; - };/; +# eval qq/*${PLFN}_orig = \\&$PLFN/; +# eval qq/*$PLFN = sub { +# die "SAFETY ABORT!" if \$ENV{_DEEP_RECURSION}++ > 10; +# %meta = \@_ unless %meta; +# *$PLFN = \\&${PLFN}_orig; +# goto &$PLFN; +# };/; + + my $PLFN; # TRW vvvv + if ($info->{PL} =~ /^Build/) { + $PLFN = "Module::Build::new"; + eval qq/*${PLFN}_orig = \\&$PLFN/; + eval qq/*$PLFN = sub { + die "SAFETY ABORT!" if \$ENV{_DEEP_RECURSION}++ > 10; + %meta = \@_[1 .. \$#_] unless %meta; + *$PLFN = \\&${PLFN}_orig; + goto &$PLFN; + };/; + } else { + $PLFN = "ExtUtils::MakeMaker::WriteMakeFile"; + eval qq/*${PLFN}_orig = \\&$PLFN/; + eval qq/*$PLFN = sub { + die "SAFETY ABORT!" if \$ENV{_DEEP_RECURSION}++ > 10; + %meta = \@_ unless %meta; + *$PLFN = \\&${PLFN}_orig; + goto &$PLFN; + };/; + } # TRW ^^^^ local @ARGV = (); local $0 = $t; @@ -460,6 +484,12 @@ $err =~ s/$t/$info->{PL}/g; die "FATAL CRASH! Could not load $info->{PL}:\n$err"; } +print "start of meta\n"; +while(my ($key,$value) = each(%meta)) +{ + print "\n$key -- $value\n\n"; +} + # map Build.PL hash keys to MakeMaker's @@ -470,6 +500,10 @@ dist_author AUTHOR dist_version VERSION dist_version_from VERSION_FROM + dist_abstract ABSTRACT + dist_name DISTNAME + rpm_pre RPM_PRE + rpm_post RPM_POST /; $meta{$b2m{$_}} = $meta{$_} for keys %b2m; } @@ -481,7 +515,18 @@ my $deps = $meta{PREREQ_PM}; for (keys %$deps) { my $use = "use $_"; - $use .= " $deps->{$_}" if $deps->{$_}; + print "Requries: $_ Version: ".$deps->{$_}."\n"; + + #MS 1/9/09 + $info->{"perl-requires"}{$_} = $deps->{$_}; + + if ( $deps->{$_} ) { + my $version = $deps->{$_}; + $version =~ s/^\D+//g; + print "Checking version:".$version."\n" if $version; + $use .= " $version" if $version; + } +# $use .= " $deps->{$_}" if $deps->{$_}; local $^W = 0; $@ = ""; eval $use; @@ -537,6 +582,10 @@ } } + $info->{pre} ||= $meta{RPM_PRE} || ""; + $info->{post} ||= $meta{RPM_POST} || ""; + + $info->{author} ||= $meta{AUTHOR} || ""; if (!$info->{author} && $from =~ /=head\d\s+AUTHORS?\s+(.*?)=/is) { @@ -572,6 +621,8 @@ $info->{version} ||= $meta{VERSION}; unless ($info->{version}) { + require ExtUtils::MakeMaker + unless ExtUtils::MM_Unix->can ('parse_version'); $info->{version} = ExtUtils::MM_Unix->parse_version($from) if $from = $meta{VERSION_FROM}; trim($info->{version}); # parse_version() returns spaces @@ -607,7 +658,7 @@ for (split $/, readfile("MANIFEST")) { s|[/\s].*||; # get subdirs (with some exceptions) - $doc{$_} = 1, next if -d && !/^(t|lib)$/; + $doc{$_} = 1, next if -d && !/^(t|lib|bin|etc)$/; # list all files that match the regexp $doc{$_} = 1 if /$docRE/i; } @@ -616,6 +667,23 @@ unless $info->{doc} =~ s/^=//; $info->{doc} &&= "%doc $info->{doc}"; + my $config_path = ""; + $config_path = $meta{install_path}{etc} if exists($meta{install_path}{etc}); + print "Config Path: $config_path\n"; + my %etc; + for (split $/, readfile("MANIFEST")) { + s|[\s].*||; + # list all files that match the regexp + print "Config Match: $1\n" if /^etc(.*)/i; + $etc{"%config(noreplace) $config_path$1"} = 1 if /^etc(.*)/i; + } + $info->{etc} ||= ""; + $info->{etc} = join "\n", $info->{etc}, keys %etc + unless $info->{etc} =~ s/^=//; + +print "Info etc = ".$info->{etc}."\n"; +# $info->{etc} &&= "%config(noreplace) %{_sysconfdir}/ $info->{etc}"; + # fixes the #! so perl can be found (and deps get made ok) $info->{fixin} = <{"perl-requires"}}) { + $spec .= sprintf("%-*s perl(%s)", $SPECCOL, "requires: ", $_); + if($info->{"perl-requires"}{$_}) { + if($info->{"perl-requires"}{$_} =~m/^\s?[<>=!]+\s?\d+/g) { + $spec .= " ".$info->{"perl-requires"}{$_}; + } elsif ($info->{"perl-requires"}{$_} =~m/^\s?\d+/g) { + $spec .= " == ".$info->{"perl-requires"}{$_}; + } + } + $spec .="\n"; + } + + $spec .= $info->{"provides-list"}; $spec .= $info->{"requires-list"}; $spec .= $info->{"buildrequires-list"}; $spec .= $info->{"source-list"}; $spec .= $info->{"patch-files"}; $spec .= $info->{epilogue}{tag}; - + if($info->{"no-auto-prov"}) { + $spec .= "AutoProv: no\n"; + } $spec .= "\n" . q/%description/ . "\n$info->{description}\n"; $_ = < \\&wanted, no_chdir => 1}, "%{buildroot}"); print "$info->{doc}"; + print <{etc} +ETC + for my \$x (sort \@dirs, \@files) { push \@ret, \$x unless indirs(\$x); } @@ -991,6 +1077,17 @@ $spec .= qq|$/%files -f %filelist|; $spec .= qq|$/%defattr($info->{defattr})$/|; + + if($info->{post}) + { + $spec .= qq|$/%post\n$info->{post}$/|; + } + + if($info->{pre}) + { + $spec .= qq|$/%pre\n$info->{pre}$/|; + } + $spec .= $info->{epilogue}{files}; $spec .= mksec($info, "changelog"