added a changelog script
Showing
2 changed files
with
148 additions
and
0 deletions
1 | Sean 'Shaleh' Perry <shaleh@debian.org> Tue, 5 Oct 1999 23:06:33 -0700 | ||
2 | |||
3 | * Added changelog.pl so we can have automated entries | ||
4 | set CVS_EMAIL=me@here.com and CVS_FULLNAME="Joe Blow" | ||
5 | usage: changelog.pl "added signal.c" or changelog.pl, an editor will | ||
6 | then appear (uses $VISUAL and $EDITOR) | ||
7 | the format is controlled simply via the format call at the end | ||
8 | and the section of perl code directly above it | ||
9 | |||
1 | Sean 'Shaleh' Perry <shaleh@debian.org> Tue, 5 Oct 1999 17:46:31 -0700 | 10 | Sean 'Shaleh' Perry <shaleh@debian.org> Tue, 5 Oct 1999 17:46:31 -0700 |
2 | 11 | ||
3 | * added pop3d/signal.c -- contains pop3_sigchld() currently | 12 | * added pop3d/signal.c -- contains pop3_sigchld() currently | ... | ... |
changelog.pl
0 → 100755
1 | #!/usr/bin/perl | ||
2 | |||
3 | # changelog: update the changelog using your favorite visual editor | ||
4 | # | ||
5 | # When creating a new changelog section, if either of the environment | ||
6 | # variables CVS_EMAIL or EMAIL is set, changelog will use this as the | ||
7 | # uploader's email address (with the former taking precedence), and if | ||
8 | # CVS_FULLNAME is set, it will use this as the uploader's full name. | ||
9 | # Otherwise, it will just copy the values from the previous changelog | ||
10 | # entry. | ||
11 | # | ||
12 | # Originally by Christoph Lameter <clameter@debian.org> | ||
13 | # Modified extensively by Julian Gilbey <jdg@debian.org> | ||
14 | # Now a changelog script for GNU projects | ||
15 | # Sean 'Shaleh' Perry <shaleh@debian.org> | ||
16 | # | ||
17 | # Copyright 1999 by Julian Gilbey | ||
18 | # | ||
19 | # This program is free software; you can redistribute it and/or modify | ||
20 | # it under the terms of the GNU General Public License as published by | ||
21 | # the Free Software Foundation; either version 2 of the License, or | ||
22 | # (at your option) any later version. | ||
23 | # | ||
24 | # This program is distributed in the hope that it will be useful, | ||
25 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
26 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
27 | # GNU General Public License for more details. | ||
28 | # | ||
29 | # You should have received a copy of the GNU General Public License | ||
30 | # along with this program; if not, write to the Free Software | ||
31 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
32 | |||
33 | use 5.003; # We're using function prototypes | ||
34 | use Getopt::Std; | ||
35 | use File::Copy; | ||
36 | use Cwd; | ||
37 | |||
38 | # Predeclare functions | ||
39 | sub fatal($); | ||
40 | |||
41 | my $progname; | ||
42 | ($progname=$0) =~ s|.*/||; | ||
43 | |||
44 | sub usage { | ||
45 | print <<EOF | ||
46 | Usage: $progname [-h] [changelog entry] | ||
47 | |||
48 | Options: | ||
49 | -h Display this help message and exit | ||
50 | EOF | ||
51 | } | ||
52 | |||
53 | # Look for the changelog | ||
54 | if (! -e "ChangeLog") | ||
55 | { | ||
56 | die("Cannot find ChangeLog anywhere! " . | ||
57 | "Are you in the source code tree?"); | ||
58 | } | ||
59 | |||
60 | if ( -e "ChangeLog.dch" ) { | ||
61 | die("The backup file ChangeLog.dch already exists --\n" . | ||
62 | "please move it before trying again"); | ||
63 | } else { | ||
64 | $tmpchk=1; | ||
65 | } | ||
66 | |||
67 | sub BEGIN { | ||
68 | # Initialise the variable | ||
69 | $tmpchk=0; | ||
70 | } | ||
71 | |||
72 | sub END { | ||
73 | unlink "ChangeLog.dch" or | ||
74 | warn "Could not remove ChangeLog.dch" | ||
75 | if $tmpchk; | ||
76 | } | ||
77 | |||
78 | open S, "ChangeLog" or fatal "Cannot open ChangeLog:" . " $!"; | ||
79 | open O, ">ChangeLog.dch" | ||
80 | or fatal "Cannot write to temporary file:" . " $!"; | ||
81 | |||
82 | getopts('h') | ||
83 | or die sprintf | ||
84 | ("Usage: %s [-h] [changelog entry]\n", $progname); | ||
85 | if ($opt_h) { usage(); exit(0); } | ||
86 | |||
87 | # Get a possible changelog entry from the command line | ||
88 | $SAVETEXT=$TEXT="@ARGV"; | ||
89 | |||
90 | # Get the date | ||
91 | chomp($DATE=`822-date`); | ||
92 | |||
93 | $MAINTAINER = $ENV{'CVS_FULLNAME'} || $MAINTAINER; | ||
94 | if ($MAINTAINER eq '') { | ||
95 | fatal "Could not figure out maintainer's name:" . " $!"; | ||
96 | } | ||
97 | $EMAIL = $ENV{'CVS_EMAIL'} || $ENV{'EMAIL'} || $EMAIL; | ||
98 | if ($EMAIL eq '') { | ||
99 | fatal "Could not figure out maintainer's email address:" . " $!"; | ||
100 | } | ||
101 | |||
102 | print O "$MAINTAINER <$EMAIL> $DATE\n\n"; | ||
103 | if ($TEXT) { write O } else { print O " * \n\n"; $line=3; } | ||
104 | # Rewind the current changelog to the beginning of the file | ||
105 | seek S,0,0 or fatal "Couldn't rewind ChangeLog:" . " $!"; | ||
106 | # Copy the rest of the changelog file to new one | ||
107 | while (<S>) { print O; } | ||
108 | |||
109 | close S or fatal "Error closing ChangeLog:" . " $!"; | ||
110 | close O or fatal "Error closing temporary ChangeLog:" . " $!"; | ||
111 | |||
112 | # Now Run the Editor | ||
113 | if (! $SAVETEXT) { | ||
114 | $EDITOR=$ENV{"EDITOR"} || $ENV{"VISUAL"} || '/usr/bin/editor'; | ||
115 | system("$EDITOR +$line ChangeLog.dch") / 256 == 0 or | ||
116 | fatal "Error editing the ChangeLog:" . " $!"; | ||
117 | } | ||
118 | |||
119 | copy("ChangeLog.dch","ChangeLog") or | ||
120 | fatal "Couldn't replace ChangeLog with new ChangeLog:" . " $!"; | ||
121 | |||
122 | # Format for standard ChangeLogs | ||
123 | format O = | ||
124 | * ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
125 | $TEXT | ||
126 | |||
127 | ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< | ||
128 | $TEXT | ||
129 | . | ||
130 | |||
131 | sub fatal($) { | ||
132 | my ($pack,$file,$line); | ||
133 | ($pack,$file,$line) = caller(); | ||
134 | (my $msg = sprintf("%s: fatal error at line %d:\n", | ||
135 | $progname, $line) . "@_\n") =~ tr/\0//d; | ||
136 | $msg =~ s/\n\n$/\n/; | ||
137 | die $msg; | ||
138 | } | ||
139 |
-
Please register or sign in to post a comment