0

Is it possible to post install Requires dependecies in a spec file on Centos /RHEL 7? I tried Requires: somepackage = 1.0.0.0 The problem is that I need to run a script prior to the dependencies being installed. I tried to run that in the %pre section but it appears that it's not executed before the requires' %pre section is run and failing due to a missing license file.

The spec file looks like this:

  Name:   MyClient
  Requires:    MyServerPackage = 1.0.0.0

  %pre
  echo "Write license that is needed by MyServerPackage prior to install" > /tmp/mylicense

The problem is that I get an error: %pre(MyServerPackage) scriptles failed, exit status 1 Because the /tmp/mylicense is not there at the time MyServerPackages %pre script runs. I've also tried to add a package called mylicense and adding a PreReq: mylicense. But no matter what I try I get that error from the check in MyServerPackage %pre.

crashdog
  • 134
  • 10
  • after hours of searching I found this possibility that works for RHEL 7+ https://stackoverflow.com/questions/22456217/rpm-scriptlet-ordering-for-install-remove-upgrade-using-yum I'm open to other/better solutions. – crashdog Jan 28 '18 at 14:12

1 Answers1

1

I need to run a script prior to the dependencies being installed.

That's impossible; the dependency might have been installed two years ago, for all you know.

To answer where I think you're going, you can specify that something is required for a specific section with:

Requires: MyServerPackage
Requires(pre,preun): MyServerPackage

This would tell it (line 1) that to be installed, MyServerPackage should always be there. Then line 2 explicitly says it should be there before installing or attempting to uninstall this package if you're installing them at the same time. This is useful if, for example, the other package sets up a user name, etc.

Aaron D. Marasco
  • 6,506
  • 3
  • 26
  • 39
  • I mark this as the correct answer. Because it is :) However I actually asked the question wrong. The point was that it's actually about a wrapper package. So the dependency is surely not installed earlier. However I could solve my problem by using the %pretrans macro. – crashdog Jan 29 '18 at 11:16