This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
CoreList date placeholder
[perl5.git] / Porting / makerel
... / ...
CommitLineData
1#!/usr/bin/perl -w
2
3# A first attempt at some automated support for making a perl release.
4# Very basic but functional - if you're on a unix system.
5#
6# No matter how automated this gets, you'll always need to read
7# and re-read pumpkin.pod checking for things to be done at various
8# stages of the process.
9#
10# Tim Bunce, June 1997
11
12use ExtUtils::Manifest qw(fullcheck);
13$ExtUtils::Manifest::Quiet = 1;
14use Getopt::Std;
15
16$|=1;
17
18sub usage { die <<EOF; }
19usage: $0 [ -r rootdir ] [-s suffix ] [ -b ]
20 -r rootdir directory under which to create the build dir and tarball
21 defaults to '..'
22 -s suffix suffix to append to to the perl-x.y.z dir and tarball name
23 defaults to the concatenaion of the local_patches entry
24 in patchlevel.h (or blank, if none)
25 -b make a .bz2 file in addtion to a .gz file
26EOF
27
28my %opts;
29getopts('br:s:', \%opts) or usage;
30@ARGV && usage;
31
32$relroot = defined $opts{r} ? $opts{r} : "..";
33
34die "Must be in root of the perl source tree.\n"
35 unless -f "./MANIFEST" and -f "patchlevel.h";
36
37open PATCHLEVEL,"<patchlevel.h" or die;
38my @patchlevel_h = <PATCHLEVEL>;
39close PATCHLEVEL;
40my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;
41print $patchlevel_h;
42$revision = $1 if $patchlevel_h =~ /PERL_REVISION\s+(\d+)/;
43$patchlevel = $1 if $patchlevel_h =~ /PERL_VERSION\s+(\d+)/;
44$subversion = $1 if $patchlevel_h =~ /PERL_SUBVERSION\s+(\d+)/;
45die "Unable to parse patchlevel.h" unless $subversion >= 0;
46$vers = sprintf("%d.%d.%d", $revision, $patchlevel, $subversion);
47
48# fetch list of local patches
49my (@local_patches, @lpatch_tags, $lpatch_tags);
50@local_patches = grep { /^static.*local_patches/../^};/ } @patchlevel_h;
51@local_patches = grep { !/^\s*,?NULL/ } @local_patches;
52@lpatch_tags = map { /^\s*,"(\w+)/ } @local_patches;
53$lpatch_tags = join "-", @lpatch_tags;
54
55$perl = "perl-$vers";
56$reldir = "$perl";
57
58$lpatch_tags = $opts{s} if defined $opts{s};
59$reldir .= "-$lpatch_tags" if $lpatch_tags;
60
61print "\nMaking a release for $perl in $relroot/$reldir\n\n";
62
63print "Cross-checking the MANIFEST...\n";
64($missfile, $missentry) = fullcheck();
65@$missentry
66 = grep {$_ !~ m!^\.git/! and $_ !~ m!(?:/|^)\.gitignore!} @$missentry;
67if (@$missfile ) {
68 warn "Can't make a release with MANIFEST files missing:\n";
69 warn "\t".$_."\n" for (@$missfile);
70}
71if (@$missentry ) {
72 warn "Can't make a release with files not listed in MANIFEST\n";
73 warn "\t".$_."\n" for (@$missentry);
74
75}
76if ("@$missentry" =~ m/\.orig\b/) {
77 # Handy listing of find command and .orig files from patching work.
78 # I tend to run 'xargs rm' and copy and paste the file list.
79 my $cmd = "find . -name '*.orig' -print";
80 print "$cmd\n";
81 system($cmd);
82}
83die "Aborted.\n" if @$missentry or @$missfile;
84print "\n";
85
86# VMS no longer has hardcoded version numbers descrip.mms
87
88print "Creating $relroot/$reldir release directory...\n";
89die "$relroot/$reldir release directory already exists\n" if -e "$relroot/$reldir";
90die "$relroot/$reldir.tar.gz release file already exists\n" if -e "$relroot/$reldir.tar.gz";
91mkdir("$relroot/$reldir", 0755) or die "mkdir $relroot/$reldir: $!\n";
92print "\n";
93
94
95print "Copying files to release directory...\n";
96# ExtUtils::Manifest maniread does not preserve the order
97$cmd = "awk '{print \$1}' MANIFEST | cpio -pdm $relroot/$reldir";
98system($cmd) == 0
99 or die "$cmd failed";
100print "\n";
101
102chdir "$relroot/$reldir" or die $!;
103
104print "Setting file permissions...\n";
105system("find . -type f -print | xargs chmod 0444");
106system("find . -type d -print | xargs chmod 0755");
107system("find t ext lib -name '*.t' -print | xargs chmod +x");
108system("find t ext lib -name 'test.pl' -print | xargs chmod +x");
109my @exe = qw(
110 Configure
111 configpm
112 configure.gnu
113 embed.pl
114 installperl
115 installman
116 keywords.pl
117 opcode.pl
118 t/TEST
119 *.SH
120 vms/ext/Stdio/test.pl
121 vms/ext/filespec.t
122 x2p/*.SH
123 Porting/findrfuncs
124 Porting/genlog
125 Porting/makerel
126 Porting/*.pl
127 mpeix/nm
128 mpeix/relink
129 Cross/generate_config_sh
130 Cross/warp
131);
132system("chmod +x @exe") == 0
133 or die "system: $!";
134
135my @writables = qw(
136 NetWare/config_H.wc
137 NetWare/Makefile
138 keywords.h
139 opcode.h
140 opnames.h
141 pp_proto.h
142 pp.sym
143 proto.h
144 embed.h
145 embedvar.h
146 global.sym
147 overload.c
148 overload.h
149 perlapi.h
150 perlapi.c
151 cpan/Devel-PPPort/module2.c
152 cpan/Devel-PPPort/module3.c
153 reentr.c
154 reentr.h
155 regcharclass.h
156 regnodes.h
157 warnings.h
158 lib/warnings.pm
159 win32/Makefile
160 win32/Makefile.ce
161 win32/makefile.mk
162 win32/config_H.bc
163 win32/config_H.gc
164 win32/config_H.vc
165 utils/Makefile
166 uconfig.h
167);
168system("chmod +w @writables") == 0
169 or die "system: $!";
170
171print "Adding CRs to DOSish files...\n";
172# This list is also in curliff.pl.
173my @crlf = qw(
174 djgpp/configure.bat
175 README.ce
176 README.dos
177 README.symbian
178 README.win32
179 symbian/config.pl
180 symbian/makesis.pl
181 symbian/README
182 symbian/xsbuild.pl
183 win32/Makefile
184 win32/Makefile.ce
185 win32/ce-helpers/compile-all.bat
186 win32/ce-helpers/compile.bat
187 win32/ce-helpers/registry.bat
188 win32/distclean.bat
189 win32/makefile.mk
190);
191system("perl -pi -e 's/\\015*\\012/\\015\\012/' @crlf") == 0
192 or die "system: $!";
193print "\n";
194
195chdir ".." or die $!;
196
197my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch
198
199print "Creating and compressing the tar.gz file...\n";
200$cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
201system($cmd) == 0 or die "$cmd failed";
202
203if ($opts{b}) {
204 print "Creating and compressing the tar.bz2 file...\n";
205 $cmd = "tar cf - $reldir | bzip2 > $reldir.tar.bz2";
206 system($cmd) == 0 or die "$cmd failed";
207}
208
209print "\n";
210
211system("ls -ld $perl*");
212print "\n";
213
214for my $sha (qw(sha1 shasum sha1sum)) {
215 if (`which $sha 2>/dev/null`) {
216 system("$sha $perl*.tar.*");
217 last;
218 }
219}