views:

168

answers:

1

I have a project that requires post-install hooks for deployment. My method is to use setuptools to generate the skeleton rpm spec file and tar the source files.

The problem is that I don't know how to control permissions with this method. The spec file looks like:

%install
python setup.py install --single-version-externally-managed --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES

%files -f INSTALLED_FILES
%defattr(755,%{user},%{user})

This works out reasonably well: in that all files get set set to the appropriate user and permissions. But the directories don't have the attributes set on them. I can't tell whether this is a problem, but it does seem strange: all the directories are owned by root with 755 permissions. Does anyone know a good (reasonably standard) way to make the directories owned by user? I ask because my company tends to prefer packaging applications that will deploy under an application-specific role-account. When I use setuptools to put the results in site-packages, .pyc files are copied over. But if I want to create a config file directory off the path, it seems like a good amount to work around.

+1  A: 

%defattr(755,%{user},%{user})

That line sets the default permissions, user, and group ownership on all files. You can override the default with something like:

%attr(644, <username>, <username>) </path/to/file>

If you want the default to be owned by a user other than root, then you probably need to define the 'user' macro up at the top of the spec:

%define user myusername
derks