0

I'm creating an RPM file (with rpmbuild) whose post-install script will create a file in /etc/X11/xinit/xinitrc.d/. To make sure that the directory already exists, I'd like to specify a dependency on a package which creates it.

Is it correct in this case to add a Requires: /etc/X11/xinit/xinitrc.d line to the spec file? Or is it not allowed to depend on directories, and should I rather add a dependency on xorg-x11-xinit package (which appears to provide this directory on my system)?

The package is intended to work on CentOS (RHEL) 6.

oliver
  • 6,204
  • 9
  • 46
  • 50

2 Answers2

0

This should work (you can Require any path), but you should be depending on the package that provides that path. There must be a reason you are not doing this?

user318904
  • 2,968
  • 4
  • 28
  • 37
  • I just thought it would be better to depend on the directory rather than a specific package. That way, another package may provide the path as well, and theoretically the user may choose which package should be installed to satisfy this dependency. I realize that it's mostly theoretical in this case, but would like to know what's the "correct" way to express such a dependency. – oliver Feb 09 '15 at 12:05
  • The case you are talking about: two packages owning the same directory, is a packaging error, it means they would not be able to be installed at the same time. – user318904 Feb 09 '15 at 16:56
0

You should use virtual packages to avoid surprises, when the required file can be provided by more than one package.

In your example, yum provides says that /etc/X11/xinit/xinitrc.d is provided by xorg-x11-xinit and qt5-qtbase-gui, so, specifying that path as a dependency could pull a package you don expect.

You should have a virtual package for each possible package that provides the file. The package my-xinit-x11 should contain:

Requires:     xorg-x11-xinit
Provides:     my-xinit

And your package should contain:

Requires:    my-xinit

More virtual packages can be created with the same Provides, so when either is installed rpmbuild will see the dependency as satisfied

Bruno9779
  • 1,551
  • 2
  • 14
  • 31