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