views:

58

answers:

2

I'm trying to build an RPM that will install file dependencies if they don't exist. Is there an RPM Spec Section that will be executed before the RPM checks for dependencies. (I'm refering to file dependencies not package dependencies listed in the "Requires" header).

Example: If I have a perl file and the execution permissions bit is set. RPM will check to see if perl is installed in the location the "#!/bin/perl" specifies in the perl file. (It looks like it checks the RPM database to see if perl is installed in that location instead of checking the actual file location) If perl is not installed in the /bin/perl location I want to install it before the RPM will error out telling me "/bin/perl is needed by [MY_PACKAGE]"

Side Question: Since the file dependency checks the RPM database is there a way to update the installed locations? i.e. If my perl script specifies "#!/usr/local/bin/perl" but my RPM database has perl located in "/usr/bin/perl" how do I update the RPM datbase? Symbolically linking "/usr/local/bin/perl" manually won't work becuase it doesn't updated the RPM database. The RPM installer will still say "/usr/local/bin/perl is needed by [MY_PACKAGE]"

+1  A: 

I think you're trying to use the wrong tool for the job. The job of rpm is to install the packages it's told to install, not to go and look for other packages. Pulling in dependencies is the job of higher-level tools such as apt, urpmi or yum.

For the example you give, if your package requires /usr/local/bin/perl, then some other package must provide /usr/local/bin/perl. That could be a package that contains a symlink from /usr/local/bin/perl to /usr/bin/perl and declares a dependency on /usr/bin/perl (I don't know how that lets you require a minimum version of /usr/local/bin/perl though).

Gilles
+1  A: 

One of the design guidelines for RPM specs is that they should not print error messages or in any way interact with the user. You don't know if they will be installed manually or via yum/GUI.

You can specify dependencies on files just like dependencies on file packages, make sure you start the filename with /. If you print out the dependency lists for your RPMs you'll see some .so libraries listed there this way.

If you are using Perl, the best way would be to include perl as your requirement in the spec and rely on it's normal location for the distro, i.e. /usr/bin/perl.

m1tk4