Create an RPM that can also manage files and add users

I am trying to create an RPM in Fedora 15 that will install my software, but for my software to work correctly after installation, I also need to edit other (configuration) files on the system, add users / groups, etc. Some of these tasks are restricted to the root user. I know that I never created an RPM as root, and I understand why this is such a bad idea. However, if I add script shell statements to my specification file (% post,% prep ... any section) to edit the necessary files, add users / groups, etc. My rpmbuild command does not work with the message "Permission denied" (not surprising).

What is the best way to handle this? Should I first tell my users to install my package first, and then possibly run the shell script as root to configure all this? It is not very elegant. I was hoping to allow the user to do everything with one simple command, such as "yum install mysoftware".

Most of my research shows that perhaps this should not even be done using RPMs. I read many parts of Maximum RPM and many other useful resources, but did not find what I was looking for. I am new to creating RPM, but I was able to successfully create a simple specification file for my software ... I just can’t properly configure all the settings after unpacking and installing the package in the right place. Any input is very welcome!

+5
source share
2 answers

In the section of %preyour RPM file, .specyou need to check all the conditions necessary for installing your software.
The section of %postyour RPM file .specshould make all the changes necessary to run your software.
To avoid file permission errors in the section of %postyour RPM file .spec, you can set the access rights and file permissions in the section %files. Thus, the user installing the RPM has the appropriate permissions to modify the configuration files.

%install
# Copy files to directories on your installation server

%files
# Set file permissions and ownership on your installation server
%attr(775, myuser, mygroup) /path/to/my/file


%pre
# Check if custom user 'myuser' exists. If not, create it.
# Check if custom group 'mygroup' exists. If not, create it.
# All other checks here

%post
# Perform post-installation steps here, like editing other (configuration) files.
echo "Installation complete."
+5
source

useradd %pre rpmbuild. . , , .

+7

All Articles