To create RPM packages from within a coremedia-application project, all you have to do is add an execution to the coremedia-application:rpm goal, e.g.
<plugin> <groupId>com.coremedia.maven</groupId> <artifactId>coremedia-application-maven-plugin</artifactId> <extensions>true</extensions> <executions> <execution> <goals> <goal>rpm</goal> </goals> </execution> </executions> </plugin>
This will create a rpm package with reasonable defaults in your ${project.build.directory}. When you install the rpm at your target machine, the rpm will create a /opt/coremedia/${project.artifactId} folder for the application with user coremedia and group coremedia.
All files contained in your bin directory will be made executable.
However in most cases you will at least override the defaults for user group which will be applied to the files on the target machine. You can do so easily if you add the following snippet within the above mentioned execution element:
<configuration> <defaultuser>john</defaultuser> <defaultgroup>doe</defaultgroup> <defaultfilemode>644</defaultfilemode> <defaultdirmode>755</defaultdirmode> </configuration>
In contrast to zip archives, files packaged in an rpm file always have a target path prefix where it will be placed on install and removed on uninstall. As mentioned above the defaultprefix will be set to /opt/coremedia/<rpm name> . However if you want to map some files to a special directory you can do that with the mapping element. Each mapping element is defined by a directory element which defines the base directory below the configured output directory normally ${project.build.directory}/${project.build.finalName}, to which all includes and excludes are relative to.
To override the defaultPrefix you have to define a prefix element within the mapping element. A prefix element always has to start and end with a / slash.
To override the defaultfilemode or the defaultdirmode all you have to do is define either filemode or dirmode. Below you see a mapping example that maps all *.sh files below the bin directory to a target path usr/bin with filemode 700.
<mapping> <directory>bin</directory> <prefix>/usr/bin/</prefix> <includes>*.sh</includes <filemode>700</filemode> </mapping>
You can define as many mapping elements as you like but you have to enclose them with a mappings element as you can see in the complete reference below.
There are many configuration possibilities you can configure for an rpm. The following snippet shows a complex configuration:
<plugin> <groupId>com.coremedia.maven</groupId> <artifactId>coremedia-application-maven-plugin</artifactId> <extensions>true</extensions> <executions> <execution> <id>build-test-rpm</id> <goals> <goal>rpm</goal> </goals> <configuration> <classifier>test</classifier> <rpmConfig> <name>content-managenent-server</name> <version>1.2</version> <release>2</release> <group>Unspecified</group> <host>BuildMachine</host> <summary>The CoreMedia content managenent server</summary> <description>The content repository for CoreMedia 6</description> <license>CoreMedia Proprietary License</license> <packager>The Dist Man</packager> <distribution>CoreMedia 6</distribution> <vendor>CoreMedia AG</vendor> <url>http://www.coremedia.com</url> <sourcePackage></sourcePackage> <provides>contentrepository</provides> <prefixes>cm</prefixes> <type>BINARY</type> <architecture>NOARCH</architecture> <os>LINUX</os> <preInstallScript></preInstallScript> <postInstallScript></postInstallScript> <preUninstallScript></preUninstallScript> <postUninstallScript></postUninstallScript> <defaultprefix>/opt/coremedia</defaultprefix> <dependencies> <dependency> <packageName>ksh</packageName> <minVersion>20100621</minVersion> </dependency> <dependency> <packageName>httpd</packageName> <maxVersion>2.2.20</maxVersion> </dependency> </dependencies> <defaultuser>coremedia</defaultuser> <defaultgroup>coremedia</defaultgroup> <defaultfilemode>644</defaultfilemode> <defaultdirmode>755</defaultdirmode> <createEmptyDirs>false</createEmptyDirs> <mappings> <mapping> <directory>mySpecialDir</directory> <includes>**/*</includes> <excludes>private/**</exludes> <!-- an optional prefix must start and end with a "/". If no prefix is given the defaultprefix + rpmName will be used--> <prefix>/opt/coremedia/mydir/</prefix> <username>john</username> <groupname>doe</groupname> <filemode>777</filemode> <dirmode>777</dirmode> <directive>[NONE|CONFIG|DOC|ICON|MISSINGOK|NOREPLACE|SPECFILE|GHOST|LICENSE|README|EXCLUDE|UNPATCHED|PUBKEY|POLICY]</directive> <mapping> <mappings> <symlinks> <symlink> <source>/opt/coremedia/john</source> <target>mySpecialDir</target> <permissions>755</permissions> <symlink> <symlinks> </rpmConfig> </configuration> </execution> </executions> </plugin>
In contrast to maven versioning it is not allowed to use dashes "-" within the version or the release. RPM versioning also has no SNAPSHOT concept but instead has the separation into version and release. To fit both models the application plugin convert maven versions into rpm versions. To achieve this the version will be set together from the major.minor.incremental parts of the maven version whereas the release will be build from the buildnumber if present suffixed by either release or develop and the qualifier if present.
In case of a snapshot version a unix timestamp is appended.
Applying all these rules leads to the following example mappings:
Maven major.minor.incremental-build-qualifier | Rpm version-release |
---|---|
1 | 1-1.release |
1.1-SNAPSHOT | 1.1-1.develop.121313 |
1.1-rc-4 | 1.1-1.rc.4.release |
1-1 | 1-1.release |
preview-4 | 0-1.preview.4.release |
1-2-SNAPSHOT | 1-2.develop.12123123 |
1.2.3-SNAPSHOT | 1.2.3-1.develop.12123123 |
1.2.3-2-SNAPSHOT | 1.2.3-2.develop.12123123 |
You may wonder why 1 and 1-1 leads to the same rpm representation. This is because an rpm release always starts at 1. A maven version n-n is therefore equal to a maven version n on rpm level. This is ok because a buildnumber set to 0 is not very usefull.