[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: XDG Base Directory Specification ignores installation directories
From: |
Gavin Smith |
Subject: |
Re: XDG Base Directory Specification ignores installation directories |
Date: |
Wed, 28 Aug 2024 21:26:55 +0100 |
On Wed, Aug 28, 2024 at 01:34:23PM +0200, Patrice Dumas wrote:
> Hello,
>
> Using the XDG Base Directory Specification is not as straightforward as
> what I thought. I have changed my mind compared to my previous
> proposition, because interaction between defaults if $XDG_DATA_DIRS is
> not set and $datadir installation directory are not really considered by
> the specification (I'd say rightly as it is out of scope for the
> specification) but we need to make decisions about all that.
I'm a bit confused as I thought it was configuration files which we
were discussing, which would be XDG_CONFIG_DIRS, not XDG_DATA_DIRS.
I see that htmlxref.cnf is installed under $datadir, e.g. as
"/usr/local/share/texinfo/htmlxref.cnf". I suppose there is a question
of whether this file counts as "data" or "configuration". We should
decide which one each file we are talking about is, otherwise this issue
is more confusing.
> Here is my current proposal:
>
> - replace ~/.texinfo by the XDG specification, with $XDG_CONFIG_HOME.
> In my opinion, it is an improvement compared to using ~/.texinfo directly
> in HOME. The specification is unclear on what should be in $XDG_DATA_HOME
> or $XDG_CONFIG_HOME but my feeling is that $XDG_CONFIG_HOME is better.
> Still find files in ~/.texinfo/ after specification locations for some
> time, with a deprecation message if found in that directory.
I added similar logic for the "info" program, in infomap.c. XDG_CONFIG_HOME
is checked first (both as an environment variable and in the default
"$HOME/.config" location). If the file is found there, then the old
location ("$HOME/infokey") is not checked.
The case of htmlxref.cnf (I assume that's the file we're talking about)
is more complicated as more than one file can be loaded. I would say
to check under XDG_CONFIG_HOME first, and if found, do *not* check under
the old location ("$HOME/.texinfo/"). This would allow setting
XDG_CONFIG_HOME to override all configuration in the user's home
directory.
Check under XDG_CONFIG_DIRS in any case for htmlxref.cnf files (with
any files there having a lower priority).
There is no rush to add a deprecation message.
> - to replace the former search in $datadir/texinfo:
> if $XDG_DATA_DIRS is set, search in those directories. Then search
> in $datadir (if not already in $XDG_DATA_DIRS). Last search in
> /usr/local/share and /usr/share (if not already done), which are
> the default for $XDG_DATA_DIRS that have to be used if $XDG_DATA_DIRS
> is not set. In what I propose, they are used even if $XDG_DATA_DIRS
> is set.
If we consider htmlxref.cnf a "config" file rather than a "data" file,
then the copy of htmlxref.cnf under $datadir (e.g. /usr/local/share/texinfo)
would not be covered as a "config" file by the XDG specification.
Therefore setting XDG_DATA_DIRS should have no effect on whether this
file is read or not.
However, if htmlxref.cnf is a "data" file, then here's an attempt at
laying out what is checked:
* First check "." and "./.texinfo" (cwd and relative to source file
location), as is currently done. This is not really under the purview
of the XDG spec as it is a project-specific configuration file.
* Regardless of whether anything was found in the previous step, check
XDG_DATA_HOME, then in the "old location" ($HOME/.texinfo) *but only*
if nothing was found in XDG_DATA_HOME. Accumulate the data from any
htmlxref.cnf file found with that in the previous step.
* Regardless of whether anything was found in the previous steps, then
we should check XDG_DATA_DIRS. Only if the XDG_DATA_DIRS variable
is unset, then use $datadir as the default. We ignore this part of
the spec:
"If $XDG_DATA_DIRS is either not set or empty, a value equal to
/usr/local/share/:/usr/share/ should be used.
as it seems wrong to hardcode these paths when we already have $datadir.
Accumulate the data from any htmlxref.cnf file found with those in
the previous two steps.
I hope my attempt at making sense of this illuminates rather than
obscures. I'm not sure I really have the time at the moment to think
about this properly.
We don't need to change all the uses of $datadir (from autoconf/automake)
in Texinfo with XDG_DATA_DIRS, I believe. This change is just for user
configuration files such as they might have in their home directory, not
for installed parts of Texinfo (like Common.pm, etc.). (I don't think
we were discussing this but I'm saying it just in case.)
> - do the same for $sysconfdir/texinfo as for $datadir/texinfo.
Which files would this affect?