This project shows how to generate debian packages for AIBench-based applications. This is done by integrating the jdeb plugin into the default pom.xml
.
Building this project with mvn package
will produce a debian package at target/aibench-jdeb_1.0_all.deb
. This package can then be installed with dpkg -i aibench-jdeb_1.0_all.deb
so that:
- Project files (i.e.,
run.sh
,conf
,lib
andplugins_bin
) are located at/usr/local/lib/aibench-jdeb
. - A link to launch script is located at
/usr/local/bin/run-aibench
.
This way, the application can be run by running command run-aibench
(which can be configured) from any path.
First, we create a new AIBench project:
mvn archetype:generate -DarchetypeGroupId=es.uvigo.ei.sing -DarchetypeArtifactId=aibench-archetype -DarchetypeVersion=2.5.5 -DgroupId=es.uvigo.ei.sing -DartifactId=my-aibench-application -DinteractiveMode=false -DarchetypeCatalog=http://sing.ei.uvigo.es/maven2/archetype-catalog.xml
Secondly, we configure the pom.xml
so that we:
- Set a proper project name and add a description.
- Add property
debian.package.lib.folder
specifying the location of the project in target debian systems. - Add property
debian.package.command
specifying the location of the command in target debian systems. - Add property
debian.package.maintainer
specifying the project maintainer. - Add property
debian.package.dependencies
specifying the project dependencies (i.e., debian packages). For instance, valuedefault-jre | java7-runtime
are the minimum required dependencies to indicate that project needs Java 1.7 to run.
At this momment, we have to create two files:
- An adapted
run.sh
for the target system. This file will besrc/main/resources/run-debian-package.sh
. - A debian control file at
src/main/resources/debian/control/control
.
This script is pretty similar to the default run.sh
:
#!/bin/bash
cd ${debian.package.lib.folder}
java -jar ./lib/aibench-aibench-2.5.5.jar
When creating this file we use properties defined in project's pom.xml
:
Package: ${artifactId}
Version: ${version}
Section: misc
Priority: low
Architecture: all
Description: ${description}
Maintainer: ${debian.package.maintainer}
Depends: ${debian.package.dependencies}
It is necessary to add this execution
to the maven-resources-plugin
so that new resources created in the previous step are copied (and filtered) to the project build directory:
<!-- copy debian files -->
<execution>
<id>copy-resources-debian</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/debian</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/debian</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
Finally, we add the following jdeb
plugin definition to project pom.xml
:
<plugin>
<artifactId>jdeb</artifactId>
<groupId>org.vafer</groupId>
<version>1.5</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jdeb</goal>
</goals>
<configuration>
<controlDir>${project.build.directory}/debian/control</controlDir>
<dataSet>
<data>
<src>${project.build.directory}/run-debian-package.sh</src>
<dst>run.sh</dst>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>${debian.package.lib.folder}</prefix>
<filemode>744</filemode>
</mapper>
</data>
<data>
<src>${project.build.directory}/conf</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>${debian.package.lib.folder}/conf</prefix>
</mapper>
</data>
<data>
<src>${project.build.directory}/lib</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>${debian.package.lib.folder}/lib</prefix>
</mapper>
</data>
<data>
<src>${project.build.directory}/plugins_bin</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>${debian.package.lib.folder}/plugins_bin</prefix>
</mapper>
</data>
<data>
<type>link</type>
<linkName>${debian.package.command}</linkName>
<linkTarget>${debian.package.lib.folder}/run.sh</linkTarget>
<symlink>true</symlink>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
The generated debian package can be installed with dpkg -i aibench-jdeb_1.0_all.deb
. Now, the application can be run by running command run-aibench
(configured with debian.package.command
) from any path.