diff --git a/easybuild/tools/options.py b/easybuild/tools/options.py index fe2abe75f7..8a95aa7226 100644 --- a/easybuild/tools/options.py +++ b/easybuild/tools/options.py @@ -123,7 +123,7 @@ def terminal_supports_colors(stream): CONFIG_ENV_VAR_PREFIX = 'EASYBUILD' XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), ".config")) -XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc').split(os.pathsep) +XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(os.pathsep) DEFAULT_SYS_CFGFILES = [f for d in XDG_CONFIG_DIRS for f in sorted(glob.glob(os.path.join(d, 'easybuild.d', '*.cfg')))] DEFAULT_USER_CFGFILE = os.path.join(XDG_CONFIG_HOME, 'easybuild', 'config.cfg') @@ -213,6 +213,12 @@ class EasyBuildOptions(GeneralOption): DEFAULT_LOGLEVEL = 'INFO' DEFAULT_CONFIGFILES = DEFAULT_SYS_CFGFILES[:] + if 'XDG_CONFIG_DIRS' not in os.environ: + old_etc_location = os.path.join('/etc', 'easybuild.d') + if os.path.isdir(old_etc_location) and glob.glob(os.path.join(old_etc_location, '*.cfg')): + _log.deprecated(f"Using {old_etc_location} is deprecated. Please use " + "/etc/xdg/easybuild.d instead or add /etc to XDG_CONFIG_DIRS", '6.0') + if os.path.exists(DEFAULT_USER_CFGFILE): DEFAULT_CONFIGFILES.append(DEFAULT_USER_CFGFILE) @@ -1322,7 +1328,7 @@ def show_default_configfiles(self): '', "* user-level: %s" % os.path.join('${XDG_CONFIG_HOME:-$HOME/.config}', 'easybuild', 'config.cfg'), " -> %s => %s" % (DEFAULT_USER_CFGFILE, ('not found', 'found')[os.path.exists(DEFAULT_USER_CFGFILE)]), - "* system-level: %s" % os.path.join('${XDG_CONFIG_DIRS:-/etc}', 'easybuild.d', '*.cfg'), + "* system-level: %s" % os.path.join('${XDG_CONFIG_DIRS:-/etc/xdg}', 'easybuild.d', '*.cfg'), " -> %s => %s" % (system_cfg_glob_paths, ', '.join(DEFAULT_SYS_CFGFILES) or "(no matches)"), '', "Default list of existing configuration files (%d): %s" % (found_cfgfile_cnt, found_cfgfile_list), diff --git a/test/framework/options.py b/test/framework/options.py index 089b068e62..6e7823f907 100644 --- a/test/framework/options.py +++ b/test/framework/options.py @@ -3497,7 +3497,7 @@ def test_show_default_configfiles(self): '', "* user-level: ${XDG_CONFIG_HOME:-$HOME/.config}/easybuild/config.cfg", " -> %s", - "* system-level: ${XDG_CONFIG_DIRS:-/etc}/easybuild.d/*.cfg", + "* system-level: ${XDG_CONFIG_DIRS:-/etc/xdg}/easybuild.d/*.cfg", " -> %s/easybuild.d/*.cfg => ", ]) @@ -3512,12 +3512,12 @@ def test_show_default_configfiles(self): homecfgfile_str += " => found" else: homecfgfile_str += " => not found" - expected = expected_tmpl % ('(not set)', '(not set)', homecfgfile_str, '{/etc}') + expected = expected_tmpl % ('(not set)', '(not set)', homecfgfile_str, '{/etc/xdg}') self.assertIn(expected, logtxt) # to predict the full output, we need to take control over $HOME and $XDG_CONFIG_DIRS os.environ['HOME'] = self.test_prefix - xdg_config_dirs = os.path.join(self.test_prefix, 'etc') + xdg_config_dirs = os.path.join(self.test_prefix, 'etc', 'xdg') os.environ['XDG_CONFIG_DIRS'] = xdg_config_dirs expected_tmpl += '\n'.join([ @@ -3542,12 +3542,12 @@ def test_show_default_configfiles(self): xdg_config_home = os.path.join(self.test_prefix, 'home') os.environ['XDG_CONFIG_HOME'] = xdg_config_home - xdg_config_dirs = [os.path.join(self.test_prefix, 'etc'), os.path.join(self.test_prefix, 'moaretc')] + xdg_config_dirs = [os.path.join(self.test_prefix, 'etc', 'xdg'), os.path.join(self.test_prefix, 'moaretc')] os.environ['XDG_CONFIG_DIRS'] = os.pathsep.join(xdg_config_dirs) # put various dummy cfgfiles in place cfgfiles = [ - os.path.join(self.test_prefix, 'etc', 'easybuild.d', 'config.cfg'), + os.path.join(self.test_prefix, 'etc', 'xdg', 'easybuild.d', 'config.cfg'), os.path.join(self.test_prefix, 'moaretc', 'easybuild.d', 'bar.cfg'), os.path.join(self.test_prefix, 'moaretc', 'easybuild.d', 'foo.cfg'), os.path.join(xdg_config_home, 'easybuild', 'config.cfg'),