LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   File ownership from RPM spec file (https://www.linuxquestions.org/questions/linux-general-1/file-ownership-from-rpm-spec-file-4175525373/)

r0tty 11-14-2014 03:55 AM

File ownership from RPM spec file
 
Hi,

How can I write a spec file so that after installation of the package the files belong to a user defined by an external factor?

The use case is that the files delivered by a package belong to different user accounts on prod servers than on dev and test.

Thanks in advance for any assistance.

Regards,
Rotty

smallpond 11-14-2014 01:31 PM

You can do chown in a script in the %post section based on something present or absent on the target system.
For example it could install the files for the production case, then in %post check for a file named /tmp/MYRPM_TEST.

r0tty 11-17-2014 03:06 AM

Hi,

Thanks for that.

I could write quite a simple bit of bash for the %post section that uses the hostname to determine if it is a prod, test or dev install. From that I can work out which account to chown the files to.

However, from within the %post section how can I enumerate the files being dropped by the RPM? Without that I will have hard code all the files in the chown command (or top level directories if I'm using 'chown -R'), which is a problem for maintainability.

Thanks,
Rotty

smallpond 11-17-2014 05:57 AM

I'm not sure if this would work, but you could try 'rpm -qpl rpmname' to list files.


All times are GMT -5. The time now is 12:32 PM.