directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1001715 - in /directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main: java/org/apache/directory/daemon/installers/ java/org/apache/directory/daemon/installers/archive/ resources/org/apache/directory/daemon/installers/...
Date Mon, 27 Sep 2010 12:53:56 GMT
Author: pamarcelot
Date: Mon Sep 27 12:53:56 2010
New Revision: 1001715

URL: http://svn.apache.org/viewvc?rev=1001715&view=rev
Log:
Fixed the archive installer for Unix machines.

Modified:
    directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/AbstractMojoCommand.java
    directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
    directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
    directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
    directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh

Modified: directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/AbstractMojoCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/AbstractMojoCommand.java?rev=1001715&r1=1001714&r2=1001715&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/AbstractMojoCommand.java
(original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/AbstractMojoCommand.java
Mon Sep 27 12:53:56 2010
@@ -139,12 +139,12 @@ public abstract class AbstractMojoComman
      */
     public void copyCommonFiles( GenerateMojo mojo ) throws Exception
     {
-        // Creating the installation layout and directories
-        InstallationLayout installationLayout = new InstallationLayout( getInstallationDirectory()
);
+        // Getting the installation layout and creating directories
+        InstallationLayout installationLayout = getInstallationLayout();
         installationLayout.mkdirs();
 
-        // Creating the instance layout and directories
-        InstanceLayout instanceLayout = new InstanceLayout( getInstanceDirectory() );
+        // Getting the instance layout and creating directories
+        InstanceLayout instanceLayout = getInstanceLayout();
         instanceLayout.mkdirs();
 
         MojoHelperUtils.copyDependencies( mojo, installationLayout );
@@ -166,8 +166,8 @@ public abstract class AbstractMojoComman
             getClass().getResourceAsStream( "/org/apache/directory/daemon/installers/log4j.properties"
),
             new File( instanceLayout.getConfDirectory(), "log4j.properties" ), true );
 
-        // Copying the 'apacheds' shell script (only for all OSes except Windows)
-        if ( !target.isOsNameWindows() )
+        // Copying the 'apacheds' shell script (only for Linux, Solaris or Mac OS X)
+        if ( target.isOsNameLinux() || target.isOsNameSolaris() || target.isOsNameMacOSX()
)
         {
             MojoHelperUtils.copyAsciiFile( mojo, filterProperties,
                 getClass().getResourceAsStream( "/org/apache/directory/daemon/installers/apacheds.init"
),
@@ -177,6 +177,30 @@ public abstract class AbstractMojoComman
 
 
     /**
+     * Gets the installation layout.
+     *
+     * @return
+     *      the installation layout
+     */
+    protected InstallationLayout getInstallationLayout()
+    {
+        return new InstallationLayout( getInstallationDirectory() );
+    }
+
+
+    /**
+     * Gets the instance layout.
+     *
+     * @return
+     *      the instance layout
+     */
+    protected InstanceLayout getInstanceLayout()
+    {
+        return new InstanceLayout( getInstanceDirectory() );
+    }
+
+
+    /**
      * Copies wrapper files to the installation layout.
      *
      * @param installationLayout

Modified: directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/Target.java?rev=1001715&r1=1001714&r2=1001715&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
(original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/Target.java
Mon Sep 27 12:53:56 2010
@@ -27,6 +27,8 @@ package org.apache.directory.daemon.inst
  */
 public class Target
 {
+    /** The OS name for 'Any' */
+    public static final String OS_NAME_ANY = "Any";
     /** The OS name for 'Linux' */
     public static final String OS_NAME_LINUX = "Linux";
     /** The OS name for 'Mac OS X' */
@@ -38,6 +40,8 @@ public class Target
 
     /** The OS architecture for 'amd64' */
     public static final String OS_ARCH_AMD64 = "amd64";
+    /** The OS architecture for 'Any' */
+    public static final String OS_ARCH_ANY = "Any";
     /** The OS architecture for 'i386' */
     public static final String OS_ARCH_I386 = "i386";
     /** The OS architecture for 'sparc' */

Modified: directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java?rev=1001715&r1=1001714&r2=1001715&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
(original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveInstallerCommand.java
Mon Sep 27 12:53:56 2010
@@ -25,8 +25,15 @@ import java.io.IOException;
 
 import org.apache.directory.daemon.installers.AbstractMojoCommand;
 import org.apache.directory.daemon.installers.GenerateMojo;
+import org.apache.directory.daemon.installers.MojoHelperUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.BZip2;
+import org.apache.tools.ant.taskdefs.GZip;
+import org.apache.tools.ant.taskdefs.Tar;
+import org.apache.tools.ant.taskdefs.Zip;
 import org.codehaus.plexus.util.FileUtils;
 
 
@@ -61,27 +68,127 @@ public class ArchiveInstallerCommand ext
      */
     public void execute() throws MojoExecutionException, MojoFailureException
     {
+        // Verifying the target
+        if ( !verifyTarget() )
+        {
+            return;
+        }
+
         // Getting the archive type
         String archiveType = target.getArchiveType();
 
-        // Checking for a null archive type
-        if ( archiveType == null )
+        log.info( "  Creating " + archiveType + " archive..." );
+
+        // Creating the target directory
+        getTargetDirectory().mkdirs();
+
+        log.info( "    Copying archive files" );
+
+        try
         {
-            log.warn( "Archive type is null!" );
-            log.warn( "The build will continue, but please check the archive type of this
installer " );
-            log.warn( "target" );
-            return;
+            // Creating the installation layout and copying files to it
+            copyCommonFiles( mojo );
+
+            // Copy bat and sh scripts to bin
+            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
+                "apacheds.bat" ), new File( getInstallationLayout().getBinDirectory(),
+                "apacheds.bat" ), false );
+            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
+                "apacheds.sh" ), new File( getInstallationLayout().getBinDirectory(),
+                "apacheds.sh" ), false );
+            MojoHelperUtils.copyAsciiFile( mojo, filterProperties, getClass().getResourceAsStream(
+                "cpappend.bat" ), new File( getInstallationLayout().getBinDirectory(),
+                "cpappend.bat" ), false );
+
+            // Removing unnecessary directories and files
+            FileUtils.deleteDirectory( getInstallationLayout().getConfDirectory() );
+            new File( getInstanceLayout().getConfDirectory(), "wrapper.conf" ).delete();
+            FileUtils.deleteDirectory( getInstanceLayout().getRunDirectory() );
+        }
+        catch ( Exception e )
+        {
+            log.error( e.getMessage() );
+            throw new MojoFailureException( "Failed to copy archive files." );
         }
 
-        // Checking for a known archive type
-        if ( !archiveType.equalsIgnoreCase( "zip" ) && !archiveType.equalsIgnoreCase(
"tar" )
-            && !archiveType.equalsIgnoreCase( "tar.gz" ) && !archiveType.equalsIgnoreCase(
"tar.bz2" ) )
+        // Generating the archive
+        log.info( "    Generating archive" );
+
+        // Creating the final file
+        String finalName = target.getFinalName();
+        if ( !finalName.endsWith( archiveType ) )
         {
-            log.warn( "Archive type is unknwown (" + archiveType + ")!" );
-            log.warn( "The build will continue, but please check the archive type of this
installer " );
-            log.warn( "target" );
-            return;
+            finalName = finalName + archiveType;
         }
+        File finalFile = new File( mojo.getOutputDirectory(), finalName );
+
+        // Preparing the Ant project
+        Project project = new Project();
+        project.setBaseDir( mojo.getOutputDirectory() );
+
+        // ZIP Archive
+        if ( archiveType.equalsIgnoreCase( "zip" ) )
+        {
+            Zip zipTask = new Zip();
+            zipTask.setProject( project );
+            zipTask.setDestFile( finalFile );
+            zipTask.setBasedir( getTargetDirectory() );
+            zipTask.setIncludes( getArchiveDirectory().getName() + "/**" );
+            zipTask.execute();
+        }
+        // TAR Archive
+        else if ( archiveType.equalsIgnoreCase( "tar" ) )
+        {
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( finalFile );
+            tarTask.setBasedir( getTargetDirectory() );
+            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
+            tarTask.execute();
+        }
+        // TAR.GZ Archive
+        else if ( archiveType.equalsIgnoreCase( "tar.gz" ) )
+        {
+            File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" );
+
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( tarFile );
+            tarTask.setBasedir( getTargetDirectory() );
+            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
+            tarTask.execute();
+
+            GZip gzipTask = new GZip();
+            gzipTask.setProject( project );
+            gzipTask.setDestfile( finalFile );
+            gzipTask.setSrc( tarFile );
+            gzipTask.execute();
+
+            tarFile.delete();
+        }
+        // TAR.BZ2 Archive
+        else if ( archiveType.equalsIgnoreCase( "tar.bz2" ) )
+        {
+            File tarFile = new File( mojo.getOutputDirectory(), target.getId() + ".tar" );
+
+            Tar tarTask = new Tar();
+            tarTask.setProject( project );
+            tarTask.setDestFile( tarFile );
+            tarTask.setBasedir( getTargetDirectory() );
+            tarTask.setIncludes( getArchiveDirectory().getName() + "/**" );
+            tarTask.execute();
+
+            BZip2 bzip2Task = new BZip2();
+            bzip2Task.setProject( project );
+            bzip2Task.setDestfile( finalFile );
+            bzip2Task.setSrc( tarFile );
+            bzip2Task.execute();
+
+            tarFile.delete();
+        }
+
+        log.info( "=> Archive Installer (" + archiveType + ") archive generated at "
+            + finalFile );
 
         // TODO FIXME
         //        File baseDirectory = target.getLayout().getInstallationDirectory();
@@ -120,115 +227,81 @@ public class ArchiveInstallerCommand ext
         //            throw new MojoFailureException( "Failed to copy Archive Installer resources
files." );
         //        }
         //
-        //        // Generating the Bin
-        //        log.info( "Generating Archive Installer" );
-        //
-        //        Project project = new Project();
-        //        project.setBaseDir( targetDirectory );
-        //
-        //        // ZIP Archive
-        //        if ( archiveType.equalsIgnoreCase( "zip" ) )
-        //        {
-        //            Zip zipTask = new Zip();
-        //            zipTask.setProject( project );
-        //            zipTask.setDestFile( new File( imagesDirectory, target.getFinalName()
) );
-        //            zipTask.setBasedir( targetDirectory );
-        //            zipTask.setIncludes( archiveDirectory.getName() + "/**" );
-        //            zipTask.execute();
-        //        }
-        //        // TAR Archive
-        //        else if ( archiveType.equalsIgnoreCase( "tar" ) )
-        //        {
-        //            Tar tarTask = new Tar();
-        //            tarTask.setProject( project );
-        //            tarTask.setDestFile( new File( imagesDirectory, target.getFinalName()
) );
-        //            tarTask.setBasedir( targetDirectory );
-        //            tarTask.setIncludes( archiveDirectory.getName() + "/**" );
-        //            tarTask.execute();
-        //        }
-        //        // TAR.GZ Archive
-        //        else if ( archiveType.equalsIgnoreCase( "tar.gz" ) )
-        //        {
-        //            File tarFile = new File( imagesDirectory, target.getId() + ".tar" );
-        //
-        //            Tar tarTask = new Tar();
-        //            tarTask.setProject( project );
-        //            tarTask.setDestFile( tarFile );
-        //            tarTask.setBasedir( targetDirectory );
-        //            tarTask.setIncludes( archiveDirectory.getName() + "/**" );
-        //            tarTask.execute();
-        //
-        //            GZip gzipTask = new GZip();
-        //            gzipTask.setProject( project );
-        //            gzipTask.setDestfile( new File( imagesDirectory, target.getFinalName()
) );
-        //            gzipTask.setSrc( tarFile );
-        //            gzipTask.execute();
-        //
-        //            tarFile.delete();
-        //        }
-        //        // TAR.BZ2 Archive
-        //        else if ( archiveType.equalsIgnoreCase( "tar.bz2" ) )
-        //        {
-        //            File tarFile = new File( imagesDirectory, target.getId() + ".tar" );
-        //
-        //            Tar tarTask = new Tar();
-        //            tarTask.setProject( project );
-        //            tarTask.setDestFile( tarFile );
-        //            tarTask.setBasedir( targetDirectory );
-        //            tarTask.setIncludes( archiveDirectory.getName() + "/**" );
-        //            tarTask.execute();
-        //
-        //            BZip2 bzip2Task = new BZip2();
-        //            bzip2Task.setProject( project );
-        //            bzip2Task.setDestfile( new File( imagesDirectory, target.getFinalName()
) );
-        //            bzip2Task.setSrc( tarFile );
-        //            bzip2Task.execute();
-        //
-        //            tarFile.delete();
-        //        }
+
         //
         //        log.info( "Archive Installer generated at " + new File( imagesDirectory,
