Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does %defattr mean in RPM spec files?

While creating RPMs, the RPM spec files have a directive %defattr . I know that it defines the default attributes for the files that are installed by that RPM. If I write the %defattr as below, what does it mean?

%defattr(-testuser, testuser)
like image 471
Mariselvam Avatar asked Aug 05 '11 06:08

Mariselvam


2 Answers

The mode you specified is invalid. %defattr takes four arguments

From http://ftp.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html#S3-RPM-INSIDE-FLIST-DEFATTR-DIRECTIVE

The %defattr Directive

The %defattr directive allows setting of default attributes for files and directives. The %defattr has a similar format to the %attr directive:

  1. The default permissions, or "mode" for files.

  2. The default user id.

  3. The default group id.

  4. The default permissions, or "mode" for directories.

The %attr directive has the following format:

%defattr(file mode, user, group, dir mode)

As with %attr if a particular attribute does not need to be specified (usually because the file is installed with that attribute set properly), then that attribute may be replaced with a dash. In addition the directory mode may be ommited. %defattr tends to be used at the top of %files.

like image 188
brightlancer Avatar answered Oct 16 '22 00:10

brightlancer


To set permissions and ownerships in a spec file treat the directory like a file thusly... %defattr will set all files without %attr (in this case rww owner apache group apache and set directories to 755).

%files
#%attr(<mode>, <user>, <group>) file
%defattr(644,apache,apache,755)
%attr(-,apache,apache) /var/www/coolapp
%attr(-,apache,apache) /var/www/coolapp/js
%attr(-,apache,apache) /var/www/coolapp/static
/var/www/coolapp/index.html
/var/www/coolapp/__init__.py
/var/www/coolapp/settings.py
/var/www/coolapp/urls.py
/var/www/coolapp/wsgi.py
like image 7
Chad Prey Avatar answered Oct 16 '22 01:10

Chad Prey