Building RPMs on any platform with Maven

In several occasions I had to build RPM packages for installing software. In the past I mostly did it with a Maven build using the RPM Maven Plugin.

The process is simple: At the end of your build you gather up all resources, try to understand the mapping configuration, bang your head a few times in order to figure out way to work with -SNAPSHOT versions and that’s it. In the end you have a few RPM files.

The only problem is, that the plugin actually creates a spec file and runs the rpmbuild command line tool. Which is, of course, only available on an RPM like system. Fortunately Debian/Ubuntu based distributions, although they use something different, provide at least the rpmbuild tool.

On Windows or Mac OS the situation looks different. Adding rpmbuild to Windows can be quite a task. Still the question remains, why this is necessary since Java can run on all platforms.

So time to write a Maven plugin which does not the rpmbuild tool, but create RPM packages native in Java:

de.dentrassi.maven:rpm is a Maven Plugin which does create RPM packages using plain Java as a Maven Plugin. The process is simply and fast and does not require additional command line tool. The plugin is open source and the source code is available on GitHub ctron/rpm-builder.

6 Replies to “Building RPMs on any platform with Maven”

  1. Really good thanks, worked well for my usecase. Just wondering if you had considered following it up with deploy/install as an artifact to a repository(nexus).

  2. Great plugin – thanks! But I noticed that the package name is always made lowercase – this is surprising behavoiour. What’s the rationale behind it? Can it be changed, or made optional?

  3. Thanks very much, great plugin, it’s saved me a load of work. However I can’t get signing to work, signing seems to work ok but rhnpush always says no signature. If I sign via rpm –addsign using the same key then I can use rhnpush. There is a difference in the signature information,

    bash-4.2$ rpm –checksig -v signedmaven.rpm
    Header V4 RSA/SHA1 Signature, key ID a5514418: OK
    Header SHA1 digest: OK (ee8b2aacd073230defef2899230f05c8860622ea)
    MD5 digest: OK (28e62686840244cd6bb632199b86f436)

    Now using a file signed with rpm –addsign
    bash-4.2$ rpm –checksig -v signedrpm.rpm
    Header V4 RSA/SHA1 Signature, key ID a5514418: OK
    Header SHA1 digest: OK (8ea4cbee4c3f29265e3fb2c33ca176c2955f147f)
    V4 RSA/SHA1 Signature, key ID a5514418: OK
    MD5 digest: OK (7e2a666a5a0e531b327f5eba3015e217)

    See the extra line in the rpm signed data?
    V4 RSA/SHA1 Signature, key ID a5514418: OK

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.