Search code examples
centos7rpmbuildrpm-specrhel7

post install dependencies order in spec files


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.


Solution

  • 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.