3 # $Cambridge: exim/release-process/scripts/mk_exim_release.pl,v 1.1 2010/06/03 12:00:38 nm4 Exp $
18 # ------------------------------------------------------------------
20 sub get_and_check_version
{
23 # make sure this looks like a real release version
24 # which should (currently) be 4.xx or 4.xx_RCx
25 unless ( $release =~ /^(4\.\d\d(?:_RC\d+)?)$/ ) {
26 croak
"The given version number does not look right - $release";
28 return $1; # untainted here...
31 # ------------------------------------------------------------------
36 # The CVS tag consists of exim-$version where $version
37 # is the version number with . replaced with _
38 my $modversion = $context->{release
};
39 $modversion =~ tr/0-9RC/_/cs;
41 return sprintf( 'exim-%s', $modversion );
44 # ------------------------------------------------------------------
46 sub deal_with_working_directory
{
50 # Set default directory
51 $context->{directory
} ||= File
::Spec
->rel2abs( sprintf( 'exim-packaging-%s', $context->{release
} ) );
52 my $directory = $context->{directory
};
54 # ensure the working directory is not in place
55 if ( -d
$directory ) {
57 print "Deleting existing $directory\n" if ($verbose);
58 rmtree
( $directory, { verbose
=> $debug } );
60 if ( -d
$directory ) {
61 croak
"Working directory $directory exists";
65 mkpath
( $context->{directory
}, { verbose
=> ( $verbose || $debug ) } );
68 # ------------------------------------------------------------------
74 my $archive_file = sprintf( '%s/%s-%s.tar', $context->{tmp_dir
}, $context->{pkgname
}, $context->{release
} );
75 $context->{tmp_archive_file
} = $archive_file;
76 my @cmd = ( 'git', 'archive', '--format=tar', "--output=$archive_file", $context->{tag
} );
79 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
80 system(@cmd) == 0 || croak
"Export failed";
83 # ------------------------------------------------------------------
88 die "Cannot see archive file\n" unless ( -f
$context->{tmp_archive_file
} );
89 my @cmd = ( 'tar', 'xf', $context->{tmp_archive_file
} );
92 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
93 system(@cmd) == 0 || croak
"Unpack failed";
96 # ------------------------------------------------------------------
98 sub build_documentation
{
99 system("cd doc/doc-docbook && ./OS-Fixups && make everything") == 0
100 || croak
"Doc build failed";
103 # ------------------------------------------------------------------
105 sub move_text_docs_into_pkg
{
108 my $old_docdir = 'doc/doc-docbook';
109 my $new_docdir = File
::Spec
->catdir( $context->{pkgdir
}, 'doc' );
110 mkpath
( $new_docdir, { verbose
=> ( $verbose || $debug ) } );
112 # move generated documents from docbook stuff
113 foreach my $file (qw
/exim.8 spec.txt filter.txt/) {
114 move
( File
::Spec
->catfile( $old_docdir, $file ), File
::Spec
->catfile( $new_docdir, $file ) );
117 # move text documents across
118 foreach my $file ( glob( File
::Spec
->catfile( 'doc/doc-txt', '*' ) ) ) {
120 # skip a few we dont want
121 my $fn = ( File
::Spec
->splitpath($file) )[2];
123 if ( ( $fn eq 'ABOUT' )
124 || ( $fn eq 'ChangeLog.0' )
125 || ( $fn eq 'test-harness.txt' ) );
126 move
( $file, File
::Spec
->catfile( $new_docdir, $fn ) );
130 # ------------------------------------------------------------------
132 sub build_pspdfinfo_directory
{
135 ##foreach my $format (qw/pdf postscript texinfo info/) {
136 foreach my $format (qw
/pdf postscript/) {
137 my $dir = sprintf( 'exim-%s-%s', $format, $context->{release
} );
138 my $target = File
::Spec
->catdir( $dir, 'doc' );
139 mkpath
( $target, { verbose
=> ( $verbose || $debug ) } );
141 # move documents across
147 ( $format eq 'postscript' )
155 my $fn = ( File
::Spec
->splitpath($file) )[2];
156 move
( $file, File
::Spec
->catfile( $target, $fn ) );
161 # ------------------------------------------------------------------
163 sub build_main_package_directory
{
166 # initially we move the exim-src directory to the new directory name
167 my $pkgdir = sprintf( 'exim-%s', $context->{release
} );
168 $context->{pkgdir
} = $pkgdir;
169 rename( 'src', $pkgdir ) || croak
"Rename of src dir failed - $!";
171 # add Local subdirectory
172 my $target = File
::Spec
->catdir( $pkgdir, 'Local' );
173 mkpath
( $target, { verbose
=> ( $verbose || $debug ) } );
175 # now add the text docs
176 move_text_docs_into_pkg
($context);
179 # ------------------------------------------------------------------
181 sub build_package_directories
{
184 build_main_package_directory
($context);
185 build_pspdfinfo_directory
($context);
188 # ------------------------------------------------------------------
190 sub create_tar_files
{
193 foreach my $dir ( glob( 'exim*-' . $context->{release
} ) ) {
194 system("tar cfz ${dir}.tar.gz ${dir}");
195 system("tar cfj ${dir}.tar.bz2 ${dir}");
199 # ------------------------------------------------------------------
205 orig_dir
=> File
::Spec
->curdir(),
206 tmp_dir
=> File
::Temp
->newdir(),
209 ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
213 'directory=s' => \
$context->{directory
},
214 'verbose!' => \
$verbose,
218 'delete!' => \
$delete,
222 pod2usage
( -exitval
=> 1, -verbose
=> 0 );
224 pod2usage
(0) if $help;
225 pod2usage
( -verbose
=> 2 ) if $man;
227 $context->{release
} = get_and_check_version
(shift);
228 $context->{tag
} = build_tag
($context);
229 deal_with_working_directory
( $context, $delete );
230 export_git_tree
($context);
231 chdir( $context->{directory
} ) || die;
232 unpack_tree
($context);
233 build_documentation
($context);
234 build_package_directories
($context);
235 create_tar_files
($context);
244 mk_exim_release.pl - Build an exim release
248 mk_exim_release.pl [options] version
251 --debug force debug mode (SQL Trace)
252 --verbose force verbose mode
253 --help display this help and exits
254 --man displays man page
255 --directory=dir dir to package
256 --delete Delete packaging directory at start
264 Forces debug mode cause all SQL statements generated by L<DBIx::Class>
269 Force verbose mode - currently this has no effect
273 Display help and exits
283 Builds an exim release.
285 Starting in a populated git repo that has already been tagged for
286 release, build docs, build packages etc.
288 Parameter is the version number to build as - ie 4.72 4.72RC1 etc
292 Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>
296 Copyright 2010 Exim Maintainers. All rights reserved.