Search code examples
rpmrpmbuildrpm-spec

How to Require node.js in a RPM Specfile?


While building an RPM package, how can I use Requires or some similar tag to specify node.js version 0.10.28 or greater as a prerequisite? It's not in the default repositories, and it's possible the user has built it from source. I've looked around online, and it looks like I can only Require a "capability" provided by an RPM file. Also, I don't want to look for /usr/bin/node, as it's possible node could be installed somewhere else. I'd rather use something like which node to detect it.


Solution

  • An RPM Requires line cannot be dynamic in the sense of which). It either specifies a package name, a capability, or a file (by full path).

    You can detect node.js during your RPM's %pre script and bail out if it can't be found (though I don't recommend this).

    You can detect it during %post and print out a warning when it isn't found alerting the user that they need to install it.

    You can detect it during application startup (assuming your application is standalone) and alert about it there (likely in addition to alerting about it during %post).

    Or you can Require one of the things I mentioned before and leave it to users to get that right (or --force they way past the error).