As part of my work on my JS-Test-Runner, I’ve been setting up Maven to do all my packaging for me. Deb packaging was relatively straight-forward (using the jDeb maven plugin), and happily builds on my Linux CI box and the my home Windows dev machine, but building RPMs requires a little more hackery.
The main issue is that rather than building it from scratch, as the jdeb plugin does, it uses rpmbuild directly. This unsurprisingly doesn’t exist on Windows! Your options are to hide this step under a profile and not execute it on Windows, or to install Cygwin and work from there. I went for option B:
- Configure RPM building in your pom (see mine for an example)
- Download cygwin
- Run the installer, and select rpm and rpm-build as packages that you’d like to have installed.
- Add your Cygwin bin folder (e.g. C:\cygwin\bin) to your PATH
- Rename the ‘system file’ (actually a symlink) at cygwin\bin\rpmbuild to cygwin\bin\rpmb
- Copy the script provided in this bug ticket comment to a new batch file called ‘rpmbuild.bat’ in your PATH, e.g. C:\cygwin\bin\rpmbuild.bat
- Make a small tweak to that file, changing the ‘rpmbuild’ at the start of the last line to ‘rpmb’
Some troubleshooting notes:
- Documentation for the plugin is actually relatively good, and is available at http://mojo.codehaus.org/rpm-maven-plugin/index.html .
- For a while I was getting /var/tmp/rpm-tmp.[…] “too many arguments” errors. This appears to be because I had git’s binaries in my PATH before Cygwin’s, and it was finding the mv command from there and using that, but the path to it (‘C:/Program Files (x86)/git/bin/mv’) has a space in it. Moving C:/Cygwin/bin ahead of that in my PATH fixed the issue.
With this, I can now build JS-Test-Runner locally on my Windows box, no problemo; feel free to check out that code and try a local ‘mvn package’ to test your machine setup. RPMs will appear in [project]/target/rm/[project name]/RPMS/noarch, by default.
Many thanks for the core elements of this go to the gentlemen (or ladies) of MRPM-4, a bug ticket in the maven RPM plugin covered in comments looking at ways of doiing this. The slight tweaks to their approach are to better deal with paths, as what I could decipher from the discussion on that ticket didn’t quite hit the spot.