Packaging
Apache Directory Server is packaged in many flavvors:
- As a pure linux binary
- As a Debian dep file
- As a RedHat RPM file
- As a Mac OS installer
- As a Winwosw installer
- As a docker installer
- As a source archive
We are going to explain how each of those packages are created.
Generalities
We use two sub-modules for the installer:
- The apacheds-installers-maven-plugin which is a Maven plugin used to create the various packages
- The apacheds-installers which is creatinhg the packages
The apacheds-installers project defines each of the target in its pom.xml file. For instance, for the Debian installer, we will use this configuration:
<profile>
<id>debian</id>
<build>
<plugins>
<!-- Generating installers -->
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>apacheds-installers-maven-plugin</artifactId>
<configuration>
<!-- Targets for Linux .deb installer package -->
<debTargets>
<debTarget>
<id>apacheds-debian-i386</id>
<finalName>apacheds-${project.version}-i386.deb</finalName>
<osArch>i386</osArch>
</debTarget>
<debTarget>
<id>apacheds-debian-amd64</id>
<finalName>apacheds-${project.version}-amd64.deb</finalName>
<osArch>amd64</osArch>
</debTarget>
</debTargets>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>apacheds-installers-maven-plugin</artifactId>
<version>${project.version}</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
We can see we have defined a specific profile for this package, debian, and that the apacheds-installers-maven-plugin plugin is configured to support two kinds of packages (osArch parameter):
- A i386 package
- An amd64 packager
We also set the finalName with the package name.
The Maven goal we call is named generate.
In Java, we will have one class per target, extending the parent Target class.
The Target parent class stores the target id, architecture, OS and the final file name. Each inheriting class stores the path to the tool to use to generate the installer:
- dpkg for the Debian installer (defaults to /usr/bin/dpkg)
- rpmbuild for the RedHat installer (defaults to /usr/bin/rpmbuild)
- TODO: Mac, Windows
We use a default value, hard coded in the extended class, but this value can be ovveriden by the pom.xml configuration, and overriden by the use of a -D flag on the command line (which has the highest level of precedence).
Each extended class implements the execute() method which is responsible for calling an InstallerCommand class. These classes are the one which create the packages.
Here is the list of inherited classes:
- ArchiveTarget: Create the tar.gz package
- BinTarget
- DebTarget: Generate a deb file to be used on Debian based platforms
- MacOsXPkgTarget: Generate Mac OS platform packages
- NsisTarget: Generate a 32 bits windows package
- RpmTarget: Generate a rpm file to be used on RedHat/CentOS based platforms
Linux Debian
The debian configuration is managed by the DebTarget.java file, which sets one specific parameneter:
- OsName set to Linux
The three other parameters are declared in the pom.xml file:
- id set to apacheds-debian-i386 or apacheds-debian-amd64*
- OsArch set to i386 or i386 (see upper).
- finalName is set to apacheds-
-i386.deb or apacheds--amd64.deb
(They do have default value, which get overriden by configuration).
A DebInstallerCommand instance is created and its execute() method is called.