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_html_directory
{
166 my $dir = sprintf( 'exim-%s-%s', 'html', $context->{release
} );
167 my $target = File
::Spec
->catdir( $dir, 'doc', 'html' );
168 mkpath
( $target, { verbose
=> ( $verbose || $debug ) } );
170 # move documents across
171 move
( File
::Spec
->catdir( 'doc/doc-docbook', 'spec_html' ), File
::Spec
->catdir( $target, 'spec_html' ) );
172 foreach my $file ( glob( File
::Spec
->catfile( 'doc/doc-docbook', '*.html' ) ) ) {
173 my $fn = ( File
::Spec
->splitpath($file) )[2];
174 move
( $file, File
::Spec
->catfile( $target, $fn ) );
178 # ------------------------------------------------------------------
180 sub build_main_package_directory
{
183 # initially we move the exim-src directory to the new directory name
184 my $pkgdir = sprintf( 'exim-%s', $context->{release
} );
185 $context->{pkgdir
} = $pkgdir;
186 rename( 'src', $pkgdir ) || croak
"Rename of src dir failed - $!";
188 # add Local subdirectory
189 my $target = File
::Spec
->catdir( $pkgdir, 'Local' );
190 mkpath
( $target, { verbose
=> ( $verbose || $debug ) } );
192 # now add the text docs
193 move_text_docs_into_pkg
($context);
196 # ------------------------------------------------------------------
198 sub build_package_directories
{
201 build_main_package_directory
($context);
202 build_pspdfinfo_directory
($context);
203 build_html_directory
($context);
206 # ------------------------------------------------------------------
208 sub create_tar_files
{
211 foreach my $dir ( glob( 'exim*-' . $context->{release
} ) ) {
212 system("tar cfz ${dir}.tar.gz ${dir}");
213 system("tar cfj ${dir}.tar.bz2 ${dir}");
217 # ------------------------------------------------------------------
223 orig_dir
=> File
::Spec
->curdir(),
224 tmp_dir
=> File
::Temp
->newdir(),
227 ##$ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
231 'directory=s' => \
$context->{directory
},
232 'verbose!' => \
$verbose,
236 'delete!' => \
$delete,
240 pod2usage
( -exitval
=> 1, -verbose
=> 0 );
242 pod2usage
(0) if $help;
243 pod2usage
( -verbose
=> 2 ) if $man;
245 $context->{release
} = get_and_check_version
(shift);
246 $context->{tag
} = build_tag
($context);
247 deal_with_working_directory
( $context, $delete );
248 export_git_tree
($context);
249 chdir( $context->{directory
} ) || die;
250 unpack_tree
($context);
251 build_documentation
($context);
252 build_package_directories
($context);
253 create_tar_files
($context);
262 mk_exim_release.pl - Build an exim release
266 mk_exim_release.pl [options] version
269 --debug force debug mode (SQL Trace)
270 --verbose force verbose mode
271 --help display this help and exits
272 --man displays man page
273 --directory=dir dir to package
274 --delete Delete packaging directory at start
282 Forces debug mode cause all SQL statements generated by L<DBIx::Class>
287 Force verbose mode - currently this has no effect
291 Display help and exits
301 Builds an exim release.
303 Starting in a populated git repo that has already been tagged for
304 release, build docs, build packages etc.
306 Parameter is the version number to build as - ie 4.72 4.72RC1 etc
310 Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>
314 Copyright 2010 Exim Maintainers. All rights reserved.