dbus services directory incorrectly guessed if the prefix is not '/usr'
Building gcr on a Linux system using a prefix of anything other than '/usr' results in the dbus services files being written to '${prefix}/share/dbus-1/services'.
I'm building gcr on a self-built Linux system with an installation prefix of '/opt/gnome' which results in the dbus services directory being set to '/opt/gnome/share/dbus-1/services', a location that systemd will not search when looking for the installed files. Specifically:
meson setup \
--prefix="/opt/gnome" \
--libdir="/opt/gnome/lib64" \
--localstatedir="/var"
The 'dbus-1.pc' pkg-config file identifies the path for the service files in the 'session_bus_services_dir' variable. This should be used if available before accepting any default value (i.e. ask for the right location before guessing).
History and Circumvention
For anyone looking at this issue and facing the same problem, here's what went on. It is not, strictly speaking, resolved but a method for circumventing it has arisen as a result.
I raised this issue on the basis that the dbus service directory being installed to was not the one that dbus actually used when gcr was built with a prefix other than "/usr", i.e. you would wind up installing something that didn't work. Unfortunately, there is an opposing ideological position that one does not "pollute" directories outside of "${prefix}", so my initial change (!86 (closed)) was rejected. I amended it to provide an override value so that the existing default would be used unless a command line parameter overrode it. This idea was also rejected.
Some changes were made as a result of merge request !94 (closed). This resulted in the dbus services directory being determined by this statement:
dbus_services_dir = dbus_dep.get_variable('session_bus_services_dir',
pkgconfig_define: [ 'datadir', get_option('datadir') ],
The end of the directory would be whatever was specified in the ".pc" file and the start would come from whatever was specified for "datadir" when gcr is setup. As with the pre-change code, this would result in what I would consider the wrong directory being used ('/opt/gnome/share/dbus-1/services', not '/usr/share/dbus-1/services') and gcr not actually working after installation.
However, this change can be perverted to get the desired outcome.
As long as "dbus-1.pc" can be found, there is an opportunity to override the default behaviour by ensuring that the overriding value of "datadir" cannot be used. "dbus-1.pc" contains the line
session_bus_services_dir=${datadir}/dbus-1/services
Simply replace the variable substitution, i.e. assuming "datadir" resolves to "/usr/share", change it to read:
session_bus_services_dir=/usr/share/dbus-1/services
This can be either be done within the system "dbus-1.pc" file, or it can be a temporary copy added to "${PKG_CONFIG_PATH}". Either way, it has the effect of ensuring that the value in "dbus-1.pc" cannot be amended by meson.
This is a less desirable solution than a specific override as found in other projects, including gnome ones, but it does get around the problem without having to modify the "meson.build" files.
Be warned that there are, according to my estimate, another 28 gnome projects which have this issue but do not have the modifications required to circumvent the problem in this way. I am not proposing pursuing a fix to these issues as my circumvention for these other projects is not to build the non-essential parts of gnome (which results in around 75% of it not being built). If, however, you don't want to that or don't have the option, feel free to pursue getting the same changes made in those projects.
In connection with gcr, the changes made now mean this issue also affects the systemd directory but the same circumvention technique can be used there too.