Discussion:
Not installing to hard-coded locations vs polkit's fixed location
Mike Fleetwood
2017-08-21 10:12:53 UTC
Permalink
Hi,

I'm working on adding installation of a polkit action file into
GParted's build and install system, however the polkit daemon only
recongises action files installed into the single location of
/usr/share/polkit-1/action/.

Currently the Makefile.am contains this line:
(larger fragment of the Makefile.am below)
polkit_actiondir = $(datadir)/polkit-1/actions

This allows 'make distcheck' to work and when GParted is built with
'./configure --prefix=/usr' for the polkit action file to be installed
into the required location. However when prefix is left defaulted to
/usr/local the polkit action file is obviously installed into
/usr/local/share/polkit-1/action/ which is ignored by the polkit daemon.

Are there any resolutions to this?
I could:
1) Leave things as they are and document it as the builders
responsibility, that when prefix defaults to /usr/local, or anything
other than /usr, that the polkit action file will need manually
installing into the correct location under a unique name so as not to
overright any distro package provided copy.
2) Set polkit_actiondir to /usr/share/polkit-1/action but that is
against automake guidance and breaks 'make distcheck'.
Are there any other solutions which are reasonable?

Thanks,
Mike


Larger fragments of Makefile.am:

@INTLTOOL_POLICY_RULE@
polkit_action_in_in_FILES = org.gnome.gparted.policy.in.in
polkit_action_in_FILES = org.gnome.gparted.policy.in
polkit_action_FILES = $(polkit_action_in_FILES:.policy.in=.policy)
polkit_actiondir = /usr/share/polkit-1/actions
if INSTALL_POLKIT_ACTIONS
polkit_action_DATA = $(polkit_action_FILES)
endif

CLEANFILES = $(polkit_action_in_FILES) ...

EXTRA_DIST = $(polkit_action_in_in_FILES) ...

DISTCLEANFILES = $(polkit_action_DATA) ...

do_subst = sed -e 's,[@]sbindir[@],$(sbindir),g' \
-e 's,[@]bindir[@],$(bindir),g' \
-e 's,[@]gksuprog[@],$(GKSUPROG),g' \
-e 's,[@]enable_xhost_root[@],$(ENABLE_XHOST_ROOT),g'

org.gnome.gparted.policy.in: org.gnome.gparted.policy.in.in Makefile
$(do_subst) < $(srcdir)/org.gnome.gparted.policy.in.in >
org.gnome.gparted.policy.in
Nick Bowler
2017-08-21 14:06:43 UTC
Permalink
Hi,
Post by Mike Fleetwood
I'm working on adding installation of a polkit action file into
GParted's build and install system, however the polkit daemon only
recongises action files installed into the single location of
/usr/share/polkit-1/action/.
There is a section about this issue in the Automake manual[1].
Post by Mike Fleetwood
(larger fragment of the Makefile.am below)
polkit_actiondir = $(datadir)/polkit-1/actions
[...]
Post by Mike Fleetwood
Are there any resolutions to this?
1) Leave things as they are and document it as the builders
responsibility, that when prefix defaults to /usr/local, or anything
other than /usr, that the polkit action file will need manually
installing into the correct location under a unique name so as not to
overright any distro package provided copy.
It is pretty much fine as is. If it matters, the installer can specify
polkit_actiondir when they install your package, for example:

% make polkit_actiondir=/the/correct/location install

Just include a note about it in your README.

Things get a bit more complicated if you want the default install
location to be something probed at configure time. This usually
involves some heuristics to get a reasonable user experience.
Post by Mike Fleetwood
2) Set polkit_actiondir to /usr/share/polkit-1/action but that is
against automake guidance and breaks 'make distcheck'.
This is generally a bad idea, as installing to hardcoded locations breaks
many things. For example, it will prevent successful installation as an
unpriviliged user (unless the user knows to override polkit_actiondir).
Post by Mike Fleetwood
Are there any other solutions which are reasonable?
Another option (which might not be acceptable for you) is to do
nothing: i.e., don't install any files into the external location
by default. The user can place files manually into the correct
locations as required.

[1] https://www.gnu.org/software/automake/manual/automake.html#Hard_002dCoded-Install-Paths

Cheers,
Nick
Mike Fleetwood
2017-08-22 07:35:07 UTC
Permalink
Hi Nick,
Post by Nick Bowler
Post by Mike Fleetwood
I'm working on adding installation of a polkit action file into
GParted's build and install system, however the polkit daemon only
recongises action files installed into the single location of
/usr/share/polkit-1/action/.
There is a section about this issue in the Automake manual[1].
Post by Mike Fleetwood
(larger fragment of the Makefile.am below)
polkit_actiondir = $(datadir)/polkit-1/actions
[...]
Post by Mike Fleetwood
Are there any resolutions to this?
1) Leave things as they are and document it as the builders
responsibility, that when prefix defaults to /usr/local, or anything
other than /usr, that the polkit action file will need manually
installing into the correct location under a unique name so as not to
overright any distro package provided copy.
It is pretty much fine as is. If it matters, the installer can specify
% make polkit_actiondir=/the/correct/location install
Just include a note about it in your README.
--8<-- trimmed --8<--
Post by Nick Bowler
[1] https://www.gnu.org/software/automake/manual/automake.html#Hard_002dCoded-Install-Paths
Thank you for your advice. I will stick with what I have and add a note
in the README file as you suggest.

I had read Automake Manual section 27.10 Installing to Hard-Coded
Locations, but the examples installing files used by another package
were querying python and emacs lisp so I didn't really understand how to
apply them in my case with polkit not being a programming language and
its fixed location.

Thanks again,
Mike

Loading...