What does %defattr mean in RPM spec files?

Mariselvam picture Mariselvam · Aug 5, 2011 · Viewed 38k times · Source

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)

Answer

brightlancer picture brightlancer · Aug 16, 2011

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.