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