There are several tools provided by the Redline package which are useful when working with RPM files. This includes a scanner for examining existing RPM files, a programmatic interface for generating RPM packages, and an Ant task that can be imported and invoked from build scripts in order to package deployment files.
The scanner tool can be invoked from the command line using the main class
org.redline_rpm.Scanner
. From the command line
this class accepts as it's single argument a path to a valid RPM file. If the file specified by the providing path does
not exist, or if the file in not a valid RPM archive an exception will be thrown. And example of invoking the scanner
follows:
java -cp redline.jar org.redline_rpm.Scanner test.rpm
The scanner is most useful for debugging RPM files and tools as it generates a significant amount of output. For more generalized RPM information the standard RPM tools are recommended.
The builder is the main entry point for constructing RPM files programmatically. The tool is used by
constructing an instance of the org.redline_rpm.Builder
class and adding files and headers to the archive. When the builder is configured a final call will generate the RPM
file to a given java.nio.channels.FileChannel
.
Redline can be used to package projects that use the Ant build system. Included in the source and binary distributions
is an Ant task that can be used within an Ant build script to construct an RPM distributable. The task can be defined
using the antlib namespace convention by binding the namespace antlib:org.redline_rpm
and using the namespace prefix to reference the rpm
task type. An example of using the build
in Ant task follows:
<project name="test" default="rpm" xmlns:redline="antlib:org.redline_rpm"> <target name="rpm"> <mkdir dir="rpms"/> <redline:rpm group="Java Development" name="test" version="1.2.3" destination="rpms"> <zipfileset prefix="/usr/share/java" file="test-1.2.3.jar"/> <link path="/usr/share/java/test.jar" target="/usr/share/java/test-1.2.3.jar"/> <depends name="test-lib" version="1.2.3"/> </redline:rpm> </target> </project>
Another example, which includes setting the source package property:
<redline group="Java Development" name="test" version="1.2.6" destination="rpms" sourcePackage="test.rpm"> <tarfileset prefix="/tmp/rpmtest/bin" file="bin/*" filemode="744" username="none" group="none"/> <rpmfileset prefix="/tmp/rpmtest/conf" config="true" noreplace="true" file="conf/test1.conf" filemode="644" username="none" group="none"/> <rpmfileset prefix="/tmp/rpmtest/conf" config="true" file="conf/test2.conf" filemode="644" username="none" group="none"/> <depends name="test-lib" version="1.2.3"/> <redline>
This build script creates a new RPM file named test-1.2.3-1.noarch.rpm
in the rpms
directory
containing the local file test-1.2.3.jar
to be installed into /use/share/java
on the installation
machine. In addition a symbolic link is included from the packaged file to /usr/share/java/test.jar
.
The resulting RPM has a dependency on an RPM named test-lib
.
Redlone can also be used from within Maven using 'maven-antrun-plugin'. This is a sample configuration for building an RPM from Maven using Redline instead of the native system RPM tools:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> <execution> <id>generateSources</id> <phase>package</phase> <goals> <goal>run</goal> </goals> <configuration> <tasks> <ant antfile="${basedir}/src/main/scripts/buildrpm.xml"> <target name="rpm"/> </ant> </tasks> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>org.redline-rpm</groupId> <artifactId>redline</artifactId> <version>1.1.16</version> </dependency> </dependencies> </plugin>