This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regression test for 34394ecd - SVs that were only on the tmps stack leaked.
[perl5.git] / Porting / makerel
CommitLineData
23b3bd7f 1#!/usr/bin/perl -w
08aa1457 2
63d690b1 3# A tool to build a perl release tarball
08aa1457 4# Very basic but functional - if you're on a unix system.
08aa1457 5#
e8c01f92
SH
6# If you're on Win32 then it should still work, but various Unix command-line
7# tools will need to be available somewhere. An obvious choice is to install
8# Cygwin and ensure its 'bin' folder is on the PATH in the shell where you run
9# this script. The Cygwin 'bin' folder needs to precede the Windows 'system32'
10# folder so that Cygwin's 'find' command is found in preference to the Windows
11# 'find' command. Your Cygwin installation will need to contain at least the
12# 'cpio' command, in addition to the commands installed by default, and it will
13# also be useful to have 'curl' and 'diffstat' installed too for later stages
14# of the release process (namely, Porting\corelist.pl and generating the commit
15# statistics for the perlXYZdelta.pod file respectively). Finally, ensure that
16# the 'awk' and 'shasum' commands are copies of gawk.exe and sha1sum.exe
17# respectively, rather the links to them that only work in a Cygwin bash shell
18# which they are by default.
19#
08aa1457 20# No matter how automated this gets, you'll always need to read
63d690b1
JV
21# and re-read pumpkin.pod and release_managers_guide.pod to
22# check for things to be done at various stages of the process.
08aa1457 23#
24# Tim Bunce, June 1997
25
26use ExtUtils::Manifest qw(fullcheck);
5f244db9
DM
27$ExtUtils::Manifest::Quiet = 1;
28use Getopt::Std;
08aa1457 29
30$|=1;
5f244db9
DM
31
32sub usage { die <<EOF; }
85bdf03b 33usage: $0 [ -r rootdir ] [-s suffix ] [ -b ]
5f244db9
DM
34 -r rootdir directory under which to create the build dir and tarball
35 defaults to '..'
36 -s suffix suffix to append to to the perl-x.y.z dir and tarball name
37 defaults to the concatenaion of the local_patches entry
38 in patchlevel.h (or blank, if none)
85bdf03b 39 -b make a .bz2 file in addtion to a .gz file
5f244db9
DM
40EOF
41
42my %opts;
85bdf03b 43getopts('br:s:', \%opts) or usage;
5f244db9
DM
44@ARGV && usage;
45
46$relroot = defined $opts{r} ? $opts{r} : "..";
08aa1457 47
48die "Must be in root of the perl source tree.\n"
49 unless -f "./MANIFEST" and -f "patchlevel.h";
50
3ffabb8c
GS
51open PATCHLEVEL,"<patchlevel.h" or die;
52my @patchlevel_h = <PATCHLEVEL>;
53close PATCHLEVEL;
d4257220 54my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;
08aa1457 55print $patchlevel_h;
93136620 56$revision = $1 if $patchlevel_h =~ /PERL_REVISION\s+(\d+)/;
d4257220
GS
57$patchlevel = $1 if $patchlevel_h =~ /PERL_VERSION\s+(\d+)/;
58$subversion = $1 if $patchlevel_h =~ /PERL_SUBVERSION\s+(\d+)/;
55d729e4 59die "Unable to parse patchlevel.h" unless $subversion >= 0;
93136620 60$vers = sprintf("%d.%d.%d", $revision, $patchlevel, $subversion);
08aa1457 61
3ffabb8c
GS
62# fetch list of local patches
63my (@local_patches, @lpatch_tags, $lpatch_tags);
64@local_patches = grep { /^static.*local_patches/../^};/ } @patchlevel_h;
65@local_patches = grep { !/^\s*,?NULL/ } @local_patches;
66@lpatch_tags = map { /^\s*,"(\w+)/ } @local_patches;
67$lpatch_tags = join "-", @lpatch_tags;
68
2a7df08c 69$perl = "perl-$vers";
f27ffc4a 70$reldir = "$perl";
5f244db9
DM
71
72$lpatch_tags = $opts{s} if defined $opts{s};
3ffabb8c 73$reldir .= "-$lpatch_tags" if $lpatch_tags;
08aa1457 74
f27ffc4a 75print "\nMaking a release for $perl in $relroot/$reldir\n\n";
08aa1457 76
08aa1457 77print "Cross-checking the MANIFEST...\n";
78($missfile, $missentry) = fullcheck();
37d29c6f
NC
79@$missentry
80 = grep {$_ !~ m!^\.git/! and $_ !~ m!(?:/|^)\.gitignore!} @$missentry;
9b05e874
JV
81if (@$missfile ) {
82 warn "Can't make a release with MANIFEST files missing:\n";
83 warn "\t".$_."\n" for (@$missfile);
84}
85if (@$missentry ) {
86 warn "Can't make a release with files not listed in MANIFEST\n";
87 warn "\t".$_."\n" for (@$missentry);
88
89}
90248788
TB
90if ("@$missentry" =~ m/\.orig\b/) {
91 # Handy listing of find command and .orig files from patching work.
92 # I tend to run 'xargs rm' and copy and paste the file list.
93 my $cmd = "find . -name '*.orig' -print";
94 print "$cmd\n";
95 system($cmd);
96}
3e3baf6d 97die "Aborted.\n" if @$missentry or @$missfile;
08aa1457 98print "\n";
99
b59922b7 100# VMS no longer has hardcoded version numbers descrip.mms
48e117bb
GS
101
102print "Creating $relroot/$reldir release directory...\n";
103die "$relroot/$reldir release directory already exists\n" if -e "$relroot/$reldir";
104die "$relroot/$reldir.tar.gz release file already exists\n" if -e "$relroot/$reldir.tar.gz";
105mkdir("$relroot/$reldir", 0755) or die "mkdir $relroot/$reldir: $!\n";
106print "\n";
107
108
109print "Copying files to release directory...\n";
110# ExtUtils::Manifest maniread does not preserve the order
111$cmd = "awk '{print \$1}' MANIFEST | cpio -pdm $relroot/$reldir";
86cd7d77
JH
112system($cmd) == 0
113 or die "$cmd failed";
48e117bb
GS
114print "\n";
115
6e24577b 116chdir "$relroot/$reldir" or die $!;
48e117bb 117
d38b68fe
JV
118
119my $SEARCH_ROOTS = 't ext lib dist cpan';
120
08aa1457 121print "Setting file permissions...\n";
bf955a65
GS
122system("find . -type f -print | xargs chmod 0444");
123system("find . -type d -print | xargs chmod 0755");
d38b68fe
JV
124system("find $SEARCH_ROOTS -name '*.t' -print | xargs chmod +x");
125system("find $SEARCH_ROOTS -name 'test.pl' -print | xargs chmod +x");
48e117bb 126my @exe = qw(
08aa1457 127 Configure
128 configpm
b907dc6d 129 configure.gnu
08aa1457 130 embed.pl
131 installperl
132 installman
133 keywords.pl
08aa1457 134 opcode.pl
08aa1457 135 t/TEST
08aa1457 136 *.SH
08aa1457 137 vms/ext/filespec.t
08aa1457 138 x2p/*.SH
bb304ec8
JH
139 Porting/findrfuncs
140 Porting/genlog
08aa1457 141 Porting/makerel
bb304ec8 142 Porting/*.pl
e619572c
JH
143 mpeix/nm
144 mpeix/relink
26e23ede
JH
145 Cross/generate_config_sh
146 Cross/warp
08aa1457 147);
86cd7d77
JH
148system("chmod +x @exe") == 0
149 or die "system: $!";
6e24577b 150
f7f713ed 151my @writables = qw(
f3513db0
JH
152 NetWare/config_H.wc
153 NetWare/Makefile
ac634a9a
JH
154 keywords.h
155 opcode.h
156 opnames.h
157 pp_proto.h
158 pp.sym
159 proto.h
f7f713ed
GS
160 embed.h
161 embedvar.h
f7f713ed 162 global.sym
e9e0c7d0
NC
163 overload.c
164 overload.h
ac634a9a
JH
165 perlapi.h
166 perlapi.c
b2861970
NC
167 cpan/Devel-PPPort/module2.c
168 cpan/Devel-PPPort/module3.c
e9e0c7d0
NC
169 reentr.c
170 reentr.h
171 regcharclass.h
f7f713ed 172 regnodes.h
0ebdc6d5 173 warnings.h
ac634a9a 174 lib/warnings.pm
ac634a9a 175 win32/Makefile
f78a30ba 176 win32/Makefile.ce
ac634a9a
JH
177 win32/makefile.mk
178 win32/config_H.bc
f29c64d6 179 win32/config_H.gc
f7f713ed 180 win32/config_H.vc
61190116 181 utils/Makefile
18b94d96 182 uconfig.h
f7f713ed 183);
86cd7d77
JH
184system("chmod +w @writables") == 0
185 or die "system: $!";
f7f713ed 186
6e24577b
GS
187chdir ".." or die $!;
188
f27ffc4a 189my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch
85bdf03b
DM
190
191print "Creating and compressing the tar.gz file...\n";
3ffabb8c 192$cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
85bdf03b 193system($cmd) == 0 or die "$cmd failed";
08aa1457 194
85bdf03b
DM
195if ($opts{b}) {
196 print "Creating and compressing the tar.bz2 file...\n";
197 $cmd = "tar cf - $reldir | bzip2 > $reldir.tar.bz2";
198 system($cmd) == 0 or die "$cmd failed";
199}
200
201print "\n";
9b05e874 202
ecc9c9d9
DM
203system("ls -ld $perl*");
204print "\n";
205
e8c01f92 206my $null = $^O eq 'MSWin32' ? 'NUL' : '/dev/null';
ecc9c9d9 207for my $sha (qw(sha1 shasum sha1sum)) {
e8c01f92 208 if (`which $sha 2>$null`) {
ecc9c9d9
DM
209 system("$sha $perl*.tar.*");
210 last;
211 }
9b05e874 212}