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