I have to package my Node.js app into an RPM, which will be installed on Oracle Linux 8 using dnf
from a private registry. My app requires Node.js 16 to work properly.
It looks like there are two ways to define requirements of my app:
Requires
field of RPM.I prefer the second one, so I added this into my RPM spec:
Requires: nodejs >= 16.14
However, Node.js 10 was installed during the RPM installation.
When I tried to reproduce the issue I figured out that Node.js 10 is exactly what dnf
can find:
$ dnf search nodejs -v
============================================= Name Exactly Matched: nodejs =============================================
nodejs.x86_64 : JavaScript runtime
Repo : ol8_appstream
Matched from:
Provide : nodejs = 1:10.24.0-1.module+el8.3.0+9671+154373c8
I went to dnf
docs and found out that there is a modularity concept in Fedora universe. As I understand, it's kind of “release channel”, or, as they call it, “stream”. Usually it's related to a major version of the package.
So, it looks like first I have to switch the module stream, and then install Node.js.
I checked what streams I have to choose from:
$ sudo dnf module list nodejs
Oracle Linux 8 Application Stream (x86_64)
Name Stream Profiles Summary
nodejs 10 [d] common [d], development, minimal, s2i Javascript runtime
nodejs 12 common [d], development, minimal, s2i Javascript runtime
nodejs 14 common [d], development, minimal, s2i Javascript runtime
nodejs 16 common [d], development, minimal, s2i Javascript runtime
nodejs 18 common [d], development, minimal, s2i Javascript runtime
Oracle Linux 8 EPEL Modular Packages for Development (x86_64)
Name Stream Profiles Summary
nodejs 13 default, development, minimal Javascript runtime
nodejs 16-epel default, development, minimal Javascript runtime
Sure, I can switch the stream manually and install Node.js 16 by myself. But I would like to write my RPM in a way which will tell dnf
to do it for me.
My question is: is it even possible? Is there a way for an RPM to require exact module stream?
I searched all over the internet and could not find anything. I feels like usually folks do not do things like that in Fedora/RHEL/OL world. If so, please, tell me what is the correct way to require a proper Node.js version in my case?
Update:
I've figured out the problem with Node.js 10 being installed when I required 16.
It happened because nodejs
in OL8 has Epoch set to 1, which makes the whole version of Node.js 10 1:10.24...
, while I do not set Epoch, which means I'm asking for 0:16.14...
. Hence, dnf
makes a correct assumption installing 1:10.24
when I ask for >= 0:16.14
.
Get more:
No. One of the design decisions with modularity was that the grouping metadata would be separate from the individual packages — conceptually at a higher level, allowing different groups without the individual packages needing to be changed themselves.
The way to do this, theoretically, would be to create your own module containing this RPM and which (at the module level) depends on the stream you want.
If you're targetting EL8 for the foreseeable future, that's probably the right approach still. However, I can't in good conscience recommend putting a lot of work into that, because for various reasons, we're backing away from modularity overall in current Fedora Linux (and probably in future downstreams) and are going to find another way to tackle the same underlying problem.