This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
MakeMaker is first-come in Maintainers.pl.
[perl5.git] / Porting / makerel
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
12 use ExtUtils::Manifest qw(fullcheck);
13
14 $|=1;
15 $relroot = "..";        # XXX make an option
16
17 die "Must be in root of the perl source tree.\n"
18         unless -f "./MANIFEST" and -f "patchlevel.h";
19
20 open PATCHLEVEL,"<patchlevel.h" or die;
21 my @patchlevel_h = <PATCHLEVEL>;
22 close PATCHLEVEL;
23 my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;
24 print $patchlevel_h;
25 $revision = $1 if $patchlevel_h =~ /PERL_REVISION\s+(\d+)/;
26 $patchlevel = $1 if $patchlevel_h =~ /PERL_VERSION\s+(\d+)/;
27 $subversion = $1 if $patchlevel_h =~ /PERL_SUBVERSION\s+(\d+)/;
28 die "Unable to parse patchlevel.h" unless $subversion >= 0;
29 $vers = sprintf("%d.%d.%d", $revision, $patchlevel, $subversion);
30
31 # fetch list of local patches
32 my (@local_patches, @lpatch_tags, $lpatch_tags);
33 @local_patches = grep { /^static.*local_patches/../^};/ } @patchlevel_h;
34 @local_patches = grep { !/^\s*,?NULL/  } @local_patches;
35 @lpatch_tags   = map  {  /^\s*,"(\w+)/ } @local_patches;
36 $lpatch_tags   = join "-", @lpatch_tags;
37
38 $perl = "perl-$vers";
39 $reldir = "$perl";
40 $reldir .= "-$lpatch_tags" if $lpatch_tags;
41
42 print "\nMaking a release for $perl in $relroot/$reldir\n\n";
43
44 print "Cross-checking the MANIFEST...\n";
45 ($missfile, $missentry) = fullcheck();
46 @$missentry
47     = grep {$_ !~ m!^\.git/! and $_ !~ m!(?:/|^)\.gitignore!} @$missentry;
48 warn "Can't make a release with MANIFEST files missing.\n" if @$missfile;
49 warn "Can't make a release with files not listed in MANIFEST.\n" if @$missentry;
50 if ("@$missentry" =~ m/\.orig\b/) {
51     # Handy listing of find command and .orig files from patching work.
52     # I tend to run 'xargs rm' and copy and paste the file list.
53     my $cmd = "find . -name '*.orig' -print";
54     print "$cmd\n";
55     system($cmd);
56 }
57 die "Aborted.\n" if @$missentry or @$missfile;
58 print "\n";
59
60 # VMS no longer has hardcoded version numbers descrip.mms
61
62 print "Creating $relroot/$reldir release directory...\n";
63 die "$relroot/$reldir release directory already exists\n"   if -e "$relroot/$reldir";
64 die "$relroot/$reldir.tar.gz release file already exists\n" if -e "$relroot/$reldir.tar.gz";
65 mkdir("$relroot/$reldir", 0755) or die "mkdir $relroot/$reldir: $!\n";
66 print "\n";
67
68
69 print "Copying files to release directory...\n";
70 # ExtUtils::Manifest maniread does not preserve the order
71 $cmd = "awk '{print \$1}' MANIFEST | cpio -pdm $relroot/$reldir";
72 system($cmd) == 0
73     or die "$cmd failed";
74 print "\n";
75
76 chdir "$relroot/$reldir" or die $!;
77
78 print "Setting file permissions...\n";
79 system("find . -type f -print     | xargs chmod 0444");
80 system("find . -type d -print     | xargs chmod 0755");
81 system("find t ext lib -name '*.t'     -print | xargs chmod +x");
82 system("find t ext lib -name 'test.pl' -print | xargs chmod +x");
83 my @exe = qw(
84     Configure
85     configpm
86     configure.gnu
87     embed.pl
88     installperl
89     installman
90     keywords.pl
91     opcode.pl
92     t/TEST
93     *.SH
94     vms/ext/Stdio/test.pl
95     vms/ext/filespec.t
96     x2p/*.SH
97     Porting/findrfuncs
98     Porting/genlog
99     Porting/makerel
100     Porting/*.pl
101     mpeix/nm
102     mpeix/relink
103     Cross/generate_config_sh
104     Cross/warp
105 );
106 system("chmod +x @exe") == 0
107     or die "system: $!";
108
109 my @writables = qw(
110     NetWare/config_H.wc
111     NetWare/Makefile
112     keywords.h
113     opcode.h
114     opnames.h
115     pp_proto.h
116     pp.sym
117     proto.h
118     embed.h
119     embedvar.h
120     global.sym
121     overload.c
122     overload.h
123     pod/perlintern.pod
124     pod/perlapi.pod
125     pod/perltoc.pod
126     perlapi.h
127     perlapi.c
128     ext/Devel-PPPort/module2.c
129     ext/Devel-PPPort/module3.c
130     reentr.c
131     reentr.h
132     regcharclass.h
133     regnodes.h
134     warnings.h
135     lib/warnings.pm
136     win32/Makefile
137     win32/Makefile.ce
138     win32/makefile.mk
139     win32/config_H.bc
140     win32/config_H.gc
141     win32/config_H.vc
142     utils/Makefile
143     uconfig.h
144 );
145 system("chmod +w @writables") == 0
146     or die "system: $!";
147
148 print "Adding CRs to DOSish files...\n";
149 # This list is also in curliff.pl.
150 my @crlf = qw(
151     djgpp/configure.bat
152     README.ce
153     README.dos
154     README.symbian
155     README.win32
156     symbian/config.pl
157     symbian/makesis.pl
158     symbian/README
159     symbian/xsbuild.pl
160     win32/Makefile
161     win32/Makefile.ce
162     win32/ce-helpers/compile-all.bat
163     win32/ce-helpers/compile.bat
164     win32/ce-helpers/registry.bat
165     win32/distclean.bat
166     win32/makefile.mk
167 );
168 system("perl -pi -e 's/\\015*\\012/\\015\\012/' @crlf") == 0
169     or die "system: $!";
170 print "\n";
171
172 chdir ".." or die $!;
173
174 print "Creating and compressing the tar file...\n";
175 my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch
176 $cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
177 system($cmd) == 0
178     or die "$cmd failed";
179 print "\n";
180
181 system("ls -ld $perl*");