Reputation: 285
I'm using rpm-maven-plugin to create an installation/upgrade RPM for my application which will be installed on CentOS 7.
For a new installation, some packages are required, however rpm-maven-plugin ignores the settings in rpm.spec file (so 'Requires:' won't work) and it's impossible to execute yum or rpm from withing the RPM scripts.
Is there a configuration for the plugin which tells RPM to install the required packages (PostgresDB and sshpass in this case)?
If not, what is the best option? Tell the customer to manually install the requirements before installation the RPM or create a shell script which handles the complete setup?
Here is the relevant part of the pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>${rpm-maven-plugin.version}</version>
<inherited>false</inherited>
<executions>
<execution>
<inherited>false</inherited>
<phase>install</phase>
<goals>
<goal>rpm</goal>
</goals>
</execution>
</executions>
<configuration>
<license>Commercial</license>
<group>Networking/Admin</group>
<name>name</name>
<packager>packager</packager>
<prefix>$prefix</prefix>
<version>${project.version}</version>
<release>release</release>
<needarch>x86_64</needarch>
<mappings>
...
</mappings>
<requires>
<require>postgresql >= ${rpm.postgresql.version}</require>
<require>java-1.8.0-openjdk</require>
<require>sshpass</require>
</requires>
<postinstallScriptlet>
<script>
cd /opt/%{name}
if [ "$1" = 1 ] ; then
if [ -e ./install.sh ]; then
sh ./install.sh;
fi
fi
if [ "$1" = 2 ] ; then
sh ./upgrade.sh
fi
</script>
</postinstallScriptlet>
</configuration>
</plugin>
</plugins>
</build>
Upvotes: 0
Views: 2944
Reputation: 194
Ran into this issue today. Found solution, which is not documented very well. Basically need to pass the list of requirements in the form of a LinkedHashSet.
According to the maven-rpm-plugin documentation for requires
requires:
The list of requirements for this package.
Type:java.util.LinkedHashSet
Required: No
so change
<requires>
<require>postgresql >= ${rpm.postgresql.version} </require>
<require>java-1.8.0-openjdk</require>
<require>sshpass</require>
</requires>
to
<requires>
<LinkedHashSet>postgresql >= ${rpm.postgresql.version},java-1.8.0-openjdk,sshpass</LinkedHashSet>
</requires>
Assuming ${rpm.postgresql.version}=123 the final spec would have a line like the following:
Requires: postgresql >= 123,java-1.8.0-openjdk,sshpass
Upvotes: 0