Search code examples
rpmrpmbuildrpm-spec

RPMBUILD: Is is possible to RPM configuration file portability at install time


As per my requirement is is possible that the rpm is same for all server but only one config file change as per the server environment like production,staging,testing or else. i have bundle of config file for all server but i don't want hardcode it in spec file or it is not possible to create different rpm for all server.it is possible to specify name of the config file at time of rpm install on client side.


Solution

  • Possibly a repeat of this one so I will copy my answer from there...


    I don't think there's a native way; I would do a %post like you had noted.

    However, I would do this (similar to something I do with an internal-only package I develop for work):

    1. Three separate files /etc/name.conf-developer, /etc/name.conf-live, etc.
    2. Have all three packages provide a virtual package, e.g. name-config
    3. Have main package require name-config
      • This will make rpm, yum, or whatever require at least one be installed in the same transaction
    4. Have all three packages conflict with each other
    5. Have each config package's %post (and possibly %verify) symlink /etc/name.conf to the proper config
      • This also helps show the user what is happening

    Cons:

    1. It's a little hackish
    2. rpm --whatprovides /etc/name.conf will say it is not owned by any package