Question

I'm pretty new to building spec files and rpm's in general. I have seen the question asked but the answers did not address my exact problem.

I am creating a Cassandra RPM to learn the process of how to create an RPM and have looked at other specfiles as well. I have a problem though.

I have my %build section modify ownerships and permissions to the "cassandra" user. I get the error that the said user doesn't exist yet. I found this page: http://fedoraproject.org/wiki/Packaging%3aUsersAndGroups explaining what I should do. So I added

Requires(pre): shadow-utils

also added the %pre section:

getent group %{owner} > /dev/null || groupadd -r %{owner}
if ! getent passwd %{owner} >/dev/null ; then
  sudo useradd -d /usr/share/%{owner} -g %{owner} -M -r %{owner}
fi
exit 0

The problem is that this is actually not executing and I am getting the following error:

chown: invalid user: 'cassandra'
error: Bad exit status from /var/tmp/rpm-tmp.6HOAZx (%build)

Not sure what to do and would appreciate any help. :)

Thanks

Was it helpful?

Solution

The error you are seeing is occurring when the package is built.

But the changes you are making to address the problem are in the %pre section of the package, which runs when the package is installed on the target system.

Your changes might have the desired affect (creating the user/group) when the package is installed. But you cannot test that until you first address the build-time problem.

The build time problem is most likely occurring because the 'cassandra' user does not exist on the build system. You should not try to change ownership of files during a package build. Instead, use the %attr modifier in the %files section to indicate the file attributes.

See: http://www.rpm.org/max-rpm/s1-rpm-anywhere-specifying-file-attributes.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top