6 my $specfile = 'pcp.spec';
9 'spec=s' => \
$specfile,
13 open(my $fh, '<:encoding(UTF-8)', $specfile)
14 or die "Could not open '$specfile' $!";
17 my $state = 'before-changelog';
21 # process the specfile
22 while (my $row = <$fh>) {
23 if ($state eq 'before-changelog') {
24 # handful of special cases toward the start of the spec
25 $row =~ s
#ftp://oss.sgi.com#ftp://ftp.pcp.io#;
26 $row =~ s
#^Release: .*%\{\?dist\}#Release: \%\{buildversion}%{?dist}#;
27 $row =~ s
#%{name}-%{version}-.*\.tar\.gz#ftp://ftp.pcp.io/projects/pcp/download/%{name}-%{version}.src.tar.gz#;
32 if ($row =~ '^%changelog') {
33 $state = 'within-changelog';
34 next; # report the heading (above) & continue
35 } elsif ($state eq 'before-changelog') {
36 next; # not yet reached the changelog section
39 # separate out the changelog entries, discard the weekly ones
41 # first deal with any previous entry
42 print $entry if ($entry ne '' and $discard == 0);
43 # now begin capturing this new entry
44 $state = 'capturing-entry';
47 } elsif ($row =~ 'Automated weekly rawhide release') {
53 print $entry if ($entry ne '' and $discard == 0);