javamavenrpmrpm-maven-plugin

Remove the dependency on Python while building RPM using rpm-maven-plugin


I'm using rpm-maven-plugin to build an rpm as a part of my mvn build which later will be installed in a docker image that doesn't have Python. Python is not being used in the project as well. But for some reason, the generated spec file has the line

Requires: python >= 2.6

I tried putting in

<autoRequires>no</autoRequires>
<autoProvides>no</autoProvides>

but doesn't work as well. This is causing the docker build to fail as the rpm install fails because of missing dependency. How do I remove the dependency on python?

Following is the extract from my pom.xml

...
<version.rpm-maven-plugin>2.2.0</version.rpm-maven-plugin>
...
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>rpm-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>generate-rpm</id>
            <phase>package</phase>
            <goals>
                <goal>rpm</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <group>XXX</group>
        <vendor>XXX</vendor>
        <copyTo>
            target/${install.package.name}-${project.version}.rpm
        </copyTo>
        <targetOS>linux</targetOS>
        <autoRequires>no</autoRequires>
        <autoProvides>no</autoProvides>
        <mappings>
            ...
        </mappings>
        <preinstallScriptlet>
            <scriptFile>${basedir}/src/main/package/control/preinst</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
        </preinstallScriptlet>
        <postinstallScriptlet>
            <scriptFile>${basedir}/src/main/package/control/postinst</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
        </postinstallScriptlet>
        <preremoveScriptlet>
            <scriptFile>${basedir}/src/main/package/control/prerm</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
        </preremoveScriptlet>
        <postremoveScriptlet>
            <scriptFile>${basedir}/src/main/package/control/postrm</scriptFile>
            <fileEncoding>utf-8</fileEncoding>
        </postremoveScriptlet>
        <cleanScriptlet>
            <script>rm -rf ${project.build.directory}/rpm/buildroot</script>
        </cleanScriptlet>
    </configuration>
</plugin>

maven version: 3.5.4.

target docker image runs bare-bones SLES linux with just what is required and doesn't have Python.


Solution

  • Got it working by manually overriding the requires section

    ...
    <autoRequires>no</autoRequires>
    <autoProvides>no</autoProvides>
    <requires>
      <require>java-11-openjdk-headless</require>
    </requires>
    ...