makerel revision 1.6
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
14$|=1;
15$relroot = "..";	# XXX make an option
16
17die "Must be in root of the perl source tree.\n"
18	unless -f "./MANIFEST" and -f "patchlevel.h";
19
20open PATCHLEVEL,"<patchlevel.h" or die;
21my @patchlevel_h = <PATCHLEVEL>;
22close PATCHLEVEL;
23my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h;
24print $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+)/;
28die "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
33my (@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
43print "\nMaking a release for $perl in $relroot/$reldir\n\n";
44
45print "Cross-checking the MANIFEST...\n";
46($missfile, $missentry) = fullcheck();
47warn "Can't make a release with MANIFEST files missing.\n" if @$missfile;
48warn "Can't make a release with files not listed in MANIFEST.\n" if @$missentry;
49if ("@$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}
56die "Aborted.\n" if @$missentry or @$missfile;
57print "\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
65print "Creating $relroot/$reldir release directory...\n";
66die "$relroot/$reldir release directory already exists\n"   if -e "$relroot/$reldir";
67die "$relroot/$reldir.tar.gz release file already exists\n" if -e "$relroot/$reldir.tar.gz";
68mkdir("$relroot/$reldir", 0755) or die "mkdir $relroot/$reldir: $!\n";
69print "\n";
70
71
72print "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";
75system($cmd) == 0
76    or die "$cmd failed";
77print "\n";
78
79chdir "$relroot/$reldir" or die $!;
80
81print "Setting file permissions...\n";
82system("find . -type f -print     | xargs chmod 0444");
83system("find . -type d -print     | xargs chmod 0755");
84system("find t ext lib -name '*.t'     -print | xargs chmod +x");
85system("find t ext lib -name 'test.pl' -print | xargs chmod +x");
86my @exe = qw(
87    Configure
88    configpm
89    configure.gnu
90    embed.pl
91    installperl
92    installman
93    keywords.pl
94    opcode.pl
95    perly.fixer
96    t/TEST
97    *.SH
98    vms/ext/Stdio/test.pl
99    vms/ext/filespec.t
100    x2p/*.SH
101    Porting/findrfuncs
102    Porting/genlog
103    Porting/makerel
104    Porting/p4genpatch
105    Porting/patchls
106    Porting/*.pl
107    mpeix/nm
108    mpeix/relink
109    Cross/generate_config_sh
110    Cross/warp
111);
112system("chmod +x @exe") == 0
113    or die "system: $!";
114
115my @writables = qw(
116    NetWare/config_H.wc
117    NetWare/Makefile
118    keywords.h
119    opcode.h
120    opnames.h
121    pp_proto.h
122    pp.sym
123    proto.h
124    embed.h
125    embedvar.h
126    global.sym
127    pod/perlintern.pod
128    pod/perlapi.pod
129    perlapi.h
130    perlapi.c
131    ext/ByteLoader/byterun.h
132    ext/ByteLoader/byterun.c
133    ext/B/B/Asmdata.pm
134    ext/Devel/PPPort/PPPort.xs
135    ext/Devel/PPPort/module2.c
136    ext/Devel/PPPort/module3.c
137    regnodes.h
138    warnings.h
139    lib/warnings.pm
140    vms/perly_c.vms
141    vms/perly_h.vms
142    win32/Makefile
143    win32/makefile.mk
144    win32/config_H.bc
145    win32/config_H.gc
146    win32/config_H.vc
147    wince/config_H.ce
148    wince/Makefile.ce
149);
150system("chmod +w @writables") == 0
151    or die "system: $!";
152
153print "Adding CRs to DOSish files...\n";
154my @crlf = qw(
155    djgpp/configure.bat
156    README.ce
157    README.dos
158    README.win32
159    win32/Makefile
160    win32/makefile.mk
161    wince/Makefile.ce
162    wince/compile-all.bat
163    wince/README.perlce
164    wince/registry.bat
165);
166system("perl -pi -e 's/\\015*\\012/\\015\\012/' @crlf") == 0
167    or die "system: $!";
168print "\n";
169
170chdir ".." or die $!;
171
172print "Creating and compressing the tar file...\n";
173my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch
174$cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz";
175system($cmd) == 0
176    or die "$cmd failed";
177print "\n";
178
179system("ls -ld $perl*");
180