target.getFinalName() ) );
     }
 
 
     /**
-     * Recursively copy files from the given source to the given destination.
+     * Verifies the target.
      *
-     * @param src
-     *      the source
-     * @param dest
-     *      the destination
-     * @throws IOException
-     *      If an error occurs when copying a file
+     * @return
+     *      <code>true</code> if the target is correct, 
+     *      <code>false</code> if not.
      */
-    public void copyFiles( File src, File dest ) throws IOException
+    private boolean verifyTarget()
     {
-        if ( src.isDirectory() )
-        {
-            dest.mkdirs();
+        // Getting the archive type
+        String archiveType = target.getArchiveType();
 
-            for ( File file : src.listFiles() )
-            {
-                copyFiles( file, new File( dest, file.getName() ) );
-            }
+        // Checking for a null archive type
+        if ( archiveType == null )
+        {
+            log.warn( "Archive type is null!" );
+            log.warn( "The build will continue, but please check the archive type of this
installer target" );
+            return false;
         }
-        else
+
+        // Checking for a known archive type
+        if ( !archiveType.equalsIgnoreCase( "zip" ) && !archiveType.equalsIgnoreCase(
"tar" )
+            && !archiveType.equalsIgnoreCase( "tar.gz" ) && !archiveType.equalsIgnoreCase(
"tar.bz2" ) )
         {
-            FileUtils.copyFile( src, dest );
+            log.warn( "Archive type is unknwown (" + archiveType + ")!" );
+            log.warn( "The build will continue, but please check the archive type of this
installer " );
+            log.warn( "target" );
+            return false;
         }
+
+        return true;
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
+    protected void initializeFilterProperties()
+    {
+        super.initializeFilterProperties();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
     public File getInstallationDirectory()
     {
-        // TODO Auto-generated method stub
-        return null;
+        return getArchiveDirectory();
     }
 
 
+    /**
+     * {@inheritDoc}
+     */
     public File getInstanceDirectory()
     {
-        // TODO Auto-generated method stub
-        return null;
+        return new File( getArchiveDirectory(), "instances/default" );
+    }
+
+
+    /**
+     * Gets the directory for the archive.
+     *
+     * @return
+     *      the directory for the archive
+     */
+    private File getArchiveDirectory()
+    {
+        return new File( getTargetDirectory(), "apacheds-" + mojo.getProject().getVersion()
);
     }
 }

Modified: directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java?rev=1001715&r1=1001714&r2=1001715&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
(original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/java/org/apache/directory/daemon/installers/archive/ArchiveTarget.java
Mon Sep 27 12:53:56 2010
@@ -45,6 +45,16 @@ public class ArchiveTarget extends Targe
 
 
     /**
+     * Creates a new instance of ArchiveTarget.
+     */
+    public ArchiveTarget()
+    {
+        setOsName( Target.OS_NAME_ANY );
+        setOsArch( Target.OS_ARCH_ANY );
+    }
+
+
+    /**
      * Gets the archive type.
      *
      * @return

Modified: directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
URL: http://svn.apache.org/viewvc/directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh?rev=1001715&r1=1001714&r2=1001715&view=diff
==============================================================================
--- directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
(original)
+++ directory/apacheds/branches/apacheds-apacheds-2.0/installers-plugin/src/main/resources/org/apache/directory/daemon/installers/archive/apacheds.sh
Mon Sep 27 12:53:56 2010
@@ -18,18 +18,47 @@
 #  under the License.
 #
 
-#---------------------------------#
-# dynamically build the classpath #
-#---------------------------------#
-ADS_CP=
-for i in `ls ./lib/`
-do
-  ADS_CP=${ADS_CP}:lib/${i}
-done
+# Checking the number of parameters
+if [ $# -eq 0 ]
+then
+    # Using 'default' as default instance name
+    ADS_INSTANCE_NAME="default"
+elif [ $# -eq 1 ]
+then
+    # Getting the instance name from the arguments
+    ADS_INSTANCE_NAME=$1
+else
+    # Printing usage information
+    echo "Usage: apacheds.sh <instance name>"
+    echo "If <instance name> is ommited, 'default' will be used."
+    exit 1
+fi
+
+# Pring instance information
+echo "Starting ApacheDS instance '$ADS_INSTANCE_NAME'..."
 
-for i in `ls ./lib/ext/`
+# Getting the fully qualified path to the script
+case $0 in 
+    /*) 
+        SCRIPT="$0" 
+        ;; 
+   ./*) 
+        SCRIPT="`pwd`/`echo $0 | sed -e 's/^[ ]*\.\///'`" 
+        ;; 
+     *) 
+        SCRIPT="`pwd`/`echo $0 | sed -e 's/^[ ]*//'`" 
+        ;; 
+esac 
+
+# Getting the working directory of the script
+ADS_PWD=`dirname $SCRIPT`/..
+
+# Building dynamically the classpath
+ADS_CP=
+for i in `ls $ADS_PWD/lib/`
 do
-  ADS_CP=${ADS_CP}:lib/ext/${i}
+  ADS_CP=${ADS_CP}:$ADS_PWD/lib/${i}
 done
 
-java -Dlog4j.configuration=file:conf/log4j.properties -Dapacheds.log.dir=logs -cp $ADS_CP
org.apache.directory.server.UberjarMain example.com
+# Launching ApacheDS
+java -Dlog4j.configuration=file:$ADS_PWD/instances/$ADS_INSTANCE_NAME/conf/log4j.properties
-Dapacheds.log.dir=$ADS_PWD/instances/$ADS_INSTANCE_NAME/log -cp $ADS_CP org.apache.directory.server.UberjarMain
$ADS_PWD/instances/$ADS_INSTANCE_NAME
\ No newline at end of file



Mime
View raw message