Sunday, June 10, 2018

RPM Virtual Packages and Ordering

I recently decided to use an RPM virtual package (one that offers no files but merely Requires others) in order to lock down the version of packages that were being installed when an EC2 was provisioned.  Much to my chagrin it failed miserably when yum loaded packages in an unexpected order.  So, can you tell yum what order to load your RPMs?

The problem seems to be that specifying that package A (package_a) has a dependency on package B (package_b) does not guarantee that within the context of the virtual package, package B will be loaded prior to package A.  Normally, if I were to yum install package A, package B would be installed prior to package A, since package A correctly calls out the dependency.

Requires: package_b

However, in a virtual package where both package A and package B are dependencies, yum only guarantees that both will be installed. 

Requires: package_b
Requires: package_a

As it happens, in my case, package A's %post section invoked scripts that were provided by package B.  So my initial thought was, well, I'll just order the dependencies as shown above.  When I installed the virtual package (let's call it package X), package A's scriptlet failed because package B was not loaded first even though package B is a dependency of package A.  Apparently, "dependency of" does not have meaning as far as the scriptlet is concerned.  Luckily, the solution is quite simple.  The package manager Requires directives includes a modifier that indicates that a package is a dependency of the %post section.

Requires(post): package_b

Adding the above directive to package A solved the problem.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.