[Amavisadmin-svn] SF.net SVN: amavisadmin: [46] amavisadmin/trunk/tools/build_script.pl
Status: Beta
Brought to you by:
streindl
From: <str...@us...> - 2007-01-24 21:20:59
|
Revision: 46 http://amavisadmin.svn.sourceforge.net/amavisadmin/?rev=46&view=rev Author: streindl Date: 2007-01-24 13:20:59 -0800 (Wed, 24 Jan 2007) Log Message: ----------- Initial build script Added Paths: ----------- amavisadmin/trunk/tools/build_script.pl Added: amavisadmin/trunk/tools/build_script.pl =================================================================== --- amavisadmin/trunk/tools/build_script.pl (rev 0) +++ amavisadmin/trunk/tools/build_script.pl 2007-01-24 21:20:59 UTC (rev 46) @@ -0,0 +1,209 @@ +#!/usr/bin/perl -w + +# Script to create a target distribution +# +# it creates a directory dist in the current directory and compiles a ready to use +# war file, database scripts and compiled documentation as well as API +# documentation into this folder. + +use strict; +use English; +use Getopt::Long; +use Pod::Usage; +use File::Path; +use File::stat; + + +my $distdir = "dist"; +my $cleandir = 0; +my $help=0; +my $man=0; +my $createtar=undef; + +GetOptions("path|p=s" => \$distdir, + "tar|t:s" => \$createtar, + "clean|c!" => \$cleandir, + "help|h" => \$help, + "man|m" => \$man) or pod2usage (2); +pod2usage(1) if ($help); +pod2usage(-exitstatus => 0, -verbose => 2) if ($man); + +if (-d "$distdir") { + if ($cleandir) { + my $stat = stat($distdir); + if ($stat->uid() != $UID) { + die "Cannot delete other user's file (security)"; + } + rmtree($distdir); + if (-d "$distdir") { + die "Cannot remove $distdir"; + } + } else { + die "$distdir does already exist"; + } +} + +mkpath ($destdir) or die "Cannot create directory $destdir"; + + + +__END__ + +=head1 NAME + +build_script.pl - Create distribution for AmavisAdmin + +=head1 SYNOPSIS + +build_script.pl [options...] + + Options: + -path=path Destination directory + -clean Clean destination directory if exist + -tar=[file] Create tar output file + -bzip2 Compress output file as bzip2 + -gzip Compress output file as gzip + -help brief help message + -man full documentation + +=head1 OPTIONS + +=over 8 + +=item B<-path> + +You can specify a different output directory for the destination where +the build script will put it's output. For example the command + + B<tools/build_script.pl> -path=I</tmp/dist> + +will build the output into the directory F</tmp/dist>. + +If the target directory does already exist, the script will die with an +error. This can be prevented by using the L</-clean> option. + +The target directory might contain several special tokens which will be +replaced before creating the actual directory. The following tokens are +defined: + +=over 8 + +=item B<%p> + +This token will be replaced by the application name (e.g. B<AmavisAdmin>). + +=item B<%v> + +This token will be replaced by the version (taken from F<conf/version.data>). +The version will be in the form C<major.minor>, e.g. B<1.0>. + +=item B<%V> + +The token will be replaced by the full version number including SVN revision +and branch type together with the information, if the build is based on +modified sources. As this is used in filenames, the version string will +not contain any spaces. An example for B<%V> might look like this: + + 1.0-r123-alpha2-modified + +where C<1.0> is the same as given by B<%v>, the string C<r123> gives the +current SVN revision, C<alpha2> denotes the current tag (see the description +for B<%T> for details).In case the build is based on uncommitted changes to +the repository, the term C<-modified> will be added to the version. This token +is actually a shortcut for + + %v-r%r-%T%m + +=item B<%r> + +This token will be replaced by the subversion revision number (e.g. C<123>). + +=item B<%T> + +This token will be replaced by the branch that is going to be build. In case +of building the trunk you will see the string C<trunk> here, for working in +branches you will see C<branch-> followed by the branch-name +(e.g. C<branch-V1_X>). If you build a tagged version (located under the +F<tags> folder in the subversion repository), only the tag-name itself is +returned (e.g. C<V_1_3_1>). + +=item B<%m> + +This token will be replaced with the string C<-modified> in case the current +working directory has been modified (i.e. the command C<svn status> returns +any output). + +=item B<%d> + +This token will be replaced by the date in the form C<YYYY-MM-DD>. + +=item B<%t> + +This token will be replaced by the current timestamp in the form +C<YYYYMMDDhhmmss>. + +=back + +=item B<-clean> + +If the target directory does already exist, delete the contents before +continuing. This option does nothing if the target directory does not +exist. + +=item B<-tar> + +If set, create a tar file with the contents of the directory just being build. +If the argument is passed without a parameter, the filename will be the name +of the B<-path> parameter followed by C<.tar>. In case no path is given on the +command line, the name will be C<dist.tar>. Please look also for B<-bzip2> and +B<-gzip> for compression. + +The filename can contain the same tokens as defined in the B<-path> option. + +=item B<-bzip2> + +If B<-tar> was given the output tar file will be compressed by using the +L<bzip2> tool. The output file type will be renamed to C<.tar.bzip2>. + +=item B<-bzip2> + +If B<-tar> was given the output tar file will be compressed by using the +L<gzip> tool. The output file type will be renamed to C<.tar.gz>. + +=item B<-help> + +Print a brief help message and exits. + +=item B<-man> + +Prints the manual page and exits. + +=back + +=head1 DESCRIPTION + +This script is used to create a distribution directory and (optionally) a tar +file containing the distribution. + +The script is compiling the web application and creating out of the generated +.war file and other files a directory which follows the following structure: + + path + +---+-LICENSE + +-README + +-NOTES + +-TODO + +-AmavisAdmin.war + +-db (contents of the db sub directory) + +-docs + +----+pdf (generated PDF documentation) + +html(generated HTML documentation) + +txt (generated TXT documentation) + +=head1 AUTHOR + +Stephen Reindl <sr...@sr...> + +=head1 BUGS + +Probably many as this tool is used for development purposes only. Property changes on: amavisadmin/trunk/tools/build_script.pl ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |