3 # $Cambridge: exim/release-process/scripts/mk_exim_release.pl,v 1.1 2010/06/03 12:00:38 nm4 Exp $
17 # ------------------------------------------------------------------
19 sub get_and_check_version {
22 # make sure this looks like a real release version
23 # which should (currently) be 4.xx
24 unless ( $release =~ /^(4\.\d\d(?:_RC\d+)?)$/ ) {
25 croak "The given version number does not look right - $release";
27 return $1; # untainted here...
30 # ------------------------------------------------------------------
35 # The CVS tag consists of exim-$version where $version
36 # is the version number with . replaced with _
37 my $modversion = $context->{release};
38 $modversion =~ tr/0-9RC/_/cs;
40 return sprintf( 'exim-%s', $modversion );
43 # ------------------------------------------------------------------
45 sub deal_with_working_directory {
49 # Set default directory
50 $context->{directory} ||= File::Spec->rel2abs( sprintf( 'exim-packaging-%s', $context->{release} ) );
51 my $directory = $context->{directory};
53 # ensure the working directory is not in place
54 if ( -d $directory ) {
56 print "Deleting existing $directory\n" if ($verbose);
57 rmtree( $directory, { verbose => $debug } );
59 if ( -d $directory ) {
60 croak "Working directory $directory exists";
64 mkpath( $context->{directory}, { verbose => ( $verbose || $debug ) } );
67 # ------------------------------------------------------------------
73 my @cmd = ( 'cvs', '-d', $context->{cvsroot}, '-Q', 'export', '-r', $context->{tag}, $context->{pkgname}, );
76 print( "Running: ", join( ' ', @cmd ), "\n" ) if ($verbose);
77 system(@cmd) == 0 || croak "Export failed";
80 # ------------------------------------------------------------------
82 sub build_documentation {
83 system("cd exim/exim-doc/doc-docbook && ./OS-Fixups && make everything") == 0
84 || croak "Doc build failed";
87 # ------------------------------------------------------------------
89 sub move_text_docs_into_pkg {
92 my $old_docdir = 'exim/exim-doc/doc-docbook';
93 my $new_docdir = File::Spec->catdir( $context->{pkgdir}, 'doc' );
94 mkpath( $new_docdir, { verbose => ( $verbose || $debug ) } );
96 # move generated documents from docbook stuff
97 foreach my $file (qw/exim.8 spec.txt filter.txt/) {
98 move( File::Spec->catfile( $old_docdir, $file ), File::Spec->catfile( $new_docdir, $file ) );
101 # move text documents across
102 foreach my $file ( glob( File::Spec->catfile( 'exim/exim-doc/doc-txt', '*' ) ) ) {
104 # skip a few we dont want
105 my $fn = ( File::Spec->splitpath($file) )[2];
107 if ( ( $fn eq 'ABOUT' )
108 || ( $fn eq 'ChangeLog.0' )
109 || ( $fn eq 'test-harness.txt' ) );
110 move( $file, File::Spec->catfile( $new_docdir, $fn ) );
114 # ------------------------------------------------------------------
116 sub build_pspdfinfo_directory {
119 ##foreach my $format (qw/pdf postscript texinfo info/) {
120 foreach my $format (qw/pdf postscript/) {
121 my $dir = sprintf( 'exim-%s-%s', $format, $context->{release} );
122 my $target = File::Spec->catdir( $dir, 'doc' );
123 mkpath( $target, { verbose => ( $verbose || $debug ) } );
125 # move documents across
129 'exim/exim-doc/doc-docbook',
131 ( $format eq 'postscript' )
139 my $fn = ( File::Spec->splitpath($file) )[2];
140 move( $file, File::Spec->catfile( $target, $fn ) );
145 # ------------------------------------------------------------------
147 sub build_html_directory {
150 my $dir = sprintf( 'exim-%s-%s', 'html', $context->{release} );
151 my $target = File::Spec->catdir( $dir, 'doc', 'html' );
152 mkpath( $target, { verbose => ( $verbose || $debug ) } );
154 # move documents across
155 move( File::Spec->catdir( 'exim/exim-doc/doc-docbook', 'spec_html' ), File::Spec->catdir( $target, 'spec_html' ) );
156 foreach my $file ( glob( File::Spec->catfile( 'exim/exim-doc/doc-docbook', '*.html' ) ) ) {
157 my $fn = ( File::Spec->splitpath($file) )[2];
158 move( $file, File::Spec->catfile( $target, $fn ) );
162 # ------------------------------------------------------------------
164 sub build_main_package_directory {
167 # initially we move the exim-src directory to the new directory name
168 my $pkgdir = sprintf( 'exim-%s', $context->{release} );
169 $context->{pkgdir} = $pkgdir;
170 rename( 'exim/exim-src', $pkgdir ) || croak "Rename of src dir failed - $!";
172 # add Local subdirectory
173 my $target = File::Spec->catdir( $pkgdir, 'Local' );
174 mkpath( $target, { verbose => ( $verbose || $debug ) } );
176 # now add the text docs
177 move_text_docs_into_pkg($context);
180 # ------------------------------------------------------------------
182 sub build_package_directories {
185 build_main_package_directory($context);
186 build_pspdfinfo_directory($context);
187 build_html_directory($context);
190 # ------------------------------------------------------------------
192 sub create_tar_files {
195 foreach my $dir ( glob( 'exim*-' . $context->{release} ) ) {
196 system("tar cfz ${dir}.tar.gz ${dir}");
197 system("tar cfj ${dir}.tar.bz2 ${dir}");
201 # ------------------------------------------------------------------
206 cvsroot => ':ext:nm4@vcs.exim.org:/home/cvs',
208 orig_dir => File::Spec->curdir(),
211 $ENV{'PATH'} = '/opt/local/bin:' . $ENV{'PATH'};
215 'directory=s' => \$context->{directory},
216 'cvsroot=s' => \$context->{cvsroot},
217 'verbose!' => \$verbose,
221 'delete!' => \$delete,
225 pod2usage( -exitval => 1, -verbose => 0 );
227 pod2usage(0) if $help;
228 pod2usage( -verbose => 2 ) if $man;
230 $context->{release} = get_and_check_version(shift);
231 $context->{tag} = build_cvs_tag($context);
232 deal_with_working_directory( $context, $delete );
233 chdir( $context->{directory} ) || die;
234 export_cvs_tree($context);
235 build_documentation($context);
236 build_package_directories($context);
237 create_tar_files($context);
246 mk_exim_release.pl - Build an exim release
250 mk_exim_release.pl [options] version
253 --debug force debug mode (SQL Trace)
254 --verbose force verbose mode
255 --help display this help and exits
256 --man displays man page
257 --directory=dir dir to package
258 --cvsroot=s CVS root spec
259 --delete Delete packaging directory at start
267 Forces debug mode cause all SQL statements generated by L<DBIx::Class>
272 Force verbose mode - currently this has no effect
276 Display help and exits
286 Builds an exim release.
288 Starting in an empty directory, with the CVS repo already tagged
289 for release, build docs, build packages etc.
291 NB The CVS root spec is embedded in the script or can be given via
292 the I<--cvsroot> parameter
294 Parameter is the version number to build as - ie 4.72 4.72RC1 etc
298 Nigel Metheringham <Nigel.Metheringham@dev.intechnology.co.uk>
302 Copyright 2009 Someone. All rights reserved.