Commit | Line | Data |
23b3bd7f |
1 | #!/usr/bin/perl -w |
08aa1457 |
2 | |
63d690b1 |
3 | # A tool to build a perl release tarball |
08aa1457 |
4 | # Very basic but functional - if you're on a unix system. |
08aa1457 |
5 | # |
e8c01f92 |
6 | # If you're on Win32 then it should still work, but various Unix command-line |
7 | # tools will need to be available somewhere. An obvious choice is to install |
8 | # Cygwin and ensure its 'bin' folder is on the PATH in the shell where you run |
9 | # this script. The Cygwin 'bin' folder needs to precede the Windows 'system32' |
10 | # folder so that Cygwin's 'find' command is found in preference to the Windows |
11 | # 'find' command. Your Cygwin installation will need to contain at least the |
12 | # 'cpio' command, in addition to the commands installed by default, and it will |
13 | # also be useful to have 'curl' and 'diffstat' installed too for later stages |
14 | # of the release process (namely, Porting\corelist.pl and generating the commit |
15 | # statistics for the perlXYZdelta.pod file respectively). Finally, ensure that |
16 | # the 'awk' and 'shasum' commands are copies of gawk.exe and sha1sum.exe |
17 | # respectively, rather the links to them that only work in a Cygwin bash shell |
18 | # which they are by default. |
19 | # |
08aa1457 |
20 | # No matter how automated this gets, you'll always need to read |
63d690b1 |
21 | # and re-read pumpkin.pod and release_managers_guide.pod to |
22 | # check for things to be done at various stages of the process. |
08aa1457 |
23 | # |
24 | # Tim Bunce, June 1997 |
25 | |
26 | use ExtUtils::Manifest qw(fullcheck); |
5f244db9 |
27 | $ExtUtils::Manifest::Quiet = 1; |
28 | use Getopt::Std; |
08aa1457 |
29 | |
30 | $|=1; |
5f244db9 |
31 | |
32 | sub usage { die <<EOF; } |
1baeb402 |
33 | usage: $0 [ -r rootdir ] [-s suffix ] [ -b ] [ -n ] |
5f244db9 |
34 | -r rootdir directory under which to create the build dir and tarball |
35 | defaults to '..' |
36 | -s suffix suffix to append to to the perl-x.y.z dir and tarball name |
37 | defaults to the concatenaion of the local_patches entry |
38 | in patchlevel.h (or blank, if none) |
85bdf03b |
39 | -b make a .bz2 file in addtion to a .gz file |
1baeb402 |
40 | -n do not make any tarballs, just the directory |
5f244db9 |
41 | EOF |
42 | |
43 | my %opts; |
1baeb402 |
44 | getopts('bnr:s:', \%opts) or usage; |
5f244db9 |
45 | @ARGV && usage; |
46 | |
47 | $relroot = defined $opts{r} ? $opts{r} : ".."; |
08aa1457 |
48 | |
49 | die "Must be in root of the perl source tree.\n" |
50 | unless -f "./MANIFEST" and -f "patchlevel.h"; |
51 | |
3ffabb8c |
52 | open PATCHLEVEL,"<patchlevel.h" or die; |
53 | my @patchlevel_h = <PATCHLEVEL>; |
54 | close PATCHLEVEL; |
d4257220 |
55 | my $patchlevel_h = join "", grep { /^#\s*define/ } @patchlevel_h; |
08aa1457 |
56 | print $patchlevel_h; |
93136620 |
57 | $revision = $1 if $patchlevel_h =~ /PERL_REVISION\s+(\d+)/; |
d4257220 |
58 | $patchlevel = $1 if $patchlevel_h =~ /PERL_VERSION\s+(\d+)/; |
59 | $subversion = $1 if $patchlevel_h =~ /PERL_SUBVERSION\s+(\d+)/; |
55d729e4 |
60 | die "Unable to parse patchlevel.h" unless $subversion >= 0; |
93136620 |
61 | $vers = sprintf("%d.%d.%d", $revision, $patchlevel, $subversion); |
08aa1457 |
62 | |
3ffabb8c |
63 | # fetch list of local patches |
64 | my (@local_patches, @lpatch_tags, $lpatch_tags); |
65 | @local_patches = grep { /^static.*local_patches/../^};/ } @patchlevel_h; |
66 | @local_patches = grep { !/^\s*,?NULL/ } @local_patches; |
67 | @lpatch_tags = map { /^\s*,"(\w+)/ } @local_patches; |
68 | $lpatch_tags = join "-", @lpatch_tags; |
69 | |
2a7df08c |
70 | $perl = "perl-$vers"; |
f27ffc4a |
71 | $reldir = "$perl"; |
5f244db9 |
72 | |
73 | $lpatch_tags = $opts{s} if defined $opts{s}; |
3ffabb8c |
74 | $reldir .= "-$lpatch_tags" if $lpatch_tags; |
08aa1457 |
75 | |
f27ffc4a |
76 | print "\nMaking a release for $perl in $relroot/$reldir\n\n"; |
08aa1457 |
77 | |
08aa1457 |
78 | print "Cross-checking the MANIFEST...\n"; |
79 | ($missfile, $missentry) = fullcheck(); |
37d29c6f |
80 | @$missentry |
81 | = grep {$_ !~ m!^\.git/! and $_ !~ m!(?:/|^)\.gitignore!} @$missentry; |
9b05e874 |
82 | if (@$missfile ) { |
83 | warn "Can't make a release with MANIFEST files missing:\n"; |
84 | warn "\t".$_."\n" for (@$missfile); |
85 | } |
86 | if (@$missentry ) { |
87 | warn "Can't make a release with files not listed in MANIFEST\n"; |
88 | warn "\t".$_."\n" for (@$missentry); |
89 | |
90 | } |
90248788 |
91 | if ("@$missentry" =~ m/\.orig\b/) { |
92 | # Handy listing of find command and .orig files from patching work. |
93 | # I tend to run 'xargs rm' and copy and paste the file list. |
94 | my $cmd = "find . -name '*.orig' -print"; |
95 | print "$cmd\n"; |
96 | system($cmd); |
97 | } |
3e3baf6d |
98 | die "Aborted.\n" if @$missentry or @$missfile; |
08aa1457 |
99 | print "\n"; |
100 | |
b59922b7 |
101 | # VMS no longer has hardcoded version numbers descrip.mms |
48e117bb |
102 | |
103 | print "Creating $relroot/$reldir release directory...\n"; |
104 | die "$relroot/$reldir release directory already exists\n" if -e "$relroot/$reldir"; |
105 | die "$relroot/$reldir.tar.gz release file already exists\n" if -e "$relroot/$reldir.tar.gz"; |
106 | mkdir("$relroot/$reldir", 0755) or die "mkdir $relroot/$reldir: $!\n"; |
107 | print "\n"; |
108 | |
109 | |
110 | print "Copying files to release directory...\n"; |
111 | # ExtUtils::Manifest maniread does not preserve the order |
112 | $cmd = "awk '{print \$1}' MANIFEST | cpio -pdm $relroot/$reldir"; |
86cd7d77 |
113 | system($cmd) == 0 |
114 | or die "$cmd failed"; |
48e117bb |
115 | print "\n"; |
116 | |
6e24577b |
117 | chdir "$relroot/$reldir" or die $!; |
48e117bb |
118 | |
d38b68fe |
119 | |
120 | my $SEARCH_ROOTS = 't ext lib dist cpan'; |
121 | |
08aa1457 |
122 | print "Setting file permissions...\n"; |
bf955a65 |
123 | system("find . -type f -print | xargs chmod 0444"); |
124 | system("find . -type d -print | xargs chmod 0755"); |
d38b68fe |
125 | system("find $SEARCH_ROOTS -name '*.t' -print | xargs chmod +x"); |
126 | system("find $SEARCH_ROOTS -name 'test.pl' -print | xargs chmod +x"); |
48e117bb |
127 | my @exe = qw( |
08aa1457 |
128 | Configure |
129 | configpm |
b907dc6d |
130 | configure.gnu |
08aa1457 |
131 | embed.pl |
132 | installperl |
133 | installman |
134 | keywords.pl |
08aa1457 |
135 | opcode.pl |
08aa1457 |
136 | t/TEST |
08aa1457 |
137 | *.SH |
08aa1457 |
138 | vms/ext/filespec.t |
08aa1457 |
139 | x2p/*.SH |
bb304ec8 |
140 | Porting/findrfuncs |
141 | Porting/genlog |
08aa1457 |
142 | Porting/makerel |
bb304ec8 |
143 | Porting/*.pl |
e619572c |
144 | mpeix/nm |
145 | mpeix/relink |
26e23ede |
146 | Cross/generate_config_sh |
147 | Cross/warp |
08aa1457 |
148 | ); |
86cd7d77 |
149 | system("chmod +x @exe") == 0 |
150 | or die "system: $!"; |
6e24577b |
151 | |
f7f713ed |
152 | my @writables = qw( |
f3513db0 |
153 | NetWare/config_H.wc |
154 | NetWare/Makefile |
ac634a9a |
155 | keywords.h |
156 | opcode.h |
157 | opnames.h |
158 | pp_proto.h |
159 | pp.sym |
160 | proto.h |
f7f713ed |
161 | embed.h |
162 | embedvar.h |
f7f713ed |
163 | global.sym |
e9e0c7d0 |
164 | overload.c |
165 | overload.h |
ac634a9a |
166 | perlapi.h |
167 | perlapi.c |
b2861970 |
168 | cpan/Devel-PPPort/module2.c |
169 | cpan/Devel-PPPort/module3.c |
e9e0c7d0 |
170 | reentr.c |
171 | reentr.h |
172 | regcharclass.h |
f7f713ed |
173 | regnodes.h |
0ebdc6d5 |
174 | warnings.h |
ac634a9a |
175 | lib/warnings.pm |
ac634a9a |
176 | win32/Makefile |
f78a30ba |
177 | win32/Makefile.ce |
ac634a9a |
178 | win32/makefile.mk |
179 | win32/config_H.bc |
f29c64d6 |
180 | win32/config_H.gc |
f7f713ed |
181 | win32/config_H.vc |
61190116 |
182 | utils/Makefile |
18b94d96 |
183 | uconfig.h |
f7f713ed |
184 | ); |
86cd7d77 |
185 | system("chmod +w @writables") == 0 |
186 | or die "system: $!"; |
f7f713ed |
187 | |
6e24577b |
188 | chdir ".." or die $!; |
189 | |
1baeb402 |
190 | exit if $opts{n}; |
191 | |
f27ffc4a |
192 | my $src = (-e $perl) ? $perl : 'perl'; # 'perl' in maint branch |
85bdf03b |
193 | |
194 | print "Creating and compressing the tar.gz file...\n"; |
3ffabb8c |
195 | $cmd = "tar cf - $reldir | gzip --best > $reldir.tar.gz"; |
85bdf03b |
196 | system($cmd) == 0 or die "$cmd failed"; |
08aa1457 |
197 | |
85bdf03b |
198 | if ($opts{b}) { |
199 | print "Creating and compressing the tar.bz2 file...\n"; |
200 | $cmd = "tar cf - $reldir | bzip2 > $reldir.tar.bz2"; |
201 | system($cmd) == 0 or die "$cmd failed"; |
202 | } |
203 | |
204 | print "\n"; |
9b05e874 |
205 | |
ecc9c9d9 |
206 | system("ls -ld $perl*"); |
207 | print "\n"; |
208 | |
e8c01f92 |
209 | my $null = $^O eq 'MSWin32' ? 'NUL' : '/dev/null'; |
ecc9c9d9 |
210 | for my $sha (qw(sha1 shasum sha1sum)) { |
e8c01f92 |
211 | if (`which $sha 2>$null`) { |
ecc9c9d9 |
212 | system("$sha $perl*.tar.*"); |
213 | last; |
214 | } |
9b05e874 |
215 | } |