RPM spec decide which dependency installs first

906 views Asked by At

I'm trying to create an RPM (my-main-rpm) that has over 10 dependencies (most of which are not made by me), but I want to first install another RPM (my-rpm-prerequisite) created by me. This my-rpm-prerequisite RPM creates/modifies some files that need to be done before the other dependencies install.

I want to be able to install the whole rpm using the single command: dnf/yum/zypper install my-main-rpm which should install all the dependencies. But I want that command to first install my-rpm-prerequisite

Is there any way I can do this?

Or is there some way I can execute a script before my dependencies are installed?

2

There are 2 answers

1
Chris Maes On

Afaik that is not possible. The rpm dependency system just makes sure that the dependencies for each package are installed, but not in which order. Your dependencies might already be present on the system before you run the installation of my-main-rpm. In that case it is impossible to make your script run before the installation of your dependencies since they are already installed.

The only way I see you can influence the order of installation is by setting dependencies, but you can only do that on packages you create yourself:

  • If A depends on B and B depends on C, then they will be installed in the order C -> B -> A.
  • if A depends on B and C, then B and C will be installed before A, but the order cannot be guaranteed; it can be C -> B -> A but also B -> C -> A.
1
msuchy On

This is impossible to achive using Requires as Chris stated. But there is other way if you "only" want to execute some script.

First, you may specify in my-rpm-prerequisite.spec:

Supplements: rpm-prerequisite

This way default installations will install my-rpm-prerequisite as enhancement of rpm-prerequisite.

Second, you specify %pretrans script. It is run on very begining of transaction. See https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#pretrans

But be aware that %pretrans may be executed even when installing the base system. So there nothing installed on system (or in chroot). So it should be written in Lua, which is interpretted by rpm itself.