[Amavisadmin-svn] SF.net SVN: amavisadmin: [50] amavisadmin/trunk
Status: Beta
Brought to you by:
streindl
From: <str...@us...> - 2007-01-25 20:25:59
|
Revision: 50 http://amavisadmin.svn.sourceforge.net/amavisadmin/?rev=50&view=rev Author: streindl Date: 2007-01-25 12:25:43 -0800 (Thu, 25 Jan 2007) Log Message: ----------- Initial build script process ready Modified Paths: -------------- amavisadmin/trunk/tools/build_script.pl amavisadmin/trunk/tools/reposInfo.pl amavisadmin/trunk/webapp/build.xml amavisadmin/trunk/webapp/src/java/amavisadmin.properties.in amavisadmin/trunk/webapp/src/java/de/sreindl/amavisadmin/bo/VersionInfo.java Added Paths: ----------- amavisadmin/trunk/AUTHORS amavisadmin/trunk/NOTES amavisadmin/trunk/README amavisadmin/trunk/TODO amavisadmin/trunk/tools/version.pm Added: amavisadmin/trunk/AUTHORS =================================================================== --- amavisadmin/trunk/AUTHORS (rev 0) +++ amavisadmin/trunk/AUTHORS 2007-01-25 20:25:43 UTC (rev 50) @@ -0,0 +1,2 @@ +Stephen Reindl <sr...@sr...> +Project Lead and Maintainer Added: amavisadmin/trunk/NOTES =================================================================== --- amavisadmin/trunk/NOTES (rev 0) +++ amavisadmin/trunk/NOTES 2007-01-25 20:25:43 UTC (rev 50) @@ -0,0 +1 @@ +... please read the LICENSE and README files for details Added: amavisadmin/trunk/README =================================================================== --- amavisadmin/trunk/README (rev 0) +++ amavisadmin/trunk/README 2007-01-25 20:25:43 UTC (rev 50) @@ -0,0 +1,11 @@ +AmavisAdmin +=========== + +This tool helps administrating data stored by Amavisd-new in an Postgres SQL +database. + +... more to come + +for installation details, please refer to docs/txt/installationguide.txt. + + Added: amavisadmin/trunk/TODO =================================================================== --- amavisadmin/trunk/TODO (rev 0) +++ amavisadmin/trunk/TODO 2007-01-25 20:25:43 UTC (rev 50) @@ -0,0 +1,20 @@ +The following things are open -*- outline -*- + +* User Interface + The user interface might be overhauled or even replaced by something + different than now. Currently the user interface is build on Rave, an WebUI + based on JSF/JSP by Sun/Netbeans + +* Database +** Support for Black/Whitelisting +** Support for MySQL + +* Security +** Role based security settings +** JAAS enabled login (for enterprise integration) + +* Documentation +* User Guide + +* ... more to come + Modified: amavisadmin/trunk/tools/build_script.pl =================================================================== --- amavisadmin/trunk/tools/build_script.pl 2007-01-24 22:06:31 UTC (rev 49) +++ amavisadmin/trunk/tools/build_script.pl 2007-01-25 20:25:43 UTC (rev 50) @@ -1,31 +1,57 @@ #!/usr/bin/perl -w -# Script to create a target distribution +# 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 + +# 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; + +BEGIN { + push @INC, "tools"; # for the version stuff +} + +use version; + use Getopt::Long; use Pod::Usage; + +use Archive::Tar; use File::Path; use File::stat; +use File::Basename; +use File::Find; +use File::Copy; + use Cwd; + +use Date::Format; + use SVN::Client; +sub createTar(); +sub copy_dir($); sub replaceParams(); +sub copy_file($$); +sub copy_doc_dir(); +sub create_file_list(); -my $distdir = "dist"; +my $distdir = "%p-v%V"; my $cleandir = 0; my $help=0; my $man=0; +my $compressbzip2 = 0; +my $compressgzip = 0; my $createtar=undef; GetOptions("path|p=s" => \$distdir, "tar|t:s" => \$createtar, "clean|c!" => \$cleandir, + "bzip2" => \$compressbzip2, + "gzip" => \$compressgzip, "help|h" => \$help, "man|m" => \$man) or pod2usage (2); pod2usage(1) if ($help); @@ -38,7 +64,7 @@ $_info = $info; }; -my $modified = 0; +my $modified = ""; my $funcStatus = sub { $modified = "-modified"; @@ -63,10 +89,32 @@ replaceParams(); -print $distdir, "\n"; +if (defined $createtar) { + if ($createtar eq "") { + $createtar = $distdir . ".tar"; + } +} +my $tempdir = "$distdir/temp"; -exit 0; +my %files = ("LICENSE" => "LICENSE", + "README" => "README", + "TODO" => "TODO", + "NOTES" => "NOTES", + "AUTHORS" => "AUTHORS", + "$tempdir/AmavisAdmin.war" => "AmavisAdmin.war", + "\@db" => "db", + "$tempdir/docs/installationguide.pdf" => "docs/pdf/installationguide.pdf", + "$tempdir/docs/installationguide.txt" => "docs/txt/installationguide.txt", + "\!$tempdir/docs/installationguide/" => 'docs/html/installationguide/', + ); + + +print "Output to $distdir\n"; +if (defined $createtar) { + print "Creating tar file $createtar\n"; +} + if (-d "$distdir") { if ($cleandir) { my $stat = stat($distdir); @@ -84,12 +132,181 @@ mkpath ($distdir) or die "Cannot create directory $distdir"; +# step 0 +# create intermediate directories which will be deleted afterwards +mkdir $tempdir; + +# step 1: run ant +my @antArgs=("-Dbuild.dir=" . getcwd() . "/$tempdir", + "-Ddist.dir=" . getcwd() . "/$tempdir", + "-buildfile", "webapp/build.xml", + "clean", + "dist"); + +system "ant", @antArgs; + +if ($? != 0) { + die "Build failed. Please check before continuing"; +} + +# step 2: documentation +copy_doc_dir (); +system "cd $tempdir/docs && touch *.xml && make clean && make"; + +if ($? != 0) { + die "Documentation build failed. Please check before continuing"; +} + +my $copydir_target = ""; +my $skip_dir = 0; + +# step 3: Copy/Move files +foreach my $file (keys %files) { + if ($file =~ /^@.*/) { + my $from_file = substr($file, 1); + copy_dir($from_file); + } elsif ($file =~ /^!.*/) { + # special dir + my $from_file = substr($file, 1); + $skip_dir = length ($from_file); + $copydir_target = $files{$file}; + copy_dir($from_file); + $copydir_target = ""; # reset dir target + } else { + copy_file($file, $files{$file}); + } +} + +# step 4: cleanup temp dir +rmtree ("$tempdir"); + + +# step 5: create CONTENTS file + +my @file_list = (); +create_file_list (); +open OUT, ">$distdir/CONTENTS" or die "Cannot create contents file ($!)"; +print OUT + "This file contains a list of all files included in this distribution.\n"; +print OUT + "Please read the file LICENSE!\n"; + +foreach my $line (@file_list) { + print OUT $line, "\n"; +} +close OUT; + +# step 6: Tar and compression +if (defined $createtar) { + createTar(); + + if ($compressbzip2) { + my $mod = "IO::Compress::Bzip2"; + unless (eval "require $mod") { + die "Bzip2 compression is required from here\n"; + } + use IO::Compress::Bzip2 qw (bzip2 $Bzip2Error); + bzip2 $createtar => $createtar . ".bz2" + or die "bzip2 failed: $Bzip2Error\n"; + unlink $createtar; # remove tar file + } elsif ($compressgzip) { + my $mod = "IO::Compress::Gzip"; + unless (eval "require $mod") { + die "Gzip compression is required from here\n"; + } + use IO::Compress::Gzip qw (gzip $GzipError); + gzip $createtar => $createtar . ".bz2" + or die "gzip failed: $GzipError\n"; + unlink $createtar; # remove tar file + } + # in case of tar output, remove the distribution directory. + rmtree "$distdir"; +} + + +exit 0; + +sub createTar() { + my $tar = Archive::Tar->new; + + $tar->add_files(@file_list); + + $tar->write($createtar) or die "Cannot create tar file ($!)"; +} + +sub file_list_item() { + my $file = $File::Find::name; + + if (-f "$file") { + push @file_list, $file; + } +} + +sub create_file_list() { + find ({wanted => \&file_list_item, no_chdir => 1 }, $distdir); +} + +sub callback_doc_file() { + my $name = $File::Find::name; + return if ($name =~ /\.svn/); + my $stat = lstat($name); + if (-l $name) { + my $link = readlink ($name); + symlink ($link, "$tempdir/$name"); + } elsif (-d $name) { + mkdir "$tempdir/$name"; + } else { + copy ($name, "$tempdir/$name"); + } +} + + +sub copy_doc_dir () { + find({wanted => \&callback_doc_file, no_chdir => 1 }, "docs"); +} + + +sub callback_single_file() { + my $name = $File::Find::name; + return if ($name =~ /\.svn/); + my $to = $name; + + if ($copydir_target ne "") { + $to = $copydir_target . substr ($name, $skip_dir); + } + + if (-d $name) { + mkpath "$distdir/$to" or die "Cannot create $distdir/$to ($!)"; + } else { + copy_file($name, $to); + } +} + +sub copy_dir($) { + my $path = shift; + find({wanted => \&callback_single_file, no_chdir => 1 }, $path); +} + +sub copy_file($$) { + my ($from, $to) = @_; + $to = "$distdir/$to"; + print "Copy $from -> $to\n"; + my $dir = dirname($to); + if (! -e "$dir") { + mkpath ($dir) or die "Cannot create $dir ($!)"; + } + copy ($from, $to) or die "Copy failed ($!)"; +} + sub replaceParams() { $distdir =~ s/\%V/\%v-r\%r-\%T\%m/g; - $distdir =~ s/\%v/1.0/g; + my $version = $version::AmavisVersion; + $distdir =~ s/\%v/$version/g; $distdir =~ s/\%r/$revision/g; - $distdir =~ s/\%d/YYYY-MM-DD/g; - $distdir =~ s/\%t/YYYYMMDDhhmmss/g; + my $datestamp=time2str("%Y-%m-%d", time()); + my $timestamp=time2str("%Y%m%d%I%M%S", time()); + $distdir =~ s/\%d/$datestamp/g; + $distdir =~ s/\%t/$timestamp/g; $distdir =~ s/\%T/$branch/g; $distdir =~ s/\%m/$modified/g; $distdir =~ s/\%p/AmavisAdmin/g; @@ -143,8 +360,9 @@ =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>. +This token will be replaced by the version (taken from +F<tools/version.pm>). The version will be in the form +C<major.minor>, e.g. B<1.0>. =item B<%V> @@ -242,6 +460,7 @@ +-README +-NOTES +-TODO + +-CONTENTS (list of files in directory) +-AmavisAdmin.war +-db (contents of the db sub directory) +-docs @@ -249,6 +468,31 @@ +html(generated HTML documentation) +txt (generated TXT documentation) +=head2 File copying + +Files are copied according to the hash %files. This hash maps a source file +related to the project base directory to the target folder. To copy files created during the process, use the C<$tempdir> variable for reference. For example, the mapping + + "$tempdir/AmavisAdmin.war" => "AmavisAdmin.war" + +copies the generated war file from it's temporary location to the target +location. + +=head3 Special copy commands + +There's the option to copy complete trees out of the source tree to the target tree. This can be done by prefixing the source tree key by an B<@> sign. The following line copies the complete C<db> folder: + + "\@db" => "db" + +The mapping result is not used in this case. If you want to copy a directory +from another location (e.g. the C<$tempdir>) path, you should use the special +indicator B<!>. The following example copies all files from the location +B<$tempdir/docs/installationguide/> to the location +B<docs/html/installationguide/>. + + "\!$tempdir/docs/installationguide/" => 'docs/html/installationguide/' + + =head1 AUTHOR Stephen Reindl <sr...@sr...> Modified: amavisadmin/trunk/tools/reposInfo.pl =================================================================== --- amavisadmin/trunk/tools/reposInfo.pl 2007-01-24 22:06:31 UTC (rev 49) +++ amavisadmin/trunk/tools/reposInfo.pl 2007-01-25 20:25:43 UTC (rev 50) @@ -13,12 +13,18 @@ # this is an development version. use strict; +BEGIN { + push @INC, "../tools"; # for ant + push @INC, "tools"; # for root dir +} + use SVN::Client; use SVK::Command::Info; use SVK; use SVK::XD; use Cwd; +use version; my $op = shift; @@ -40,13 +46,10 @@ my $cwd = getcwd(); $ctx->info( $cwd, undef, undef, \&funcRev, 0 ); $ctx->status( $cwd, undef, $funcStatus, 1, 0, 0, 0); +print "version=", $version::AmavisVersion, "\n"; +print "dbversion=", $version::DatabaseVersion, "\n"; print "revision=", $_info->rev, "\n"; print "clean_build=", $statusChanged ? "false" : "true", "\n"; -if ($cwd =~ /\/home\//) { - print "build_type=private\n"; -} else { - print "build_type=batch\n"; -} my $url = $_info->URL; if ($url =~ /trunk/) { Added: amavisadmin/trunk/tools/version.pm =================================================================== --- amavisadmin/trunk/tools/version.pm (rev 0) +++ amavisadmin/trunk/tools/version.pm 2007-01-25 20:25:43 UTC (rev 50) @@ -0,0 +1,37 @@ +# This file has only one purpose: In contains the version string used to build +# conficuration files and other topics where the version number is important. + +package version; + +use strict; +use warnings; + +BEGIN { + use Exporter(); + + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + # Version of this module (not related to the AmavisAdmin version) + $VERSION = 1.00; + + @ISA=qw(Exporter); + + @EXPORT=(); + %EXPORT_TAGS=(); + @EXPORT_OK= qw ($AmavisVersion $DatabaseVersion); +} + +our @EXPORT_OK; + +our $AmavisVersion; +our $DatabaseVersion; + +# Here the version is set +#>>>>>>>>>>>>>>>>>>>>>>>> +$AmavisVersion = "1.0"; +$DatabaseVersion = "1"; +#<<<<<<<<<<<<<<<<<<<<<<<< + +END { } + +1; Modified: amavisadmin/trunk/webapp/build.xml =================================================================== --- amavisadmin/trunk/webapp/build.xml 2007-01-24 22:06:31 UTC (rev 49) +++ amavisadmin/trunk/webapp/build.xml 2007-01-25 20:25:43 UTC (rev 50) @@ -84,8 +84,8 @@ <format property="build.timestamp" pattern="yyyyMMdd'T'HHmmssZ" locale="en"/> </tstamp> - <exec executable="/usr/bin/perl"> - <arg value="tools/reposInfo.pl" /> + <exec executable="/usr/bin/perl" failonerror="true"> + <arg value="../tools/reposInfo.pl" /> <redirector output="reposinfo.properties" /> </exec> <copy file="${src.dir}/amavisadmin.properties.in" Modified: amavisadmin/trunk/webapp/src/java/amavisadmin.properties.in =================================================================== --- amavisadmin/trunk/webapp/src/java/amavisadmin.properties.in 2007-01-24 22:06:31 UTC (rev 49) +++ amavisadmin/trunk/webapp/src/java/amavisadmin.properties.in 2007-01-25 20:25:43 UTC (rev 50) @@ -1,35 +1,31 @@ -##/* -## * Copyright (C) 2006,2007 Stephen Reindl. -## * -## * Licensed under the Apache License, Version 2.0 (the "License"); -## * you may not use this file except in compliance with the License. -## * You may obtain a copy of the License at -## * -## * http://www.apache.org/licenses/LICENSE-2.0 -## * -## * Unless required by applicable law or agreed to in writing, software -## * distributed under the License is distributed on an "AS IS" BASIS, -## * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## * See the License for the specific language governing permissions and -## * limitations under the License. -## */ - - -# AmavisAdmin properties file -# This file contains basic settings - -amavisadmin.major = 0 -amavisadmin.minor = 1 - -# those fields are translated automatically -amavisadmin.branch = @branch@ -amavisadmin.build = @revision@ -amavisadmin.build_type = @build_type@ -amavisadmin.clean_build = @clean_build@ - -# If you ever change the datamodel, please increase this value -# and provide an upgrade script in the db topic -amavisadmin.db_version = 1 - -# Build time -amavisadmin.buildtime = @TSTAMP@ +##/* +## * Copyright (C) 2006,2007 Stephen Reindl. +## * +## * Licensed under the Apache License, Version 2.0 (the "License"); +## * you may not use this file except in compliance with the License. +## * You may obtain a copy of the License at +## * +## * http://www.apache.org/licenses/LICENSE-2.0 +## * +## * Unless required by applicable law or agreed to in writing, software +## * distributed under the License is distributed on an "AS IS" BASIS, +## * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## * See the License for the specific language governing permissions and +## * limitations under the License. +## */ + + +# AmavisAdmin properties file +# This file contains basic settings + +amavisadmin.version = @version@ + +# those fields are translated automatically +amavisadmin.branch = @branch@ +amavisadmin.build = @revision@ +amavisadmin.clean_build = @clean_build@ + +amavisadmin.db_version = @dbversion@ + +# Build time +amavisadmin.buildtime = @TSTAMP@ Modified: amavisadmin/trunk/webapp/src/java/de/sreindl/amavisadmin/bo/VersionInfo.java =================================================================== --- amavisadmin/trunk/webapp/src/java/de/sreindl/amavisadmin/bo/VersionInfo.java 2007-01-24 22:06:31 UTC (rev 49) +++ amavisadmin/trunk/webapp/src/java/de/sreindl/amavisadmin/bo/VersionInfo.java 2007-01-25 20:25:43 UTC (rev 50) @@ -85,14 +85,8 @@ if (_localVersion == null) { initProps(); StringBuffer str = new StringBuffer(20); - str.append(props.getProperty("amavisadmin.major", "Unknown")); - str.append('.'); - str.append(props.getProperty("amavisadmin.minor", "unknown")); + str.append(props.getProperty("amavisadmin.version", "Unknown")); - String buildType = props.getProperty("amavisadmin.build_type"); - if (buildType.equals("local")) { - str.append (" local"); - } str.append (" build "); str.append (props.getProperty("amavisadmin.build")); str.append (" ("); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |