skip to Main Content

The file attribute can be specified in the field of rpm.spec, e.g.

%dir %attr(0770, userA, groupA) /etc/config/

My point is, There are many folders under /etc/config and I want to specify their attributes the same as /etc/config. I don’t want to specify them one by one. Is there a way to specify all the folders’ attribute under /etc/config recursively? Just like sudo chmod -R 770 /etc/config?

2

Answers


  1. You can do this:

    %install
    ...
    #whatever in plain bash
    chmod -R 770 %{buildroot}%{_sysconfdir}/config
    chmod 644 %{buildroot}%{_sysconfdir}/config/foo/bar/somefile
    
    %files
    # the attributes are copied from buildroot, but not user
    %{_sysconfdir}/config
    %{_sysconfdir}/config/foo/bar/somefile
    

    or

    %install
    ...
    #whatever in plain bash
    chmod -R 770 %{buildroot}%{_sysconfdir}/config
    chmod 644 %{buildroot}%{_sysconfdir}/config/foo/bar/somefile
    
    %files
    %defattr(-, userA, groupA, -)
    %{_sysconfdir}/config
    

    or

    %files
    # fileattr, user, group, dirattr
    %defattr(770, userA, groupA, 550)
    %{_sysconfdir}/config
    
    Login or Signup to reply.
  2. when you use the %dir directive, you tell rpmbuild to package only that directory and not the contents recursively (see here). So why don’t you just use:

    %attr(0770, userA, groupA) /etc/config/
    

    to package /etc/config/ and all subdirectories and files recursively with those attributes?

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search