File: unspin-rawhide

package info (click to toggle)
pcp 4.3.2%2Breally4.3.1-0.1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 175,188 kB
  • sloc: ansic: 261,305; sh: 123,606; xml: 107,279; cpp: 72,127; perl: 18,283; python: 15,453; yacc: 8,249; lex: 2,585; makefile: 1,957; fortran: 60; java: 52
file content (54 lines) | stat: -rwxr-xr-x 1,379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/perl -w

use strict;
use Getopt::Long;

my $specfile = 'pcp.spec';
if (@ARGV) {
    GetOptions (
	'spec=s'	=> \$specfile,
    );
}

open(my $fh, '<:encoding(UTF-8)', $specfile)
    or die "Could not open '$specfile' $!";

# state variables
my $state = 'before-changelog';
my $entry = '';
my $discard = 0;

# process the specfile
while (my $row = <$fh>) {
    if ($state eq 'before-changelog') {
	# handful of special cases toward the start of the spec
	$row =~ s#ftp://oss.sgi.com#ftp://ftp.pcp.io#;
	$row =~ s#^Release: .*%\{\?dist\}#Release: \%\{buildversion}%{?dist}#;
	$row =~ s#%{name}-%{version}-.*\.tar\.gz#ftp://ftp.pcp.io/projects/pcp/download/%{name}-%{version}.src.tar.gz#;

	print $row;
    }

    if ($row =~ '^%changelog') {
	$state = 'within-changelog';
	next;	# report the heading (above) & continue
    } elsif ($state eq 'before-changelog') {
	next;	# not yet reached the changelog section
    }

    # separate out the changelog entries, discard the weekly ones 
    if ($row =~ '^\* ') {
	# first deal with any previous entry
	print $entry if ($entry ne '' and $discard == 0);
	# now begin capturing this new entry
	$state = 'capturing-entry';
	$entry = $row;
	$discard = 0;
    } elsif ($row =~ 'Automated weekly rawhide release') {
	$discard = 1;
    } else {
	$entry .= $row;
    }
}
print $entry if ($entry ne '' and $discard == 0);
close $fh;