forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makerpmcl.pl
executable file
·90 lines (85 loc) · 2.83 KB
/
makerpmcl.pl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl
$since='';
$expect='first heading';
sub clerror { printf(STDERR "$_[0], at changelog line $.\n"); exit(1); }
sub printit {
$fulldate=$_[0];
$fullauth=$_[1];
$changes=$_[2];
$changes =~ s/^\s+(\*)/ +/g;
$_=$fulldate;
if (m/([a-zA-Z]+), *([0-9]+) *([a-zA-Z]+) *([0-9]+).*/i) {
$day=$1;
$date=$2;
$month=$3;
$year=$4;
}
else {
&clerror("Bad date format $_");
}
$_=$fullauth;
if (m/([^<]+) *<([^>]+)>/i) {
$name=$1;
$email=$2;
}
else {
&clerror("Bad maintainer format $_");
}
printf("* %s %s %02d %d %s %s\n%s\n",
$day, $month, $date, $year, $name, $email, $changes);
}
while (<STDIN>) {
# Eat white space
s/\s*\n$//;
# printf(STDERR "%-39.39s %-39.39s\n",$expect,$_);
# Match a line
if (m/^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)((\s+[-0-9a-z]+)+)\;/i) {
if ($expect eq 'first heading') {
$f{'Source'} = $1;
$f{'Version'} = $2;
$f{'Distribution'} = $3;
$f{'Distribution'} =~ s/^\s+//;
$f{'Changes'} = " \n [" . $f{'Version'} . "]\n";
} elsif ($expect eq 'next heading or eof') {
last if $2 eq $since;
$f{'Version'} = $2;
$f{'Distribution'} = $3;
$f{'Distribution'} =~ s/^\s+//;
$f{'Changes'} .= " \n [" . $f{'Version'} . "]\n";
} else {
&clerror("found start of entry where expected $expect");
}
$expect= 'start of change data'; $blanklines=0;
# $f{'Changes'}.= " $_\n \n";
} elsif (m/^\S/) {
&clerror("badly formatted heading line");
} elsif (m/^ \-\- (.*) <(.*)> ((\w+\,\s*)?\d{1,2}\s+\w+\s+\d{4}\s+\d{1,2}:\d\d:\d\d\s+[-+]\d{4}(\s+\([^\\\(\)]\))?)$/) {
$expect eq 'more change data or trailer' ||
&clerror("found trailer where expected $expect");
$f{'Maintainer'}= "$1 <$2>" unless defined($f{'Maintainer'});
$f{'Date'}= $3 unless defined($f{'Date'});
&printit($f{'Date'},$f{'Maintainer'},$f{'Changes'});
$f{'Changes'} = '';
$expect= 'next heading or eof';
# last if $since eq '';
} elsif (m/^ \-\-/) {
&clerror("badly formatted trailer line");
} elsif (m/^\s{2,}\S/) {
$expect eq 'start of change data' ||
$expect eq 'more change data or trailer' ||
&clerror("found change data where expected $expect");
$f{'Changes'} .= (" \n"x$blanklines);
s/^ *\*/ +/;
$f{'Changes'} .= " $_\n";
$blanklines=0;
$expect= 'more change data or trailer';
} elsif (!m/\S/) {
next if $expect eq 'start of change data' ||
$expect eq 'next heading or eof';
$expect eq 'more change data or trailer' ||
&clerror("found blank line where expected $expect");
$blanklines++;
} else {
&clerror("unrecognised line");
}
}