Using DNF inside custom RPM

Hello,
I need to install a package (let’s say X) from my RPM.
If I try to install it with DNF (or YUM), I have a deadlock.
If I declare it as “Requires: X”, it is obviously installed but, in case we remove X, my whole package is also removed as it depends on X.
How can I manage that?

Your question isn’t quite clear. But a rather dangerous answer to remove a package without removing deps is rpm --nodeps -e . An example of its danger–one of our clients opened a ticket, frantic because dnf and rpm no longer worked. It turned out that they had used nodeps to remove an ldap package that included some files required by dnf. So, I would recommend against doing it.
I’m not sure if your problem is that dnf fails with pkg y requires pkg x and x can’t be found. That is a different issue. Sometimes you can solve it with dnf provides */filename but other times it may just be that it’s not available for Fedora.

No, I want to install package X from inside my RPM.
I cannot use “Require: X” because it’s not a (mandatory) dependancy.
I’m just trying to find another way.
Any idea?

I think the best thing is to be specific about what you’re trying to add to what package. Speaking generally, the only thing I can think of is to rebuild the rpm, editing the spec file, but I don’t have enough rpm knowledge to be too much help–perhaps if you are specific about what dependency you’re adding to what package, someone with knowledge of it could help. You also might want to give a better title so that who ever knows about it will see the title and think to help. For example, want to add scursese to mutt.rpm will get more looks than want to add something to package.

I’m sorry I can’t be of more help, but it’s a bit beyond my knowledge.

What do you mean by “installing from inside your RPM”?

You can use Recommends: X to make it a weak dependency.