forked from alewando/XMLTV
-
Notifications
You must be signed in to change notification settings - Fork 3
/
mkdist
executable file
·288 lines (245 loc) · 8.71 KB
/
mkdist
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/usr/bin/perl -w
#
# $Id$
#
# This script is meant to be run in an empty directory, although
# it doesn't require it.
#
# This script checks out the latest head revision (by checking it out
# from scratch), checks version information in files, ignores
# files/dirs we don't want to release, tags the source files in cvs,
# generates a ChangeLog and generates the .tar.bz2 file for release.
# Then it uploads this file to upload.sourceforge.net.
#
# It DOES NOT: add the file to the XMLTV project, or email
# announcements, or update www pages, although it reminds you to do
# so :)
#
# -- [email protected]
#
use strict;
use File::Temp qw(tempdir);
use Getopt::Long;
use Date::Manip;
#$SIG{__WARN__} = sub { die $_[0] };
my $debug;
my $cvs_host = 'xmltv.cvs.sourceforge.net';
my $tmp_checkout_dir = tempdir;
sub Usage()
{
print "mkdist --version <id> [options]\n";
print "where options are:\n";
print " --version <id> - creating version <id> (eg 0.1.2)\n";
print " --sfuser <login> - sourceforge login with cvs access\n";
print " defaults to first xmltv login in ~/.cvspass\n";
print " --help - this usage message\n";
print " --debug - print debug messages as we go\n";
print " --login - perform cvs login to refresh/verify cvs access\n";
print " --step - step by step confirmation of commands\n";
}
our ($opt_help, $opt_debug, $opt_sfuser, $opt_login, $opt_version, $opt_step);
if ( ! GetOptions('help', 'debug', 'sfuser=s', 'login', 'version=s', 'step') ) {
Usage();
exit(1);
}
if ( defined($opt_help) ) {
Usage();
exit(0);
}
$debug=1 if ( defined($opt_debug) );
# Mimic Perl's system() in allowing either a single argument
# or a list of parameters (which means don't use the shell).
#
sub do_system(@)
{
if ($opt_step) {
print "@_ [yN]? ";
my $reply = <STDIN>;
return if $reply !~ /^[yY]/;
}
print "@_\n";
my $rc=system(@_);
if ( $rc != 0 ) {
die "command failed: $rc";
}
}
if ( !defined($opt_version) ) {
print STDERR "missing required argument --version, use --help for details\n";
exit(1);
}
if ( !defined($opt_sfuser) ) {
if ( open(FD, "< $ENV{HOME}/.cvspass") ) {
while (<FD>) {
if ( m/^:pserver:([^\@]+)\@$cvs_host:/o ) {
$opt_sfuser=$1;
print "assuming --sfuser $1 from first xmltv entry in ~/.cvspass\n";
last;
}
}
close(FD);
if ( !defined($opt_sfuser) ) {
print STDERR "failed to locate any appropriate entry in ~/.cvspass\n";
}
}
else {
print STDERR "failed to locate any appropriate entry in ~/.cvspass\n";
}
if ( !defined($opt_sfuser) ) {
print STDERR "missing required argument --sfuser, use --help for details\n";
exit(1);
}
}
print "Did you update the README and README.win32 files with release information?\n";
print "hit return to continue with mkdist, or ^C to stop here.";
my $junk=<>; # read return
print "opt_version=\"$opt_version\"\n" if ( $debug );
#if ( !($opt_version=~m/^\d+\.\d+$/o) && !($opt_version=~m/^\d+\.\d+\.\d+$/o) ) {
# print STDERR "invalid version id, specify something of the form \"[0-9].[0-9]\" or \"[0-9].[0-9].[0-9]\"\n";;
# exit(1);
#}
my $cvs_tag="V$opt_version";
$cvs_tag=~s/\./_/og;
print "version tag to use is: $cvs_tag\n" if ( $opt_debug );
# always use ssh for cvs access
$ENV{CVS_RSH}="ssh";
if ( defined($opt_login) ) {
# use pserver to login. FIXME Does Sourceforge support
# authenticated pserver? I thought it was anonymous only.
#
$ENV{CVSROOT}=":pserver:$opt_sfuser\@$cvs_host:/cvsroot/xmltv";
do_system("cvs login");
}
print "\nChecking out current head revision in $tmp_checkout_dir/xmltv ..\n";
chdir $tmp_checkout_dir or die "could not chdir to $tmp_checkout_dir: $!";
$ENV{CVS_RSH} = 'ssh';
$ENV{CVSROOT} = ":ext:$opt_sfuser\@$cvs_host:/cvsroot/xmltv";
do_system("cvs -z7 -q co -P xmltv");
# Filename, and a regexp to capture the version in $1.
my %check_ver = ('README' => q{^XMLTV\s+([^, ]+)},
'doc/README.win32' => q{^XMLTV\s+([^, ]+)},
'Makefile.PL' => q{^(?:(?:our|my) )?\$VERSION\s*=\s*'(\S+)';},
'lib/XMLTV.pm.in' => q{^(?:(?:our|my) )?\$VERSION\s*=\s*'(\S+)';},
'lib/exe_wrap.pl' => q{^(?:(?:our|my) )?\$VERSION\s*=\s*'(\S+)';},
);
foreach my $f (keys %check_ver) {
my $re = $check_ver{$f};
$f = "$tmp_checkout_dir/xmltv/$f";
open(FD, $f) || die "cannot open $f: $!";
my $got;
while (<FD>) {
chomp;
if (/$re/) {
$got = $1; die if not defined $got;
if ($got ne $opt_version) {
# I think it's better not to do anything clever, but
# just let the user update the file. -- epa
die "$f:$.:found version $got, not $opt_version\n";
}
else { last }
}
}
if (not defined $got) {
die "could not find version number in $f\n";
}
close FD or die "cannot close $f: $!";
print "Version number in $f is correct.\n";
}
# Another check on README - that the date is correct.
my $readme_f = "$tmp_checkout_dir/xmltv/README";
open(FD, $readme_f) or die "cannot open $readme_f: $!";
my $found = 0;
while (<FD>) {
if (/^-- .+ (\d{4}-\d\d-\d\d)/) {
$found = 1;
my $date = UnixDate(ParseDate($1), '%Y-%m-%d');
die "bad date $1 in README" if not $date;
my $today = UnixDate(ParseDate('now'), '%Y-%m-%d');
die if not $today;
die "date in README ($date) is not today ($today),\n"
. " update the signature with date and your name\n"
if $date ne $today;
}
}
die "no signature found in README" if not $found;
close FD or die "cannot close $readme_f: $!";
print "\nremoving old tag $cvs_tag just in case\n";
do_system("cvs -z3 -q tag -d \"$cvs_tag\"");
my @toremove=grep { -e "$tmp_checkout_dir/$_"
|| (warn("$_ missing, but no matter\n"), 0) }
map { "xmltv/$_" }
qw(attic
leon
cgi
todo
MANIFEST.SKIP
mkdist
ChangeLog.old);
my $cmd="tar cf save.tar ";
for my $f (@toremove) { $cmd.="$f "; }
$cmd.="`find xmltv -name CVS -type d`";
$cmd.=" `find xmltv -name .cvsignore -type f`";
print "\ntemporarily removing files/dirs not for release..\n";
do_system($cmd);
# take easy route :)
do_system('rm', '-rf', map { "$tmp_checkout_dir/$_" } @toremove);
print "\ngenerating ChangeLog..\n";
do_system("cd xmltv && cvs2cl --utc");
print "\ntagging release with $cvs_tag..\n";
do_system("cd xmltv && cvs -z3 -q tag \"$cvs_tag\"");
print "\nremoving CVS dirs..\n";
do_system("find xmltv -name CVS -type d -prune -exec rm -rf {} \\;");
print "\nrenaming xmltv directory to xmltv-$opt_version..\n";
rename("xmltv", "xmltv-$opt_version");
# The tarball we generate and upload.
mkdir $opt_version;
my $filename = "xmltv-$opt_version.tar.bz2";
print "\n";
# 'tar --bzip2' appends useless junk to the compressed data.
do_system("tar c ./xmltv-$opt_version | bzip2 >$opt_version/$filename");
do_system("cp xmltv-$opt_version/README $opt_version");
print "\n";
# FIXME do we need this if working in a separate checkout dir?
#print "\nrestoring files that won't be released..\n";
#rename("xmltv-$opt_version", "xmltv");
#unlink("xmltv/ChangeLog");
#do_system("tar xpf save.tar");
#unlink("save.tar");
print "\nuploading tempdir $filename to frs.sourceforge.net..\n";
print "scp $filename $opt_sfuser,xmltv\@frs.sourceforge.net:/home/frs/project/x/xm/xmltv/xmltv/$opt_version/\n";
do_system( "scp -r $opt_version $opt_sfuser,xmltv\@frs.sourceforge.net:/home/frs/project/x/xm/xmltv/xmltv/");
#do_system("cd xmltv; scp README $opt_sfuser,xmltv\@frs.sourceforge.net:/home/frs/project/x/xm/xmltv/xmltv/$opt_version/");
print <<END
**** File $filename uploaded to upload.sourceforge.net
To register this file as part of the release:
- Go to
< https://sourceforge.net/project/admin/explorer.php?group_id=39046 >
(login may be required)
- change folder to xmltv/$opt_version
click on files to select appropriate attributes
Step 1
------
- change status to "Hidden" (for now)
In the release page, paste the README in as 'release notes', apart
from the 'changes in this release' section of the README, which
goes in the 'changelog' box,
NOTE: check the 'Preserve my pre-formatted text. ' box
then click 'Submit/Refresh'
<page refreshes>
Step 2
------
- choose $filename, then click
'Add Files and/or Refresh View' button
<page refreshes>
Step 3
------
- set the platform 'Any' and type 'Source bz2'
- hit 'update' button
- Toggle 'Status' in Step 1 to 'Active' and hit 'Submit/Refresh' button
at the bottom of Step 1.
< how hit 'Summary' button at top of page, you should see release
show up >
Now update the XMLTV wiki.
Send a release announcement to xmltv-announce\@lists.sourceforge.net,
and update the Freshmeat entry <http://freshmeat.net/projects/xmltv/?topic_id=868>.
END
;