rpmrpmbuildrpm-spec

RPM Specfile wrong dependancy version resolved during dnf install


I've created a NodeJS app using NodeJS 18. I'm creating the .specfile to create an AlmaLinux 8 RPM.

My Requires section looks like this:

BuildRequires:         nodejs >= 18.18.2
Requires:              nodejs >= 18.18.2

When I try to install my RPM from a fresh and clean AlmaLinux 8 server, it installs nodejs 10 because the NodeJS DNF module enabled by default is the version 10:

# dnf module list nodejs
Last metadata expiration check: 0:27:46 ago on Fri 16 Feb 2024 01:11:33 PM UTC.
AlmaLinux 8 - AppStream
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
nodejs   20       common [d], development, minimal, s2i   Javascript runtime

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

I've found that it's because of the auto requires process:

# rpm -q --requires my_app.rpm
/usr/bin/bash
/usr/bin/node
nodejs >= 18.18.2
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rpmlib(PayloadIsXz) <= 5.2-1

I've tried to add this line on my .specfile to remove the /usr/bin/node requirment:

AutoReqProv:           no

But the OS still install NodeJS 10

I've tried to add this line on my .specfile, but same issue:

Conflicts:             nodejs < 18

Is there a way to get an error + error message like this one:

All matches were filtered out by modular filtering for argument: nodejs-18.18.2
Error: Unable to find a match: nodejs-18.18.2

Thank you


Solution

  • I've found a solution, working for me.

    Instead of these lines:

    BuildRequires:         nodejs >= 18.18.2
    Requires:              nodejs >= 18.18.2
    

    I've used another "Provides" notation:

    BuildRequires:         nodejs(abi18)
    Requires:              nodejs(abi18)
    Conflicts:             nodejs(abi10)
    Conflicts:             nodejs(abi12)
    Conflicts:             nodejs(abi14)
    Conflicts:             nodejs(abi16)
    

    And now, I've well my error message:

    # dnf install my_app.rpm
    Last metadata expiration check: 0:51:51 ago on Fri 16 Feb 2024 01:11:33 PM UTC.
    Error:
     Problem: package my_app from @commandline requires nodejs(abi18), but none of the providers can be installed
      - conflicting requests
      - package nodejs-1:18.18.2-1.module_el8.8.0+3652+0e111ba0.x86_64 from appstream is filtered out by modular filtering
     (try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)