Commit | Line | Data |
---|---|---|
46c573de | 1 | #!/usr/bin/env perl |
525c441c | 2 | # Copyright (c) The Exim Maintainers 2016-2018 |
3634fc25 | 3 | |
8a483da6 NM |
4 | use strict; |
5 | use warnings; | |
6 | use Carp; | |
525c441c HSHR |
7 | use Cwd qw'abs_path'; |
8 | use File::Basename; | |
9 | use File::Path qw(make_path remove_tree); | |
8f29c950 | 10 | use File::Temp; |
8a483da6 | 11 | use Getopt::Long; |
ba41f854 | 12 | use IO::File; |
8a483da6 | 13 | use Pod::Usage; |
525c441c HSHR |
14 | use if $ENV{DEBUG} => 'Smart::Comments'; |
15 | ||
16 | my $ME = basename $0; | |
17 | ||
8a483da6 NM |
18 | |
19 | my $debug = 0; | |
20 | my $verbose = 0; | |
21 | ||
525c441c HSHR |
22 | # MAJOR.MINOR[.SECURITY[.FIXES]][-RCX] |
23 | # 4 .90 .0 .22 -RC1 | |
24 | my $version_pattern = qr/ | |
25 | (?<release> | |
26 | (?<major>\d) # 4 | |
27 | \.(?<minor>\d\d) # .90 | |
28 | (?:\.(?<security>\d+) # .0 | |
29 | (?:\.(?<fixes>)\d+)?)? # .22 | |
30 | (?:-(?<rc>RC\d+)?)? # -RC1 | |
31 | ) | |
32 | /x; | |
8a483da6 | 33 | |
525c441c | 34 | # ------------------------------------------------------------------ |
8a483da6 | 35 | |
525c441c HSHR |
36 | package Context { |
37 | use strict; # not strictly necessary yet, until in an own package | |
38 | use warnings; # not strictly necessary yet, ... | |
39 | use File::Spec::Functions qw'splitpath catfile catdir splitdir'; | |
40 | use File::Path qw'make_path remove_tree'; | |
41 | use File::Copy; | |
42 | use Cwd qw'abs_path'; | |
43 | use Carp; | |
44 | ||
45 | package PWD { | |
46 | use Cwd; | |
47 | sub TIESCALAR { bless do {\my $x} } | |
48 | sub FETCH { cwd } | |
8a483da6 | 49 | } |
be914e6c | 50 | |
525c441c | 51 | tie my $cwd => 'PWD' or die; |
8a483da6 | 52 | |
525c441c HSHR |
53 | sub new { |
54 | my $class = shift; | |
55 | return bless { @_ } => $class; | |
56 | } | |
8a483da6 | 57 | |
525c441c HSHR |
58 | sub check_version { |
59 | my $context = shift; | |
60 | my $version = shift; | |
8a483da6 | 61 | |
525c441c HSHR |
62 | croak "The given version number does not look right - $version" |
63 | if not $version =~ /$version_pattern/; | |
8a483da6 | 64 | |
525c441c HSHR |
65 | $context->{v}{release} = $+{release}; |
66 | $context->{v}{major} = $+{major}; | |
67 | $context->{v}{minor} = $+{minor}; | |
68 | $context->{v}{security} = $+{security}; | |
69 | $context->{v}{rc} = $+{rc}; | |
8a483da6 | 70 | |
525c441c | 71 | ### v: $context->{v} |
8a483da6 | 72 | |
525c441c HSHR |
73 | # find a valid vcs tag matching the version |
74 | my $pattern = "$context->{pkgname}-$context->{v}{release}" =~ s/[-_.]/[-_.]/gr; | |
75 | chomp(my @tags = qx{git tag --list '$pattern'}); | |
8a483da6 | 76 | |
525c441c HSHR |
77 | croak "The given version is ambigous, tags: @tags\n" if @tags > 1; |
78 | croak "The given version does not exist (no such tag: exim-$version)\n" if @tags == 0; | |
8a483da6 | 79 | |
525c441c | 80 | $context->{git_tag} = $tags[0]; |
46c573de | 81 | |
525c441c HSHR |
82 | # target_release: the release we aim to reach with release candidates |
83 | # FIXME: re-construct from the parsed version number | |
84 | ($context->{v}{target_release} = $context->{v}{release}) =~ s/-RC\d+//; | |
46c573de | 85 | } |
8a483da6 | 86 | |
8a483da6 | 87 | |
525c441c HSHR |
88 | # We prefer gtar to tar if gtar exists in $PATH |
89 | sub override_tar_cmd { | |
90 | my $context = shift; | |
91 | my $tar = $context->{tar_cmd}; | |
8a483da6 | 92 | |
525c441c | 93 | return unless $tar eq 'tar'; |
8a483da6 | 94 | |
525c441c HSHR |
95 | foreach my $d (File::Spec->path()) { |
96 | my $p = catfile($d, 'gtar'); | |
97 | if (-x $p) { | |
98 | $context->{tar_cmd} = $p; | |
99 | print "Switched tar command to: $p\n" if $verbose; | |
100 | return; | |
101 | } | |
102 | } | |
103 | } | |
8a483da6 | 104 | |
525c441c HSHR |
105 | sub prepare_working_directory { |
106 | my $context = shift; | |
107 | my $workspace = $context->{workspace}; | |
8f29c950 | 108 | |
525c441c HSHR |
109 | if (not defined $workspace) { |
110 | $workspace = $context->{workspace} = File::Temp->newdir(File::Spec->tmpdir . '/exim-packaging-XXXX'); | |
111 | } | |
112 | else { | |
113 | # ensure the working directory is not in place | |
114 | if (-e $workspace) { | |
115 | if ($context->{delete}) { | |
116 | print "Deleting existing $workspace\n" if $verbose; | |
117 | remove_tree $workspace, { verbose => $verbose || $debug }; | |
118 | } | |
119 | else { | |
120 | croak "Working directory $workspace exists" if -e $workspace; | |
121 | } | |
122 | } | |
123 | ||
124 | # create base directory | |
125 | make_path( $context->{directory}, { verbose => $verbose || $debug } ); | |
126 | } | |
8f29c950 | 127 | |
525c441c HSHR |
128 | # Set(!) and create subdirectories |
129 | foreach (qw(vcs_export pkg_tars pkg_trees tmp)) { # {dookbook} | |
130 | make_path( | |
131 | $context->{d}{$_} = catdir($workspace, $_), | |
132 | { verbose => $verbose || $debug }); | |
133 | } | |
134 | } | |
8f29c950 | 135 | |
525c441c HSHR |
136 | sub export_git_tree { |
137 | my $context = shift; | |
138 | ||
139 | # build git command | |
140 | my $archive_file = $context->{tmp_archive_file} = sprintf'%s/%s-%s.tar', $context->{d}{tmp}, $context->{pkgname}, $context->{v}{release}; | |
141 | ### $archive_file | |
142 | my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{git_tag} ); | |
143 | ### @cmd | |
144 | # run git command | |
145 | print "[$cwd] Running: @cmd\n" if $verbose; | |
146 | 0 == system @cmd or croak "Export failed"; | |
147 | } | |
8f29c950 | 148 | |
525c441c HSHR |
149 | sub unpack_tree { |
150 | # TODO: Why can't we combine the export_git_tree with the | |
151 | # unpack_tree function? | |
152 | my $context = shift; | |
ba41f854 | 153 | |
525c441c HSHR |
154 | ### $context |
155 | die "Cannot see archive file\n" unless -f $context->{tmp_archive_file}; | |
156 | my @cmd = ('tar', | |
157 | xf => $context->{tmp_archive_file}, | |
158 | -C => $context->{d}{vcs_export} ); | |
5901f0ab | 159 | |
525c441c HSHR |
160 | # run command |
161 | print "[$cwd] Running: @cmd\n" if $verbose; | |
162 | system @cmd and croak "Unpack failed\n"; | |
5901f0ab | 163 | |
ba41f854 PP |
164 | } |
165 | ||
525c441c HSHR |
166 | sub make_version_script { |
167 | my $context = shift; | |
168 | ||
169 | #my $variant = substr( $context->{v}{release}, length($context->{v}{target_release}) ); | |
170 | #if ( $context->{v}{release} ne $context->{v}{target_release} . $variant ) { | |
171 | # die "Broken version numbering, I'm buggy"; | |
172 | #} | |
173 | ||
174 | ||
175 | # Work | |
176 | if (not my $pid = fork // die "$ME: Cannot fork: $!\n") { | |
177 | ||
178 | my $source_tree = catdir($context->{d}{vcs_export}, 'src', 'src'); | |
179 | ### $source_tree | |
180 | ||
181 | chdir $source_tree or die "chdir $source_tree: $!\n"; | |
182 | ||
183 | ||
184 | croak "WARNING: version.sh already exists - leaving it in place\n" | |
185 | if -f 'version.sh'; | |
186 | ||
187 | # Currently (25. Feb. 2016) the mk_exim_release.pl up to now can't | |
188 | # deal with security releases.!? So we need a current | |
189 | # mk_exim_release.pl. But if we use a current (master), the | |
190 | # reversion script returns wrong version info (it's running inside | |
191 | # the Git tree and uses git --describe, which always returns the | |
192 | # current version of master.) I do not want to change the old | |
193 | # reversion scripts (in 4.86.1, 4.85.1). | |
194 | # | |
195 | # Thus we've to provide the version.sh, based on the info we have | |
196 | # about the release. If reversion finds this, it doesn't try to find | |
197 | # it's own way to get a valid version number from the git. | |
198 | # | |
199 | # 4.89 series: the logic here did not handle _RC<N> thus breaking RC | |
200 | # status in versions. nb: rc in context should be same as $variant | |
201 | # in local context. | |
202 | ||
203 | #my $stamp = $context->{minor} ? '_'.$context->{minor} : ''; | |
204 | #$stamp .= $context->{rc} if $context->{rc}; | |
205 | my $variant = $context->{v}{rc} // ''; | |
206 | ||
207 | print "[$cwd] create version.sh\n" if $verbose; | |
208 | open(my $v, '>', 'version.sh') or die "Can't open version.sh for writing: $!\n"; | |
209 | print {$v} <<__; | |
210 | # initial version automatically generated by $0 | |
211 | EXIM_RELEASE_VERSION=$context->{v}{target_release} | |
212 | EXIM_VARIANT_VERSION=$variant | |
9677df8a | 213 | EXIM_COMPILE_NUMBER=0 |
525c441c | 214 | # echo "[[[ \$EXIM_RELEASE_VERSION | \$EXIM_VARIANT_VERSION | \$EXIM_COMPILE_NUMBER ]]]" |
9677df8a | 215 | __ |
525c441c HSHR |
216 | close $v or die "$0: Can not close $source_tree/version.h: $!\n"; |
217 | unlink 'version.h' or die "$ME: Can not unlink $source_tree/version.h: $!\n" | |
218 | if -f 'version.h'; | |
9677df8a | 219 | |
525c441c HSHR |
220 | # Later, if we get the reversion script fixed, we can call it again. |
221 | # For now (25. Feb. 2016) we'll leave it unused. | |
222 | #my @cmd = ('../scripts/reversion', 'release', $context->{git_tag}); | |
5901f0ab | 223 | |
525c441c HSHR |
224 | my @cmd = ('../scripts/reversion', 'release'); |
225 | print "[$cwd] Running: @cmd\n" if $verbose; | |
226 | system(@cmd) and croak "reversion failed"; | |
ba41f854 | 227 | |
525c441c HSHR |
228 | die "$ME: failed to create version.sh" |
229 | unless -f 'version.sh'; | |
ba41f854 | 230 | |
525c441c HSHR |
231 | exit 0; |
232 | } | |
233 | else { | |
234 | $pid == waitpid($pid, 0) or die "$0: waidpid: $!\n"; | |
235 | exit $? >> 8 if $?; | |
236 | } | |
237 | } | |
ba41f854 | 238 | |
525c441c HSHR |
239 | sub build_documentation { |
240 | my $context = shift; | |
241 | my $docdir = catdir $context->{d}{vcs_export}, 'doc', 'doc-docbook'; | |
242 | ||
243 | # documentation building does a chdir, so we'll do it in a | |
244 | # subprocess | |
245 | if (not my $pid = fork // die "$ME: Can't fork: $!\n") { | |
246 | chdir $docdir or die "$ME: Can't chdir to $docdir: $!\n"; | |
247 | system('./OS-Fixups') == 0 or exit $?; | |
248 | exec $context->{make_cmd}, | |
249 | "EXIM_VER=$context->{v}{target_release}" . | |
250 | ($context->{v}{rc} ? "-$context->{v}{rc}" : ''), | |
251 | 'everything'; | |
252 | die "$ME: [$cwd] Cannot exec $context->{make_cmd}: $!\n"; | |
253 | } | |
254 | else { | |
255 | waitpid($pid, 0); | |
256 | exit $? >> 8 if $?; | |
257 | } | |
be914e6c | 258 | |
525c441c HSHR |
259 | $context->copy_docbook_files; |
260 | $context->build_html_documentation if $context->{web}; | |
261 | } | |
46c573de | 262 | |
525c441c HSHR |
263 | sub copy_docbook_files { |
264 | my $context = shift; | |
be914e6c | 265 | |
525c441c HSHR |
266 | # where the generated docbook files can be found |
267 | my $docdir = catdir $context->{d}{vcs_export}, 'doc', 'doc-docbook'; | |
be914e6c | 268 | |
525c441c HSHR |
269 | foreach ('spec.xml', 'filter.xml') { |
270 | my $from = catfile $docdir, $_; | |
271 | my $to = catdir $context->{d}{tmp}; # {dookbook} | |
272 | copy $from => $to or die $@; | |
273 | } | |
274 | } | |
be914e6c | 275 | |
525c441c HSHR |
276 | sub build_html_documentation { |
277 | my $context = shift; | |
46c573de | 278 | |
525c441c HSHR |
279 | # where the website docbook source dir is - push the generated |
280 | # files there | |
281 | { | |
282 | my $webdir = catdir $context->{website_base}, 'docbook', $context->{v}{target_release}; | |
283 | make_path $webdir, { verbose => $verbose + $debug }; | |
284 | copy catfile($context->{d}{vcs_export}, 'doc', 'doc-docbook', $_) | |
285 | => $webdir or die $@ | |
286 | for 'spec.xml', 'filter.xml'; | |
287 | } | |
46c573de | 288 | |
525c441c HSHR |
289 | my $gen = catfile $context->{website_base}, 'script/gen'; |
290 | my $outdir = catdir $context->{d}{pkg_trees}, "exim-html-$context->{v}{release}"; | |
46c573de | 291 | |
525c441c | 292 | make_path $outdir, { verbose => $verbose || $debug }; |
46c573de | 293 | |
525c441c HSHR |
294 | my @cmd = ( |
295 | $gen, | |
296 | '--spec' => catfile($context->{d}{tmp}, 'spec.xml'), # {dookbook} | |
297 | '--filter' => catfile($context->{d}{tmp}, 'filter.xml'), # {dookbok} | |
298 | '--latest' => $context->{v}{target_release}, | |
299 | '--docroot' => $outdir, | |
300 | '--localstatic', | |
301 | ($verbose || $debug ? '--verbose' : ()), | |
302 | ); | |
46c573de | 303 | |
525c441c HSHR |
304 | print "[$cwd] Executing @cmd\n"; |
305 | 0 == system @cmd or exit $? >> 8; | |
46c573de | 306 | |
46c573de | 307 | } |
be914e6c | 308 | |
525c441c HSHR |
309 | sub move_to_outdir { |
310 | my $context = shift; | |
311 | make_path $context->{OUTDIR}, { verbose => $verbose || $debug }; | |
312 | move $_ => $context->{OUTDIR} or die $@ | |
313 | for glob "$context->{d}{pkg_tars}/*"; | |
314 | } | |
8a483da6 | 315 | |
525c441c HSHR |
316 | sub build_src_package_directory { |
317 | my $context = shift; | |
8a483da6 | 318 | |
525c441c HSHR |
319 | # build the exim package directory path |
320 | $context->{d}{src} = catdir $context->{d}{pkg_trees}, "exim-$context->{v}{release}"; | |
8a483da6 | 321 | |
525c441c HSHR |
322 | # initially we move the exim-src directory to the new directory name |
323 | move | |
324 | catdir( $context->{d}{vcs_export}, 'src') | |
325 | => $context->{d}{src} | |
326 | or croak "Move of src dir failed - $!"; | |
8a483da6 | 327 | |
525c441c HSHR |
328 | # add Local subdirectory |
329 | make_path( catdir( $context->{d}{src}, 'Local' ), { verbose => $verbose || $debug } ); | |
8a483da6 | 330 | |
525c441c HSHR |
331 | # now add the text docs |
332 | $context->move_text_docs_into_pkg; | |
8a483da6 | 333 | } |
8a483da6 | 334 | |
525c441c HSHR |
335 | sub build_doc_packages_directory { |
336 | my $context = shift; | |
337 | ||
338 | ##foreach my $format (qw/pdf postscript texinfo info/) { | |
339 | foreach my $format (qw/pdf postscript/) { | |
340 | my $target = catdir $context->{d}{pkg_trees}, "exim-$format-$context->{v}{release}", 'doc'; | |
341 | make_path( $target, { verbose => $verbose || $debug } ); | |
342 | ||
343 | # move documents across | |
344 | foreach my $file ( | |
345 | glob( | |
346 | catfile( | |
347 | $context->{d}{vcs_export}, | |
348 | 'doc', | |
349 | 'doc-docbook', | |
350 | ( | |
351 | ( $format eq 'postscript' ) | |
352 | ? '*.ps' | |
353 | : ( '*.' . $format ) | |
354 | ) | |
8a483da6 NM |
355 | ) |
356 | ) | |
357 | ) | |
525c441c HSHR |
358 | { |
359 | move( $file, catfile( $target, ( splitpath($file) )[2] ) ); | |
360 | } | |
8a483da6 NM |
361 | } |
362 | } | |
46c573de | 363 | |
525c441c HSHR |
364 | sub move_text_docs_into_pkg { |
365 | my $context = shift; | |
9d0311ff | 366 | |
525c441c HSHR |
367 | my $old_docdir = catdir( $context->{d}{vcs_export}, 'doc', 'doc-docbook' ); |
368 | my $old_txtdir = catdir( $context->{d}{vcs_export}, 'doc', 'doc-txt' ); | |
369 | my $new_docdir = catdir( $context->{d}{src}, 'doc' ); | |
370 | make_path( $new_docdir, { verbose => $verbose || $debug } ); | |
9d0311ff | 371 | |
525c441c HSHR |
372 | # move generated documents from docbook stuff |
373 | foreach my $file (qw/exim.8 spec.txt filter.txt/) { | |
374 | die "Empty file \"$file\"\n" if -z catfile( $old_docdir, $file ); | |
375 | move( catfile( $old_docdir, $file ), catfile( $new_docdir, $file ) ); | |
376 | } | |
9d0311ff | 377 | |
525c441c HSHR |
378 | # move text documents across |
379 | foreach my $file ( glob( catfile( $old_txtdir, '*' ) ) ) { | |
380 | ||
381 | # skip a few we dont want | |
382 | my $fn = ( splitpath($file) )[2]; | |
383 | next | |
384 | if ( ( $fn eq 'ABOUT' ) | |
385 | || ( $fn eq 'ChangeLog.0' ) | |
386 | || ( $fn eq 'test-harness.txt' ) | |
387 | # Debian issue re licensing of RFCs | |
388 | || ( $fn =~ /^draft-ietf-.*/ ) | |
389 | || ( $fn =~ /^rfc.*/ ) | |
390 | ); | |
391 | move( $file, catfile( $new_docdir, $fn ) ); | |
9d0311ff PP |
392 | } |
393 | } | |
9d0311ff | 394 | |
525c441c HSHR |
395 | sub create_tar_files { |
396 | my $context = shift; | |
9d0311ff | 397 | |
525c441c HSHR |
398 | my $pkg_tars = $context->{d}{pkg_tars}; |
399 | my $pkg_trees = $context->{d}{pkg_trees}; | |
400 | my $tar = $context->{tar_cmd}; | |
401 | if ($verbose) { | |
402 | foreach my $c (keys %{ $context->{compressors} }) { | |
403 | print "Compression: $c\t$context->{compressors}{$c}\n"; | |
404 | } | |
405 | } | |
8a483da6 | 406 | |
525c441c HSHR |
407 | # We ideally do not want local system user information in release tarballs; |
408 | # those are artifacts of use of tar for backups and have no place in | |
409 | # software release packaging; if someone extracts as root, then they should | |
410 | # get sane file ownerships. | |
411 | my $ownership = ""; | |
412 | if (`tar --help 2>&1` =~ /^\s*--owner=/m) { | |
413 | $ownership .= " --owner=$context->{tar_perms}{user} --group=$context->{tar_perms}{group}"; | |
414 | # on this GNU tar, --numeric-owner works during creation too | |
415 | $ownership .= " --numeric-owner"; | |
9d0311ff | 416 | } |
9d0311ff | 417 | |
525c441c HSHR |
418 | # See also environment variables set in main, tuning compression levels |
419 | my @COMPRESSIONS = ( | |
420 | # compressors-dict-key, file-extension, flags-as-string | |
421 | [ "gzip", "gz", "--gzip" ], | |
422 | [ "bzip2", "bz2", "--bzip2" ], | |
423 | [ "lzip", "lz", "--lzip" ], | |
424 | [ "xz", "xz", "--xz" ], | |
425 | ); | |
426 | ||
427 | foreach my $dir ( glob( catdir( $pkg_trees, ( 'exim*-' . $context->{v}{release} ) ) ) ) { | |
428 | my $dirname = ( splitdir($dir) )[-1]; | |
429 | foreach my $comp (@COMPRESSIONS) { | |
430 | my ($compkey, $extension, $flags) = @{$comp}; | |
431 | next unless $context->{compressors}{$compkey}; | |
432 | print "Creating: ${pkg_tars}/${dirname}.tar.${extension}\n" if $verbose || $debug; | |
433 | 0 == system("$tar cf ${pkg_tars}/${dirname}.tar.${extension} ${flags} ${ownership} -C ${pkg_trees} ${dirname}") | |
434 | or exit $? >> 8; | |
435 | } | |
436 | } | |
45b75b0a PP |
437 | } |
438 | ||
525c441c HSHR |
439 | sub do_cleanup { |
440 | my $context = shift; | |
00f7a87b | 441 | |
525c441c HSHR |
442 | print "Cleaning up\n" if $verbose; |
443 | remove_tree $context->{d}{tmp}, { verbose => $debug + $verbose }; | |
8a483da6 | 444 | } |
00f7a87b | 445 | |
8a483da6 NM |
446 | } |
447 | ||
91bde4a0 HSHR |
448 | MAIN: { |
449 | ||
525c441c HSHR |
450 | # some of these settings are useful only if we're in the |
451 | # exim-projekt-root, but the check, if we're, is deferred | |
452 | my $context = Context->new( | |
be914e6c | 453 | pkgname => 'exim', |
525c441c | 454 | website_base => abs_path('../exim-website'), |
9d0311ff | 455 | tar_cmd => 'tar', |
45b75b0a PP |
456 | tar_perms => { |
457 | user => '0', | |
458 | group => '0', | |
459 | }, | |
a7637438 | 460 | make_cmd => 'make', |
9d0311ff PP |
461 | compressors => { |
462 | gzip => 1, | |
463 | bzip2 => 1, | |
00f7a87b | 464 | xz => 1, |
e099cd0d | 465 | lzip => 0, |
9d0311ff | 466 | }, |
525c441c | 467 | docs => 1, |
2820726f | 468 | web => 1, |
525c441c HSHR |
469 | delete => 0, |
470 | cleanup => 1, | |
471 | ); | |
472 | ||
8f29c950 | 473 | ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'}; |
00f7a87b | 474 | # We are creating files for mass distribution, so work harder to make smaller files. |
525c441c HSHR |
475 | $ENV{GZIP} = -9; |
476 | $ENV{BZIP2} = -9; | |
00f7a87b PP |
477 | # xz documents minimum file sizes for levels higher than -6 to be useful and each |
478 | # requires more RAM on the decompressing system. Exim tarball currently 24MiB so | |
479 | # using -8. | |
525c441c | 480 | $ENV{XZ_DEFAULTS} = -8; |
8a483da6 | 481 | |
91bde4a0 | 482 | GetOptions( |
525c441c HSHR |
483 | $context, |
484 | qw(workspace|tmp=s outdir=s website_base|webgen_base=s tar_cmd=s make_cmd=s docs|build-docs! web|build-web! | |
485 | delete! cleanup!), | |
91bde4a0 HSHR |
486 | 'lzip!' => \$context->{compressors}{lzip}, |
487 | 'verbose!' => \$verbose, | |
488 | 'debug!' => \$debug, | |
489 | 'help|?' => sub { pod2usage(-verbose => 1, -exit => 0) }, | |
490 | 'man!' => sub { pod2usage(-verbose => 2, -exit => 0, -noperldoc => system('perldoc -V >/dev/null 2>&1')) }, | |
525c441c HSHR |
491 | ) and @ARGV == 2 or pod2usage; |
492 | ||
493 | ||
494 | $context->{OUTDIR} = pop @ARGV; | |
495 | ||
496 | -f '.exim-project-root' | |
497 | or die "$ME: please call this script from the root of the Exim project sources\n"; | |
498 | ||
499 | warn "$ME: changed umask to 022\n" if umask(022) != 022; | |
500 | ||
501 | $context->check_version(shift); | |
502 | $context->override_tar_cmd; | |
503 | $context->prepare_working_directory; | |
504 | $context->export_git_tree; | |
505 | $context->unpack_tree; | |
506 | $context->make_version_script; | |
507 | $context->build_documentation if $context->{docs}; | |
508 | ||
509 | $context->build_src_package_directory; | |
510 | $context->build_doc_packages_directory if $context->{docs}; | |
511 | ||
512 | $context->create_tar_files; | |
513 | $context->move_to_outdir; | |
514 | $context->do_cleanup if $context->{cleanup}; | |
515 | ||
516 | ### $context | |
8a483da6 NM |
517 | } |
518 | ||
519 | 1; | |
520 | ||
521 | __END__ | |
522 | ||
523 | =head1 NAME | |
524 | ||
6bfa380e | 525 | mk_exim_release - Build an exim release |
8a483da6 NM |
526 | |
527 | =head1 SYNOPSIS | |
528 | ||
525c441c | 529 | mk_exim_release [options] version PKG-DIRECTORY |
91bde4a0 HSHR |
530 | |
531 | =head1 DESCRIPTION | |
532 | ||
533 | B<mk_exim_release> builds an exim release. | |
534 | ||
535 | Starting in a populated git repo that has already been tagged for | |
536 | release it builds docs, packages etc. Parameter is the version number | |
525c441c HSHR |
537 | to build as - ie 4.72 4.72-RC1, 4.86.1, etc, without any prefix. |
538 | ||
539 | This scripts expects to find a tag "exim-<version>". | |
91bde4a0 HSHR |
540 | |
541 | After creating the release files, they should be signed. There is another | |
542 | helper for creating the signatures: | |
543 | F<release-process/scripts/sign_exim_packages>. | |
544 | ||
545 | Call B<mk_exim_release> about like this: | |
546 | ||
525c441c | 547 | release-process/scripts/mk_exim_release 4.99 OUT-DIR |
8a483da6 | 548 | |
8a483da6 NM |
549 | |
550 | =head1 OPTIONS | |
551 | ||
552 | =over 4 | |
553 | ||
525c441c HSHR |
554 | =item B<--[no]cleanup> |
555 | ||
556 | Do (or do not) cleanup the tmp directory at exit (default: do cleanup) | |
557 | ||
91bde4a0 | 558 | =item B<--[no]debug> |
8a483da6 | 559 | |
91bde4a0 | 560 | Forces debug mode. (default: no debug info) |
8a483da6 | 561 | |
91bde4a0 | 562 | =item B<--[no]delete> |
9d0311ff | 563 | |
525c441c | 564 | Delete a pre-existing tmp- and package-directory at start. (default: don't delete) |
9d0311ff | 565 | |
525c441c | 566 | =item B<--tmpdir> I<dir> |
a7637438 | 567 | |
525c441c | 568 | Change the name of the tmp directory (default: temporary directory) |
a7637438 | 569 | |
91bde4a0 | 570 | =item B<--[no]help> |
9d0311ff | 571 | |
91bde4a0 | 572 | Display short help and exit cleanly. (default: don't do that) |
9d0311ff | 573 | |
91bde4a0 | 574 | =item B<--[no]lzip> |
8a483da6 | 575 | |
91bde4a0 | 576 | Control the creation of B<lzip> tarballs. (default: do not use lzip) |
8a483da6 | 577 | |
91bde4a0 | 578 | =item B<--make> I<cmd> |
8a483da6 | 579 | |
91bde4a0 HSHR |
580 | Force the use of a specific C<make> command. This may be necessary if C<make> is not |
581 | C<gmake> (default: C<make>) | |
8a483da6 | 582 | |
91bde4a0 | 583 | =item B<--[no]man> |
8a483da6 | 584 | |
91bde4a0 | 585 | Display man page and exit cleanly. (default: don't do that) |
8a483da6 | 586 | |
91bde4a0 | 587 | =item B<--tar> I<cmd> |
8a483da6 | 588 | |
91bde4a0 HSHR |
589 | Use to override the path to the C<tar> command. Need GNU tar in case |
590 | I<lzip> is selected. (default: C<gtar>, if not found, use C<tar>) | |
8a483da6 | 591 | |
91bde4a0 | 592 | =item B<--[no]web> |
8a483da6 | 593 | |
91bde4a0 | 594 | Control the creation of the website. For creation of the website, the F<../exim-website> |
525c441c HSHR |
595 | (but see the B<website-base> option) directory must exist. (default: create the website) |
596 | ||
597 | =item B<--website-base> I<dir> | |
598 | ||
599 | Base directory for the web site generation (default: F<../exim-website>) | |
8a483da6 | 600 | |
91bde4a0 HSHR |
601 | =item B<--verbose> |
602 | ||
603 | Force verbose mode. (default: no verbosity) | |
604 | ||
605 | =back | |
8a483da6 NM |
606 | |
607 | =head1 AUTHOR | |
608 | ||
91bde4a0 HSHR |
609 | Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>, |
610 | some changes by Heiko Schlittermann <hs@schlittermann.de> | |
8a483da6 NM |
611 | |
612 | =head1 COPYRIGHT | |
613 | ||
91bde4a0 | 614 | Copyright 2010-2016 Exim Maintainers. All rights reserved. |
8a483da6 NM |
615 | |
616 | =cut | |
9d0311ff | 617 | # vim: set sw=4 et : |