--- cpan2rpm.orig 2004-10-15 15:01:05.000000000 -0700 +++ cpan2rpm 2004-10-15 15:13:21.000000000 -0700 @@ -117,6 +117,7 @@ # -- section options "prologue=s@" => "inserts text at beginning of section", "epilogue=s@" => "inserts text at end of section", + "no-default-sec=s@" => "suppress the default output of a section", # -- build options "spec-only" => "only generates spec file", "spec=s" => "specifies the name of a spec file", @@ -649,7 +650,7 @@ /]; $info->{"opts-secs"} = [qw/ - prep build install clean changelog tag files + prep build install clean changelog tag files pre preun post postun /]; # handle aggregate options @@ -671,6 +672,9 @@ for (@$prologue) { /^(\w+):(.*)$/ || next; my ($sec, $v) = ($1, $2); + if ($v=~/^file:(.*)/) { + $v=readfile($1); + } $info->{prologue}{$sec} = $v . $/; } @@ -679,9 +683,23 @@ for (@$epilogue) { /^(\w+):(.*)$/ || next; my ($sec, $v) = ($1, $2); + if ($v=~/^file:(.*)/) { + $v=readfile($1); + } $info->{epilogue}{$sec} = $v . $/; } + my $nodefsec = $info->{"no-default-sec"}; + delete $info->{"no-default-sec"}; + $info->{"no-default-sec"}{$_} = 0 + for (@{$info->{"opts-secs"}}); + + for (@$nodefsec) { + die "No such section in --no-default-sec: $_\n" + unless exists $info->{"no-default-sec"}{$_}; + $info->{"no-default-sec"}{$_} = 1; + } + for (@{$info->{"opts-secs"}}) { $info->{prologue}{$_} ||= ""; $info->{epilogue}{$_} ||= ""; @@ -984,6 +1002,11 @@ if $info->{"no-requires"}{"clean"}; $spec .= mksec($info, "clean" => $_); + $spec .= mksec($info, "pre" => ""); + $spec .= mksec($info, "preun" => ""); + $spec .= mksec($info, "post" => ""); + $spec .= mksec($info, "postun" => ""); + $spec .= qq|$/%files -f %filelist|; $spec .= qq|$/%defattr($info->{defattr})$/|; $spec .= $info->{epilogue}{files}; @@ -1578,7 +1601,9 @@ my $nm = shift; my $ret = qq|$/%$nm|; $ret .= "$/$info->{prologue}{$nm}" if $info->{prologue}{$nm}; - $ret .= "$/$_" for @_; + unless ($info->{"no-default-sec"}{$nm}) { + $ret .= "$/$_" for @_; + } $ret .= "$/$info->{epilogue}{$nm}" if $info->{epilogue}{$nm}; $ret; } @@ -1894,16 +1919,28 @@ =item B<--prologue=CsectionE:EcodeE>> -This option allows the user to insert arbitrary code at the top of a given section of the spec file. The section is named in the value passed to the option as the first word followed by a colon. At present, the following sections are supported: I, I, I, I, I. +This option allows the user to insert arbitrary code at the top of a given section of the spec file. The section is named in the value passed to the option as the first word followed by a colon. At present, the following sections are supported: I, I, I, I, I, I
, I, I, I.
+
+If CcodeE> begins with C, the the remainder is treated as a filename.  The contents of the file will be used.
 
 =item B<--epilogue=CsectionE:EcodeE>>
 
 As with the previous option, this may be used to insert code at the end of a given section.  This option also supports the I and I sections which allow for the user to insert extra tags or files to the spec file.
 
+If CcodeE> begins with C, the the remainder is treated as a filename.  The contents of the file will be used.
+
 I
 
 --epilogue="tag:epoch: 1"
 
+=item B<--no-default-sec=CsectionE>>
+
+Suppresses what cpan2rpm would normally write to the given section of the spec file.  Combined with --prologue and --epilogue, this gives complete control over the given section.
+
+I
+
+--no-default-sec=changelog --prologue="changelog:file:ChangeLog"
+
 =back
 
 =head2 Building options