Usually only one package owns a given directory. On a typical system, there will be a package such as "filesystem" which may own things such as /bin
. In the case of the filesystem
package on Red Hat and OpenSUSE, that package owns /usr/bin
but none of the files within that directory.
You could do that, by making a wrapper-package which owns things that are shared across your applications, and making it a dependency (Requires
) of the applications which install into those directories.
To see what actually owns something with rpm, you can use the -qf
options, e.g.,
rpm -qf /usr/lib/mysystem/myprog
The command works for directories as well as files.
The documentation for %dir
and %files
is the place to start when deciding how to make a package own a directory. In Maximum RPM: Taking the Red Hat Package Manager to the Limit, chapter 13 Directives For the %files list, it says:
As we mentioned in the section called The %files List, if a directory is specified in the %files list, the contents of that directory, and the contents of every directory under it, will automatically be included in the package
The way to get around this, is to use the %dir directive. By adding this directive to the line containing the directory, RPM will package only the directory itself, regardless of what files are in the directory at the time the package is created. Here's an example of %dir in action.
%dir /usr/blather
So the latter of the suggested cases follows the documentation. However, as a check on whether the syntax is correct (even if the rpm happens to build) it is good practice to examine the list of pathnames.
Investigating Fedora 21 to find packages for which rpm -qf
shows the same directory finds several. For example, initscripts and chkconfig use the %dir
directive to do this:
%dir /etc/rc.d
%dir /etc/rc.d/rc[0-9].d
%dir /etc/rc.d/init.d
in initscripts
spec-file, and
/etc/rc.d
/etc/rc.d/init.d
/etc/rc[0-6].d
/etc/rc.d/rc[0-6].d
in chkconfig
spec-file. However, the initscripts
package requires /sbin/chkconfig
, which is provided by the chkconfig
package. Because of that dependency, chkconfig
is the actual owner of the directory.