You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by pa...@apache.org on 2008/04/01 18:20:54 UTC
svn commit: r643469 [1/3] - in
/directory/daemon/branches/bigbang/plugin/src/main:
java/org/apache/directory/daemon/installers/
java/org/apache/directory/daemon/installers/bin/
java/org/apache/directory/daemon/installers/deb/
java/org/apache/directory/...
Author: pamarcelot
Date: Tue Apr 1 09:20:44 2008
New Revision: 643469
URL: http://svn.apache.org/viewvc?rev=643469&view=rev
Log:
Added new types of installer for ApacheDS: a Mac OS X .pkg installer, a Debian .deb installer, a Linux Binary .bin installer.
Added:
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinInstallerCommand.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinTarget.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebInstallerCommand.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebTarget.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgInstallerCommand.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgTarget.java
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-default.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-init
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/bootstrap.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/createInstaller.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/functions.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/install.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/variables.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/apacheds-default.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/apacheds-init
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/apacheds.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/control
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/deb/postinst
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/DS_Store (with props)
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/Info.plist
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/License.rtf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/apacheds-default.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/apacheds-usr-bin.sh
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/apacheds.conf
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/apacheds.init
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/dmg-background.png (with props)
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/org.apache.directory.server.plist
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/pkg-background.tiff (with props)
directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/pkg/postflight
Removed:
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/DebTarget.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/PkgTarget.java
Modified:
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/MojoHelperUtils.java
directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
Modified: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java?rev=643469&r1=643468&r2=643469&view=diff
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java (original)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/CreateImageCommand.java Tue Apr 1 09:20:44 2008
@@ -238,153 +238,99 @@
// Copy Wrapper Files
// -------------------------------------------------------------------
- // TODO I really wonder if wrapper bin, lib for macosx and solaris don't need to be
- // copied in case if os?
- if ( target.getDaemonFramework().equalsIgnoreCase( "tanuki" ) )
+ if ( target.getOsName().equals( "linux" ) && target.getOsArch().equals( "i386" )
+ && target.getDaemonFramework().equals( "tanuki" ) )
{
- if ( target.getOsName().equalsIgnoreCase( "linux" ) )
+ try
{
- if ( target.getOsArch().equals( "i386" ) )
- {
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/bin/wrapper-linux-x86-32" ), new File( layout.getBinDirectory(), target
- .getApplication().getName() ) );
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/lib/libwrapper-linux-x86-32.so" ), new File( layout.getLibDirectory(),
- "libwrapper.so" ) );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" );
- }
- }
- else
- {
- if ( target.getOsArch().equals( "x86_64" ) )
- {
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/bin/wrapper-linux-x86-64" ), new File( layout.getBinDirectory(), target
- .getApplication().getName() ) );
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/lib/libwrapper-linux-x86-64.so" ), new File( layout.getLibDirectory(),
- "libwrapper.so" ) );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException(
- "Failed to copy Tanuki binary files to lib and bin directories" );
- }
- }
- else
- {
- throw new MojoFailureException( "OsName='linux' supports only OsArc='[i386|x86_64]'" );
- }
- }
- }
- else
- {
- if ( target.getOsFamily().equalsIgnoreCase( "windows" ) )
- {
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/bin/wrapper-windows-x86-32.exe" ), new File( layout.getBinDirectory(), target
- .getApplication().getName() ) );
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
- "wrapper/lib/wrapper-windows-x86-32.dll" ), new File( layout.getLibDirectory(),
- "libwrapper.so" ) );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" );
- }
- }
- else
- {
- throw new MojoFailureException(
- "Not supported for configured daemon framework. OsName=" + target.getOsName() + " OsFamily=" + target.getOsFamily());
- }
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "wrapper/bin/wrapper-linux-x86-32" ),
+ new File( layout.getBinDirectory(), target.getApplication().getName() ) );
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
+ "wrapper/lib/libwrapper-linux-x86-32.so" ), new File( layout.getLibDirectory(), "libwrapper.so" ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" );
+ }
+ }
+
+ if ( target.getOsName().equals( "linux" )
+ && ( target.getOsArch().equals( "x86_64" ) || target.getOsArch().equals( "amd64" ) )
+ && target.getDaemonFramework().equals( "tanuki" ) )
+ {
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "wrapper/bin/wrapper-linux-x86-64" ),
+ new File( layout.getBinDirectory(), target.getApplication().getName() ) );
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
+ "wrapper/lib/libwrapper-linux-x86-64.so" ), new File( layout.getLibDirectory(), "libwrapper.so" ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" );
+ }
+ }
+
+ if ( target.getOsName().equalsIgnoreCase( "mac os x" ) && target.getDaemonFramework().equals( "tanuki" ) )
+ {
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
+ "wrapper/bin/wrapper-macosx-universal-32" ), new File( layout.getBinDirectory(), target
+ .getApplication().getName() ) );
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream(
+ "wrapper/lib/libwrapper-macosx-universal-32.jnilib" ), new File( layout.getLibDirectory(),
+ "libwrapper.jnilib" ) );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to copy Tanuki binary files to lib and bin directories" );
}
}
- else
+
+ // now copy over the jsvc executable renaming it to the mymojo.getApplicationName()
+ if ( target.getOsName().equals( "sunos" ) && target.getOsArch().equals( "sparc" ) )
{
- // now copy over the jsvc executable renaming it to the mymojo.getApplicationName()
- if ( target.getOsName().equalsIgnoreCase( "sunos" ) )
+ File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_solaris_sparc" ), executable );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoFailureException( "Failed to copy jsvc executable file "
+ + getClass().getResource( "jsvc_solaris_sparc" ) + " into position " + executable.getAbsolutePath() );
+ }
+ }
+
+ if ( target.getOsName().equals( "sunos" ) && target.getOsArch().equals( "i386" ) )
+ {
+ File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_solaris_i386" ), executable );
+ }
+ catch ( IOException e )
{
- if ( target.getOsArch().equalsIgnoreCase( "sparc" ) )
- {
- File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_solaris_sparc" ),
- executable );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy jsvc executable file "
- + getClass().getResource( "jsvc_solaris_sparc" ) + " into position "
- + executable.getAbsolutePath() );
- }
- }
- else
- {
- if ( target.getOsArch().equals( "i386" ) )
- {
- File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_solaris_i386" ),
- executable );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy jsvc executable file "
- + getClass().getResource( "jsvc_solaris_i386" ) + " into position "
- + executable.getAbsolutePath() );
- }
- }
- else
- {
- throw new MojoFailureException( "OsName='sunos' supports only OsArc='[sparc|i386]'" );
- }
- }
- }
- else
- {
- // now copy over the jsvc executable renaming it to the mymojo.getApplicationName()
- if ( target.getOsName().equalsIgnoreCase( "macosx" ) )
- {
- if ( target.getOsArch().equalsIgnoreCase( "ppc" ) )
- {
- File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
- try
- {
- MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_macosx_ppc" ),
- executable );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "Failed to copy jsvc executable file "
- + getClass().getResource( "jsvc_macosx_ppc" ) + " into position "
- + executable.getAbsolutePath() );
- }
- }
- else
- {
- throw new MojoFailureException( "OsName='macosx' supports only OsArch='[ppc]'" );
- }
- }
- else
- {
- throw new MojoFailureException( "OsName='" + target.getOsName()
- + "' is not supported for build process." );
- }
+ throw new MojoFailureException( "Failed to copy jsvc executable file "
+ + getClass().getResource( "jsvc_solaris_i386" ) + " into position " + executable.getAbsolutePath() );
}
}
+
+ // now copy over the jsvc executable renaming it to the mymojo.getApplicationName()
+ // if ( target.getOsName().equals( "macosx" ) && target.getOsArch().equals( "ppc" ) )
+ // {
+ // File executable = new File( layout.getBinDirectory(), target.getApplication().getName() );
+ // try
+ // {
+ // MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "jsvc_macosx_ppc" ), executable );
+ // }
+ // catch ( IOException e )
+ // {
+ // throw new MojoFailureException( "Failed to copy jsvc executable file "
+ // + getClass().getResource( "jsvc_macosx_ppc" ) + " into position " + executable.getAbsolutePath() );
+ // }
+ // }
target.setLibArtifacts( MojoHelperUtils.copyDependencies( mymojo, layout ) );
Modified: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/MojoHelperUtils.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/MojoHelperUtils.java?rev=643469&r1=643468&r2=643469&view=diff
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/MojoHelperUtils.java (original)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/MojoHelperUtils.java Tue Apr 1 09:20:44 2008
@@ -139,7 +139,7 @@
mymojo.getLog().info( " Including artifacts: " );
mymojo.getLog().info( " -------------------" );
Iterator artifacts = mymojo.getProject().getRuntimeArtifacts().iterator();
-
+
while ( artifacts.hasNext() )
{
artifact = ( Artifact ) artifacts.next();
@@ -237,6 +237,34 @@
{
throw new MojoFailureException( "Execution of '" + cmdString + "' resulted in a non-zero exit value: "
+ task.getExitValue() );
+ }
+ }
+
+
+ /**
+ * Recursively copy files from the given source to the given destination.
+ *
+ * @param src
+ * the source
+ * @param dest
+ * the destination
+ * @throws IOException
+ * If an error occurs when copying a file
+ */
+ public static void copyFiles( File src, File dest ) throws IOException
+ {
+ if ( src.isDirectory() )
+ {
+ dest.mkdirs();
+
+ for ( File file : src.listFiles() )
+ {
+ copyFiles( file, new File( dest, file.getName() ) );
+ }
+ }
+ else
+ {
+ FileUtils.copyFile( src, dest );
}
}
}
Modified: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java?rev=643469&r1=643468&r2=643469&view=diff
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java (original)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/ServiceInstallersMojo.java Tue Apr 1 09:20:44 2008
@@ -28,15 +28,20 @@
import java.util.List;
import java.util.Set;
+import org.apache.directory.daemon.installers.bin.BinInstallerCommand;
+import org.apache.directory.daemon.installers.bin.BinTarget;
+import org.apache.directory.daemon.installers.deb.DebInstallerCommand;
+import org.apache.directory.daemon.installers.deb.DebTarget;
import org.apache.directory.daemon.installers.inno.InnoInstallerCommand;
import org.apache.directory.daemon.installers.inno.InnoTarget;
import org.apache.directory.daemon.installers.izpack.IzPackInstallerCommand;
import org.apache.directory.daemon.installers.izpack.IzPackTarget;
+import org.apache.directory.daemon.installers.nsis.NsisInstallerCommand;
+import org.apache.directory.daemon.installers.nsis.NsisTarget;
+import org.apache.directory.daemon.installers.pkg.PkgInstallerCommand;
+import org.apache.directory.daemon.installers.pkg.PkgTarget;
import org.apache.directory.daemon.installers.rpm.RpmInstallerCommand;
import org.apache.directory.daemon.installers.rpm.RpmTarget;
-import org.apache.directory.daemon.installers.nsis.NsisTarget;
-import org.apache.directory.daemon.installers.nsis.NsisInstallerCommand;
-
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Developer;
import org.apache.maven.model.MailingList;
@@ -118,6 +123,11 @@
* @parameter
*/
private DebTarget[] debTargets;
+
+ /**
+ * @parameter
+ */
+ private BinTarget[] binTargets;
/**
* @parameter
@@ -250,6 +260,27 @@
rpmCmd = new RpmInstallerCommand( this, ( RpmTarget ) target );
rpmCmd.execute();
}
+
+ if ( target instanceof PkgTarget )
+ {
+ PkgInstallerCommand pkgCmd = null;
+ pkgCmd = new PkgInstallerCommand( this, ( PkgTarget ) target );
+ pkgCmd.execute();
+ }
+
+ if ( target instanceof DebTarget )
+ {
+ DebInstallerCommand debCmd = null;
+ debCmd = new DebInstallerCommand( this, ( DebTarget ) target );
+ debCmd.execute();
+ }
+
+ if ( target instanceof BinTarget )
+ {
+ BinInstallerCommand binCmd = null;
+ binCmd = new BinInstallerCommand( this, ( BinTarget ) target );
+ binCmd.execute();
+ }
}
}
@@ -263,6 +294,7 @@
addAll( allTargets, rpmTargets );
addAll( allTargets, debTargets );
addAll( allTargets, pkgTargets );
+ addAll( allTargets, binTargets );
}
@@ -538,7 +570,7 @@
getLog().info( "daemonFramework: " + target.getDaemonFramework() );
getLog().info( "loggerConfigurationFile: " + target.getLoggerConfigurationFile() );
getLog().info( "bootstrapperConfigurationFiles: " + target.getBootstrapperConfigurationFile() );
- getLog().info( "serverConfigurationFil: " + target.getServerConfigurationFile() );
+ getLog().info( "serverConfigurationFile: " + target.getServerConfigurationFile() );
}
}
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinInstallerCommand.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinInstallerCommand.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinInstallerCommand.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,255 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.bin;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.directory.daemon.installers.MojoCommand;
+import org.apache.directory.daemon.installers.MojoHelperUtils;
+import org.apache.directory.daemon.installers.ServiceInstallersMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Bin (Binary) Installer command for Linux.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 434414 $
+ */
+public class BinInstallerCommand extends MojoCommand
+{
+ private final Properties filterProperties = new Properties( System.getProperties() );
+ /** The PKG target */
+ private final BinTarget target;
+ /** The Maven logger */
+ private final Log log;
+ /** The sh utility executable */
+ private File shUtility = new File( "/bin/sh" );
+ /** The final name of the installer */
+ private String finalName;
+
+
+ /**
+ * Creates a new instance of BinInstallerCommand.
+ *
+ * @param mymojo
+ * the Server Installers Mojo
+ * @param target
+ * the Bin target
+ */
+ public BinInstallerCommand( ServiceInstallersMojo mymojo, BinTarget target )
+ {
+ super( mymojo );
+ this.target = target;
+ this.log = mymojo.getLog();
+ initializeFiltering();
+ }
+
+
+ /**
+ * Performs the following:
+ * <ol>
+ * <li>Bail if target is not for Linux</li>
+ * <li>Creates the Mac OS X PKG Installer for Apache DS</li>
+ * <li>Package it in a Mac OS X DMG (Disk iMaGe)</li>
+ * </ol>
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ // Verifying the target is macosx
+ if ( !target.getOsFamily().equals( "linux" ) )
+ {
+ log.warn( "Bin installer can only be targeted for linux platforms!" );
+ log.warn( "The build will continue, but please check the the platform of this installer " );
+ log.warn( "target" );
+ return;
+ }
+
+ // Verifying the hdiutil utility exists
+ if ( !shUtility.exists() )
+ {
+ log.warn( "Cannot find sh utility at this location: " + shUtility );
+ log.warn( "The build will continue, but please check the location of your sh " );
+ log.warn( "utility." );
+ return;
+ }
+
+ File baseDirectory = target.getLayout().getBaseDirectory();
+ File imagesDirectory = baseDirectory.getParentFile();
+
+ log.info( "Creating Bin Installer..." );
+
+ // Creating the package directory
+ File binDirectory = new File( imagesDirectory, target.getId() + "-bin" );
+ binDirectory.mkdirs();
+
+ log.info( "Copying Bin installer files" );
+
+ // Copying the apacheds files in the root directory
+ File binRootDirectory = new File( binDirectory, "root" );
+ binRootDirectory.mkdirs();
+ File binRootServerDirectory = new File( binRootDirectory, "server" );
+ try
+ {
+ copyFiles( baseDirectory, binRootServerDirectory );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy image (" + target.getLayout().getBaseDirectory()
+ + ") to the Bin directory (" + binRootDirectory + ")" );
+ }
+
+ // Create instance and sh directory
+ File binRootInstanceDirectory = new File( binRootDirectory, "instance" );
+ binRootInstanceDirectory.mkdirs();
+ File binShDirectory = new File( binDirectory, "sh" );
+ binShDirectory.mkdirs();
+
+ // Copying the resources files
+ try
+ {
+ // Copying the apacheds.conf file to the server installation layout
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.conf" ),
+ new File( binRootServerDirectory, "conf/apacheds.conf" ), false );
+
+ // Copying the default instance apacheds.conf file
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "apacheds-default.conf" ), new File( binRootInstanceDirectory, "apacheds.conf" ), false );
+
+ // Copying the log4j.properties file for the default instance
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootServerDirectory,
+ "conf/log4j.properties" ), new File( binRootInstanceDirectory, "log4j.properties" ), false );
+
+ // Copying the server.xml file for the default instance
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( binRootServerDirectory,
+ "conf/server.xml" ), new File( binRootInstanceDirectory, "server.xml" ), false );
+
+ // Copying the apacheds-init script file for the default instance
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds-init" ),
+ new File( binRootInstanceDirectory, "apacheds-init" ), true );
+
+ // Copying shell script utilities for the installer
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "bootstrap.sh" ),
+ new File( binDirectory, "bootstrap.sh" ), true );
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "createInstaller.sh" ), new File( binDirectory, "createInstaller.sh" ), true );
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "functions.sh" ),
+ new File( binShDirectory, "functions.sh" ), false );
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "install.sh" ),
+ new File( binShDirectory, "install.sh" ), false );
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "variables.sh" ),
+ new File( binShDirectory, "variables.sh" ), false );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy Bin resources files." );
+ }
+
+ // Generating the Bin
+ log.info( "Generating Bin Installer" );
+ Execute createBinTask = new Execute();
+ String[] cmd = new String[]
+ { shUtility.getAbsolutePath(), "createInstaller.sh" };
+ createBinTask.setCommandline( cmd );
+ createBinTask.setSpawn( true );
+ createBinTask.setWorkingDirectory( binDirectory );
+ try
+ {
+ createBinTask.execute();
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed while trying to generate the Bin: " + e.getMessage() );
+ }
+
+ log.info( "Bin Installer generated at " + new File( imagesDirectory, finalName ) );
+ }
+
+
+ /**
+ * Recursively copy files from the given source to the given destination.
+ *
+ * @param src
+ * the source
+ * @param dest
+ * the destination
+ * @throws IOException
+ * If an error occurs when copying a file
+ */
+ public void copyFiles( File src, File dest ) throws IOException
+ {
+ if ( src.isDirectory() )
+ {
+ dest.mkdirs();
+
+ for ( File file : src.listFiles() )
+ {
+ copyFiles( file, new File( dest, file.getName() ) );
+ }
+ }
+ else
+ {
+ FileUtils.copyFile( src, dest );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.daemon.installers.MojoCommand#getFilterProperties()
+ */
+ public Properties getFilterProperties()
+ {
+ return filterProperties;
+ }
+
+
+ private void initializeFiltering()
+ {
+ filterProperties.putAll( mymojo.getProject().getProperties() );
+ filterProperties.put( "app", target.getApplication().getName() );
+ String version = target.getApplication().getVersion();
+ if ( version != null )
+ {
+ filterProperties.put( "app.version", version );
+ }
+ else
+ {
+ filterProperties.put( "app.version", "1.0" );
+ }
+ filterProperties.put( "tmpArchive", "__tmp.tar.gz" );
+ finalName = target.getFinalName();
+ if ( !finalName.endsWith( ".bin" ) )
+ {
+ finalName = finalName + ".bin";
+ }
+ filterProperties.put( "finalName", finalName );
+ filterProperties.put( "apacheds.version", target.getApplication().getVersion() );
+ }
+}
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinTarget.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinTarget.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinTarget.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/bin/BinTarget.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.bin;
+
+
+import org.apache.directory.daemon.installers.Target;
+
+
+/**
+ * A Bin installer for the Linux platform.
+ *
+ * To create a Bin installer we use the shell (SH) utility that is bundled
+ * in every Linux.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class BinTarget extends Target
+{
+ /** The wrapper executable path */
+ private String wrapperExecutablePath = "src/main/installers/wrapper/bin/wrapper-windows-x86-32.exe";
+
+
+ /**
+ * Gets the Wrapper executable path.
+ *
+ * @return
+ * the wrapper executable path
+ */
+ public String getWrapperExecutablePath()
+ {
+ return wrapperExecutablePath;
+ }
+
+
+ /**
+ * Sets the Wrapper executable path.
+ *
+ * @param wrapperExecutablePath
+ * the wrapper executable path
+ */
+ public void setWrapperExecutablePath( String wrapperExecutablePath )
+ {
+ this.wrapperExecutablePath = wrapperExecutablePath;
+ }
+}
\ No newline at end of file
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebInstallerCommand.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebInstallerCommand.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebInstallerCommand.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,253 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.deb;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.directory.daemon.installers.MojoCommand;
+import org.apache.directory.daemon.installers.MojoHelperUtils;
+import org.apache.directory.daemon.installers.ServiceInstallersMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tools.ant.taskdefs.Execute;
+
+
+/**
+ * Nullsoft INstaller System (NSIS) Installer command for Windows installers
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 434414 $
+ */
+public class DebInstallerCommand extends MojoCommand
+{
+ private final Properties filterProperties = new Properties( System.getProperties() );
+ /** The Deb target */
+ private final DebTarget target;
+ /** The Maven logger */
+ private final Log log;
+ /** The dpkg utility*/
+ private File dpkgUtility;
+
+
+ /**
+ * Creates a new instance of DebInstallerCommand.
+ *
+ * @param mymojo
+ * the Server Installers Mojo
+ * @param target
+ * the DEB target
+ */
+ public DebInstallerCommand( ServiceInstallersMojo mymojo, DebTarget target )
+ {
+ super( mymojo );
+ this.target = target;
+ this.log = mymojo.getLog();
+ initializeFiltering();
+ }
+
+
+ /**
+ * Performs the following:
+ * <ol>
+ * <li>Bail if target is not for linux or the dpkg utility could not be found.</li>
+ * <li>Creates the Debian DEB package for Apache DS</li>
+ * </ol>
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ // Verifying the target is linux
+ if ( !target.getOsFamily().equals( "linux" ) )
+ {
+ log.warn( "DEB package installer can only be targeted for Linux platforms!" );
+ log.warn( "The build will continue, but please check the the platform of this installer " );
+ log.warn( "target" );
+ return;
+ }
+
+ // Verifying the dpkg utility exists
+ if ( !target.getDpkgUtility().exists() )
+ {
+ log.warn( "Cannot find dpkg utility at this location: " + target.getDpkgUtility() );
+ log.warn( "The build will continue, but please check the location of your dpkg " );
+ log.warn( "utility." );
+ return;
+ }
+ else
+ {
+ dpkgUtility = target.getDpkgUtility();
+ }
+
+ File baseDirectory = target.getLayout().getBaseDirectory();
+ File imagesDirectory = baseDirectory.getParentFile();
+
+ log.info( "Creating Debian DEB Package..." );
+
+ // Creating the package directory
+ File debDirectory = new File( imagesDirectory, target.getId() + "-deb" );
+ debDirectory.mkdirs();
+
+ log.info( "Copying DEB Package files" );
+
+ // Copying the apacheds files in the '/opt/apacheds-$VERSION/' directory
+ File debApacheDsHomeDirectory = new File( debDirectory, "opt/apacheds-" + target.getApplication().getVersion() );
+ try
+ {
+ // Copying the generated layout
+ MojoHelperUtils.copyFiles( baseDirectory, debApacheDsHomeDirectory );
+
+ // Replacing the apacheds.conf file
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.conf" ),
+ new File( debApacheDsHomeDirectory, "conf/apacheds.conf" ), false );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy image (" + target.getLayout().getBaseDirectory()
+ + ") to the DEB directory (" + debApacheDsHomeDirectory + ")" );
+ }
+
+ // Copying the instances in the '/var/lib/apacheds-$VERSION/default' directory
+ File debDefaultInstanceDirectory = new File( debDirectory, "var/lib/apacheds-"
+ + target.getApplication().getVersion() + "/default" );
+ debDefaultInstanceDirectory.mkdirs();
+ File debDefaultInstanceConfDirectory = new File( debDefaultInstanceDirectory, "conf" );
+ debDefaultInstanceConfDirectory.mkdirs();
+ new File( debDefaultInstanceDirectory, "ldif" ).mkdirs();
+ new File( debDefaultInstanceDirectory, "log" ).mkdirs();
+ new File( debDefaultInstanceDirectory, "partitions" ).mkdirs();
+ new File( debDefaultInstanceDirectory, "run" ).mkdirs();
+ File debEtcInitdDirectory = new File( debDirectory, "etc/init.d" );
+ debEtcInitdDirectory.mkdirs();
+ new File( debDirectory, "/var/run/apacheds-" + target.getApplication().getVersion() ).mkdirs();
+ try
+ {
+ // Copying the apacheds.conf file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "apacheds-default.conf" ), new File( debDefaultInstanceConfDirectory, "apacheds.conf" ), false );
+
+ // Copying the log4j.properties file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( debApacheDsHomeDirectory,
+ "conf/log4j.properties" ), new File( debDefaultInstanceConfDirectory, "log4j.properties" ), false );
+
+ // Copying the server.xml file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( debApacheDsHomeDirectory,
+ "conf/server.xml" ), new File( debDefaultInstanceConfDirectory, "server.xml" ), false );
+
+ // Copying the init script in /etc/init.d/
+ MojoHelperUtils
+ .copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds-init" ), new File(
+ debEtcInitdDirectory, "apacheds-" + target.getApplication().getVersion() + "-default" ), true );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy resources files to the DEB directory ("
+ + debDefaultInstanceDirectory + ")" );
+ }
+
+ // Create DEBIAN directory
+ File debDebianDirectory = new File( debDirectory, "DEBIAN" );
+ debDebianDirectory.mkdirs();
+
+ // Copying the 'control' file
+ try
+ {
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "control" ),
+ new File( debDebianDirectory, "control" ), true );
+
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "postinst" ),
+ new File( debDebianDirectory, "postinst" ), true );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy DEB 'control' file." );
+ }
+
+ // Setting correct permission on the postinst script
+ MojoHelperUtils.exec( new String[]
+ { "chmod", "755", new File( debDebianDirectory, "postinst" ).toString() }, debDebianDirectory, false );
+
+ // Generating the DEB
+ log.info( "Generating Debian DEB Package" );
+ String finalName = target.getFinalName();
+ if ( !finalName.endsWith( ".deb" ) )
+ {
+ finalName = finalName + ".deb";
+ }
+ Execute createDebTask = new Execute();
+ String[] cmd = new String[]
+ { dpkgUtility.getAbsolutePath(), "-b", target.getId() + "-deb", finalName };
+ createDebTask.setCommandline( cmd );
+ createDebTask.setSpawn( true );
+ createDebTask.setWorkingDirectory( imagesDirectory );
+
+ try
+ {
+ createDebTask.execute();
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed while trying to generate the DEB package: " + e.getMessage() );
+ }
+
+ log.info( "Debian DEB package generated at " + new File( imagesDirectory, finalName ) );
+ }
+
+
+ private void initializeFiltering()
+ {
+ filterProperties.putAll( mymojo.getProject().getProperties() );
+ filterProperties.put( "app", target.getApplication().getName() );
+ String version = target.getApplication().getVersion();
+ if ( target.getApplication().getVersion() != null )
+ {
+ if ( version.endsWith( "-SNAPSHOT" ) )
+ {
+ filterProperties.put( "version.debian", version + "1" );
+ }
+ else
+ {
+ filterProperties.put( "version.debian", version );
+ }
+
+ filterProperties.put( "app.version", version );
+ }
+ else
+ {
+ filterProperties.put( "app.version", "1.0" );
+ }
+ filterProperties.put( "arch", target.getOsArch() );
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.daemon.installers.MojoCommand#getFilterProperties()
+ */
+ public Properties getFilterProperties()
+ {
+ return filterProperties;
+ }
+}
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebTarget.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebTarget.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebTarget.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/deb/DebTarget.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.deb;
+
+
+import java.io.File;
+
+import org.apache.directory.daemon.installers.Target;
+
+
+/**
+ * A Deb package for the Debian platform.
+ *
+ * To create a Deb package we use the dpkg utility that is bundled in the
+ * Debian operating system.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class DebTarget extends Target
+{
+ /** The wrapper executable path */
+ private String wrapperExecutablePath = "src/main/installers/wrapper/bin/wrapper-windows-x86-32.exe";
+ /** The PackageMaker utility executable */
+ private File dpkgUtility = new File( "/usr/bin/dpkg" );
+
+
+ /**
+ * Gets the dpkg utility.
+ *
+ * @return
+ * the dpkg utility
+ */
+ public File getDpkgUtility()
+ {
+ return dpkgUtility;
+ }
+
+
+ /**
+ * Gets the Wrapper executable path.
+ *
+ * @return
+ * the wrapper executable path
+ */
+ public String getWrapperExecutablePath()
+ {
+ return wrapperExecutablePath;
+ }
+
+
+ /**
+ * Sets the dpkg utility.
+ *
+ * @param dpkgUtility
+ * the dpkg utility
+ */
+ public void setDpkgUtility( File dpkgUtility )
+ {
+ this.dpkgUtility = dpkgUtility;
+ }
+
+
+ /**
+ * Sets the Wrapper executable path.
+ *
+ * @param wrapperExecutablePath
+ * the wrapper executable path
+ */
+ public void setWrapperExecutablePath( String wrapperExecutablePath )
+ {
+ this.wrapperExecutablePath = wrapperExecutablePath;
+ }
+}
\ No newline at end of file
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgInstallerCommand.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgInstallerCommand.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgInstallerCommand.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgInstallerCommand.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,337 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.pkg;
+
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.directory.daemon.installers.MojoCommand;
+import org.apache.directory.daemon.installers.MojoHelperUtils;
+import org.apache.directory.daemon.installers.ServiceInstallersMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.tools.ant.taskdefs.Execute;
+
+
+/**
+ * PKG Installer command for creating Mac OS X packages.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 434414 $
+ */
+public class PkgInstallerCommand extends MojoCommand
+{
+ private final Properties filterProperties = new Properties( System.getProperties() );
+ /** The PKG target */
+ private final PkgTarget target;
+ /** The Maven logger */
+ private final Log log;
+ /** The PackageMaker utility executable */
+ private File packageMakerUtility;
+ /** The hdiutil utility executable */
+ private File hdiutilUtility = new File( "/usr/bin/hdiutil" );
+
+
+ /**
+ * Creates a new instance of PkgInstallerCommand.
+ *
+ * @param mymojo
+ * the Server Installers Mojo
+ * @param target
+ * the PKG target
+ */
+ public PkgInstallerCommand( ServiceInstallersMojo mymojo, PkgTarget target )
+ {
+ super( mymojo );
+ this.target = target;
+ this.log = mymojo.getLog();
+ initializeFiltering();
+ }
+
+
+ /**
+ * Performs the following:
+ * <ol>
+ * <li>Bail if target is not for macosx or the PackageMaker or hdiutil utilities coud not be found.</li>
+ * <li>Creates the Mac OS X PKG Installer for Apache DS</li>
+ * <li>Package it in a Mac OS X DMG (Disk iMaGe)</li>
+ * </ol>
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException
+ {
+ // Verifying the target is macosx
+ if ( !target.getOsFamily().equals( "macosx" ) )
+ {
+ log.warn( "PKG installer can only be targeted for Mac OS X platforms!" );
+ log.warn( "The build will continue, but please check the the platform of this installer " );
+ log.warn( "target" );
+ return;
+ }
+
+ // Verifying the PackageMaker utility exists
+ if ( !target.getPackageMakerUtility().exists() )
+ {
+ log.warn( "Cannot find PackageMaker utility at this location: " + target.getPackageMakerUtility() );
+ log.warn( "The build will continue, but please check the location of your Package Maker " );
+ log.warn( "utility." );
+ return;
+ }
+ else
+ {
+ packageMakerUtility = target.getPackageMakerUtility();
+ }
+
+ // Verifying the hdiutil utility exists
+ if ( !hdiutilUtility.exists() )
+ {
+ log.warn( "Cannot find hdiutil utility at this location: " + hdiutilUtility );
+ log.warn( "The build will continue, but please check the location of your hdiutil " );
+ log.warn( "utility." );
+ return;
+ }
+
+ File baseDirectory = target.getLayout().getBaseDirectory();
+ File imagesDirectory = baseDirectory.getParentFile();
+
+ log.info( "Creating Mac OS X PKG Installer..." );
+
+ // Creating the package directory
+ File pkgDirectory = new File( imagesDirectory, target.getId() + "-pkg" );
+ pkgDirectory.mkdirs();
+
+ log.info( "Copying PKG installer files" );
+
+ // Creating the root directories hierarchy
+ File pkgRootDirectory = new File( pkgDirectory, "root" );
+ pkgRootDirectory.mkdirs();
+ File pkgRootUsrBinDirectory = new File( pkgRootDirectory, "usr/bin" );
+ pkgRootUsrBinDirectory.mkdirs();
+ File pkgRootUsrLocalApachedsDirectory = new File( pkgRootDirectory, "usr/local/"
+ + target.getApplication().getName() + "-" + target.getApplication().getVersion() );
+ pkgRootUsrLocalApachedsDirectory.mkdirs();
+ File pkgRootInstancesDirectory = new File( pkgRootUsrLocalApachedsDirectory, "instances" );
+ pkgRootInstancesDirectory.mkdirs();
+ File pkgRootInstancesDefaultDirectory = new File( pkgRootInstancesDirectory, "default" );
+ pkgRootInstancesDefaultDirectory.mkdirs();
+ File pkgRootInstancesDefaultConfDirectory = new File( pkgRootInstancesDefaultDirectory, "conf" );
+ pkgRootInstancesDefaultConfDirectory.mkdirs();
+ File pkgRootInstancesDefaultLdifDirectory = new File( pkgRootInstancesDefaultDirectory, "ldif" );
+ pkgRootInstancesDefaultLdifDirectory.mkdirs();
+ new File( pkgRootInstancesDefaultDirectory, "log" ).mkdirs();
+ new File( pkgRootInstancesDefaultDirectory, "partitions" ).mkdirs();
+ new File( pkgRootInstancesDefaultDirectory, "run" ).mkdirs();
+ File pkgRootLibraryLaunchDaemons = new File( pkgRootDirectory, "Library/LaunchDaemons" );
+ pkgRootLibraryLaunchDaemons.mkdirs();
+
+ // Copying the apacheds files in the root directory
+ try
+ {
+ // Copying the generated layout
+ MojoHelperUtils.copyFiles( baseDirectory, pkgRootUsrLocalApachedsDirectory );
+
+ // Copying the apacheds.init file
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.init" ),
+ new File( pkgRootUsrLocalApachedsDirectory, "bin/" + target.getApplication().getName() + ".init" ),
+ true );
+
+ // Replacing the apacheds.conf file
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream( "apacheds.conf" ),
+ new File( pkgRootUsrLocalApachedsDirectory, "conf/apacheds.conf" ), true );
+
+ // Copying the apacheds.conf file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "apacheds-default.conf" ), new File( pkgRootInstancesDefaultConfDirectory, "apacheds.conf" ), false );
+
+ // Copying the log4j.properties file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( pkgRootUsrLocalApachedsDirectory,
+ "conf/log4j.properties" ), new File( pkgRootInstancesDefaultConfDirectory, "log4j.properties" ), false );
+
+ // Copying the server.xml file in the default instance conf directory
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, new File( pkgRootUsrLocalApachedsDirectory,
+ "conf/server.xml" ), new File( pkgRootInstancesDefaultConfDirectory, "server.xml" ), false );
+
+ // Copying the apacheds command to /usr/bin
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "apacheds-usr-bin.sh" ), new File( pkgRootUsrBinDirectory, target.getApplication().getName() ), true );
+
+ // Copying the org.apache.directory.server.plist file to /Library/LaunchDaemons/
+ MojoHelperUtils.copyAsciiFile( mymojo, filterProperties, getClass().getResourceAsStream(
+ "org.apache.directory.server.plist" ), new File( pkgRootLibraryLaunchDaemons,
+ "org.apache.directory.server.plist" ), true );
+
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy image (" + target.getLayout().getBaseDirectory()
+ + ") to the PKG directory (" + pkgRootDirectory + ")" );
+ }
+
+ // Create Resources folder and sub-folder
+ // Copying the resources files and Info.plist file needed for the
+ // generation of the PKG
+ File pkgResourcesEnglishDirectory = new File( pkgDirectory, "Resources/en.lproj" );
+ pkgResourcesEnglishDirectory.mkdirs();
+ File pkgScriptsDirectory = new File( pkgDirectory, "scripts" );
+ pkgScriptsDirectory.mkdirs();
+
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "pkg-background.tiff" ), new File(
+ pkgResourcesEnglishDirectory, "background.tiff" ) );
+
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "License.rtf" ), new File(
+ pkgResourcesEnglishDirectory, "License.rtf" ) );
+
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "Info.plist" ), new File( pkgDirectory,
+ "Info.plist" ) );
+
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "postflight" ), new File(
+ pkgScriptsDirectory, "postflight" ) );
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy PKG resources files." );
+ }
+
+ // Generating the PKG
+ log.info( "Generating Mac OS X PKG Installer" );
+ Execute createPkgTask = new Execute();
+ String[] cmd = new String[]
+ { packageMakerUtility.getAbsolutePath(), "--root", "root/", "--resources", "Resources/", "--info",
+ "Info.plist", "--title", "Apache Directory Server " + target.getApplication().getVersion(),
+ "--version", target.getApplication().getVersion(), "--scripts", "scripts", "--out",
+ "Apache Directory Server Installer.pkg" };
+ createPkgTask.setCommandline( cmd );
+ createPkgTask.setSpawn( true );
+ createPkgTask.setWorkingDirectory( pkgDirectory );
+ try
+ {
+ createPkgTask.execute();
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed while trying to generate the PKG: " + e.getMessage() );
+ }
+
+ log.info( "Mac OS X PKG Installer generated at "
+ + new File( pkgDirectory, "Apache Directory Server Installer.pkg" ) );
+
+ log.info( "Creating Mac OS X DMG..." );
+
+ // Creating the disc image directory
+ File dmgDirectory = new File( imagesDirectory, target.getId() + "-dmg" );
+ dmgDirectory.mkdirs();
+
+ log.info( "Copying DMG files" );
+
+ // Create dmg directory and its sub-directory
+ File dmgDmgBackgroundDirectory = new File( dmgDirectory, "dmg/.background" );
+ dmgDmgBackgroundDirectory.mkdirs();
+
+ // Copying the files
+ try
+ {
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "dmg-background.png" ), new File(
+ dmgDirectory, "dmg/.background/background.png" ) );
+
+ MojoHelperUtils.copyBinaryFile( getClass().getResourceAsStream( "DS_Store" ), new File( dmgDirectory,
+ "dmg/.DS_Store" ) );
+
+ MojoHelperUtils.copyFiles( new File( pkgDirectory, "Apache Directory Server Installer.pkg" ), new File(
+ dmgDirectory, "dmg/Apache Directory Server Installer.pkg" ) );
+
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed to copy DMG resources files." );
+ }
+
+ // Setting execution permission to the postflight script
+ // (unfortunately, the execution permission has been lost after the
+ // copy of the PKG to the dmg folder)
+ MojoHelperUtils.exec( new String[]
+ {
+ "chmod",
+ "755",
+ new File( dmgDirectory, "dmg/Apache Directory Server Installer.pkg/Contents/Resources/postflight" )
+ .toString() }, dmgDirectory, false );
+
+ // Generating the DMG
+ log.info( "Generating Mac OS X DMG Installer" );
+ String finalName = target.getFinalName();
+ if ( !finalName.endsWith( ".dmg" ) )
+ {
+ finalName = finalName + ".dmg";
+ }
+ try
+ {
+ Execute createDmgTask = new Execute();
+ createDmgTask.setCommandline( new String[]
+ { hdiutilUtility.getAbsolutePath(), "makehybrid", "-hfs", "-hfs-volume-name",
+ "Apache Directory Server Installer", "-hfs-openfolder", "dmg/", "dmg/", "-o", "TMP.dmg" } );
+ createDmgTask.setSpawn( true );
+ createDmgTask.setWorkingDirectory( dmgDirectory );
+ createDmgTask.execute();
+
+ createDmgTask.setCommandline( new String[]
+ { hdiutilUtility.getAbsolutePath(), "convert", "-format", "UDZO", "TMP.dmg", "-o", "../" + finalName } );
+ createDmgTask.execute();
+
+ }
+ catch ( IOException e )
+ {
+ log.error( e.getMessage() );
+ throw new MojoFailureException( "Failed while trying to generate the DMG: " + e.getMessage() );
+ }
+
+ log.info( "Mac OS X DMG generated at " + new File( imagesDirectory, finalName ) );
+ }
+
+
+ private void initializeFiltering()
+ {
+ filterProperties.putAll( mymojo.getProject().getProperties() );
+ filterProperties.put( "app.name", target.getApplication().getName() );
+ if ( target.getApplication().getVersion() != null )
+ {
+ filterProperties.put( "app.version", target.getApplication().getVersion() );
+ }
+ else
+ {
+ filterProperties.put( "app.version", "1.0" );
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.directory.daemon.installers.MojoCommand#getFilterProperties()
+ */
+ public Properties getFilterProperties()
+ {
+ return filterProperties;
+ }
+}
Added: directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgTarget.java
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgTarget.java?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgTarget.java (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/java/org/apache/directory/daemon/installers/pkg/PkgTarget.java Tue Apr 1 09:20:44 2008
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ *
+ */
+package org.apache.directory.daemon.installers.pkg;
+
+
+import java.io.File;
+
+import org.apache.directory.daemon.installers.Target;
+
+
+/**
+ * A PKG installer for the Mac OS X platform.
+ *
+ * To create a PKG installer we use the PackageMaker utility that is bundled
+ * in the (free) developer tools supplied by Apple.
+ *
+ * More information on the use of the PackageMaker utility in the command line
+ * can be found at this address:
+ * http://developer.apple.com/documentation/Darwin/Reference/Manpages/man1/packagemaker.1.html
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+public class PkgTarget extends Target
+{
+ /** The wrapper executable path */
+ private String wrapperExecutablePath = "src/main/installers/wrapper/bin/wrapper-windows-x86-32.exe";
+ /** The PackageMaker utility executable */
+ private File packageMakerUtility = new File(
+ "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker" );
+
+
+ /**
+ * Gets the PackageMaker utility.
+ *
+ * @return
+ * the PackageMaker utility
+ */
+ public File getPackageMakerUtility()
+ {
+ return packageMakerUtility;
+ }
+
+
+ /**
+ * Gets the Wrapper executable path.
+ *
+ * @return
+ * the wrapper executable path
+ */
+ public String getWrapperExecutablePath()
+ {
+ return wrapperExecutablePath;
+ }
+
+
+ /**
+ * Sets the PackageMaker utility.
+ *
+ * @param packageMakerUtility
+ * the PackageMaker utility
+ */
+ public void setPackageMakerUtility( File packageMakerUtility )
+ {
+ this.packageMakerUtility = packageMakerUtility;
+ }
+
+
+ /**
+ * Sets the Wrapper executable path.
+ *
+ * @param wrapperExecutablePath
+ * the wrapper executable path
+ */
+ public void setWrapperExecutablePath( String wrapperExecutablePath )
+ {
+ this.wrapperExecutablePath = wrapperExecutablePath;
+ }
+}
\ No newline at end of file
Added: directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-default.conf
URL: http://svn.apache.org/viewvc/directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-default.conf?rev=643469&view=auto
==============================================================================
--- directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-default.conf (added)
+++ directory/daemon/branches/bigbang/plugin/src/main/resources/org/apache/directory/daemon/installers/bin/apacheds-default.conf Tue Apr 1 09:20:44 2008
@@ -0,0 +1,41 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you 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.
+#
+
+#
+# In this file you can override parameters specified in the default
+# Apache Directory Server config file which is usually at
+# /opt/apacheds-x.x.x/conf/apacheds.conf
+#
+# See also http://wrapper.tanukisoftware.org/doc/english/properties.html
+# For a list of properties that can be set.
+#
+# Common overrides shown commented below
+
+
+# Override the JRE used
+# wrapper.java.command=%JAVA_HOME%/bin/java
+
+# Override the JVM memory settings
+# Initial Java Heap Size (in MB)
+# wrapper.java.initmemory=384
+
+# Maximum Java Heap Size (in MB)
+# wrapper.java.maxmemory=384
+
+# apacheds.instance.start=auto
\ No newline at end of file