3 # $Cambridge: exim/release-process/scripts/mk_exim_release.pl,v 1.1 2010/06/03 12:00:38 nm4 Exp $
19 # ------------------------------------------------------------------
21 sub get_and_check_version {
25 # make sure this looks like a real release version
26 # which should (currently) be 4.xx or 4.xx_RCx
27 unless ( $release =~ /^(4\.\d\d(?:_RC\d+)?)$/ ) {
28 croak "The given version number does not look right - $release";
30 my $full_release = $1; # untainted here...
31 my $trunc_release = $full_release;
32 $trunc_release =~ s/^(4\.\d\d)(?:_RC\d+)?$/$1/;
34 $context->{release} = $full_release;
35 $context->{trelease} = $trunc_release;
38 # ------------------------------------------------------------------
43 # The CVS tag consists of exim-$version where $version
44 # is the version number with . replaced with _
45 my $modversion = $context->{release};
46 $modversion =~ tr/0-9RC/_/cs;
48 return sprintf( 'exim-%s', $modversion );
51 # ------------------------------------------------------------------
53 sub deal_with_working_directory {
57 # Set default directory
58 $context->{directory} ||= File::Spec->rel2abs( sprintf( 'exim-packaging-%s', $context->{release} ) );
59 my $directory = $context->{directory};
61 # ensure the working directory is not in place
62 if ( -d $directory ) {
64 print "Deleting existing $directory\n" if ($verbose);
65 rmtree( $directory, { verbose => $debug } );
67 if ( -d $directory ) {
68 croak "Working directory $directory exists";
72 mkpath( $context->{directory}, { verbose => ( $verbose || $debug ) } );
75 # ------------------------------------------------------------------
81 my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp_dir}, $context->{pkgname}, $context->{release} );
82 $context->{tmp_archive_file} = $archive_file;
83 my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{tag} );
86 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
87 system(@cmd) == 0 || croak "Export failed";
90 # ------------------------------------------------------------------
95 die "Cannot see archive file\n" unless ( -f $context->{tmp_archive_file} );
96 my @cmd = ( 'tar', 'xf', $context->{tmp_archive_file} );
99 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
100 system(@cmd) == 0 || croak "Unpack failed";
103 # ------------------------------------------------------------------
105 sub build_html_documentation {
108 my $genpath = $context->{webgen_base} . '/script/gen.pl';
109 my $templates = $context->{webgen_base} . '/templates';
114 $genpath, '--spec', 'doc/doc-docbook/spec.xml', '--filter',
115 'doc/doc-docbook/filter.xml', '--latest', $context->{trelease}, '--tmpl',
116 $templates, '--docroot', $dir
119 print "Executing ", join( ' ', @cmd ), "\n";
122 # move directory into right place
123 rename( sprintf( 'html/exim-html-%s', $context->{trelease} ), sprintf( 'exim-html-%s', $context->{release} ) );
126 # ------------------------------------------------------------------
128 sub build_documentation {
131 system("cd doc/doc-docbook && ./OS-Fixups && make everything") == 0
132 || croak "Doc build failed";
134 build_html_documentation($context);
137 # ------------------------------------------------------------------
139 sub move_text_docs_into_pkg {
142 my $old_docdir = 'doc/doc-docbook';
143 my $new_docdir = File::Spec->catdir( $context->{pkgdir}, 'doc' );
144 mkpath( $new_docdir, { verbose => ( $verbose || $debug ) } );
146 # move generated documents from docbook stuff
147 foreach my $file (qw/exim.8 spec.txt filter.txt/) {
148 move( File::Spec->catfile( $old_docdir, $file ), File::Spec->catfile( $new_docdir, $file ) );
151 # move text documents across
152 foreach my $file ( glob( File::Spec->catfile( 'doc/doc-txt', '*' ) ) ) {
154 # skip a few we dont want
155 my $fn = ( File::Spec->splitpath($file) )[2];
157 if ( ( $fn eq 'ABOUT' )
158 || ( $fn eq 'ChangeLog.0' )
159 || ( $fn eq 'test-harness.txt' ) );
160 move( $file, File::Spec->catfile( $new_docdir, $fn ) );
164 # ------------------------------------------------------------------
166 sub build_pspdfinfo_directory {
169 ##foreach my $format (qw/pdf postscript texinfo info/) {
170 foreach my $format (qw/pdf postscript/) {
171 my $dir = sprintf( 'exim-%s-%s', $format, $context->{release} );
172 my $target = File::Spec->catdir( $dir, 'doc' );
173 mkpath( $target, { verbose => ( $verbose || $debug ) } );
175 # move documents across
181 ( $format eq 'postscript' )
189 my $fn = ( File::Spec->splitpath($file) )[2];
190 move( $file, File::Spec->catfile( $target, $fn ) );
195 # ------------------------------------------------------------------
197 sub build_main_package_directory {
200 # initially we move the exim-src directory to the new directory name
201 my $pkgdir = sprintf( 'exim-%s', $context->{release} );
202 $context->{pkgdir} = $pkgdir;
203 rename( 'src', $pkgdir ) || croak "Rename of src dir failed - $!";
205 # add Local subdirectory
206 my $target = File::Spec->catdir( $pkgdir, 'Local' );
207 mkpath( $target, { verbose => ( $verbose || $debug ) } );
209 # now add the text docs
210 move_text_docs_into_pkg($context);
213 # ------------------------------------------------------------------
215 sub build_package_directories {
218 build_main_package_directory($context);
219 build_pspdfinfo_directory($context);
222 # ------------------------------------------------------------------
224 sub create_tar_files {
227 foreach my $dir ( glob( 'exim*-' . $context->{release} ) ) {
228 system("tar cfz ${dir}.tar.gz ${dir}");
229 system("tar cfj ${dir}.tar.bz2 ${dir}");
233 # ------------------------------------------------------------------
239 orig_dir => File::Spec->curdir(),
240 tmp_dir => File::Temp->newdir(),
241 webgen_base => "$FindBin::Bin/../../../exim-website",
244 ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
248 'directory=s' => \$context->{directory},
249 'webgen_base=s' => \$context->{webgen_base},
250 'verbose!' => \$verbose,
254 'delete!' => \$delete,
258 pod2usage( -exitval => 1, -verbose => 0 );
260 pod2usage(0) if $help;
261 pod2usage( -verbose => 2 ) if $man;
263 get_and_check_version( shift, $context );
264 $context->{tag} = build_tag($context);
265 deal_with_working_directory( $context, $delete );
266 export_git_tree($context);
267 chdir( $context->{directory} ) || die;
268 unpack_tree($context);
269 build_documentation($context);
270 build_package_directories($context);
271 create_tar_files($context);
280 mk_exim_release.pl - Build an exim release
284 mk_exim_release.pl [options] version
287 --debug force debug mode (SQL Trace)
288 --verbose force verbose mode
289 --help display this help and exits
290 --man displays man page
291 --directory=dir dir to package
292 --delete Delete packaging directory at start
300 Forces debug mode cause all SQL statements generated by L<DBIx::Class>
305 Force verbose mode - currently this has no effect
309 Display help and exits
319 Builds an exim release.
321 Starting in a populated git repo that has already been tagged for
322 release, build docs, build packages etc.
324 Parameter is the version number to build as - ie 4.72 4.72RC1 etc
328 Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>
332 Copyright 2010 Exim Maintainers. All rights reserved.