From 75290b40d15b0b8e051a69da8f1ea96f41da2b4e Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 15 Jun 2021 13:05:04 +0200 Subject: [PATCH 1/2] Introduce a Linux FHS run mode The idea is that distro native packages can use this runmode without having to patch the code base. This is still not complete since there's no automatic detection of when to use this. --- lib/puppet/util/run_mode.rb | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/puppet/util/run_mode.rb b/lib/puppet/util/run_mode.rb index a64198150f4..00aac0cb910 100644 --- a/lib/puppet/util/run_mode.rb +++ b/lib/puppet/util/run_mode.rb @@ -105,6 +105,48 @@ def vendor_module_dir end end + class LinuxFHSRunMode < RunMode + def conf_dir + which_dir("/etc/puppet", File.join(ENV.fetch("XDG_CONFIG_HOME", "~/.config"), "puppet")) + end + + def code_dir + File.join(conf_dir, 'code') + end + + def var_dir + which_dir("/var/lib/puppet", File.join(ENV.fetch("XDG_DATA_HOME", "~/.local/share"), "puppet")) + end + + def public_dir + which_dir("/var/cache/puppet/public", File.join(ENV.fetch("XDG_CACHE_HOME", "~/.cache"), "puppet", "public")) + end + + def run_dir + which_dir("/run/puppet", File.join(ENV.fetch("XDG_RUNTIME_DIR") { "/run/user/#{Etc.getpwuid.uid}" }, "puppet")) + end + + def log_dir + which_dir("/var/log/puppet", File.join(ENV.fetch("XDG_STATE_HOME", "~/.local/state"), "puppet", "logs")) + end + + def pkg_config_path + # automatically picked up + end + + def gem_cmd + '/usr/bin/gem' + end + + def common_module_dir + '/usr/share/puppet/modules' + end + + def vendor_module_dir + '/usr/share/puppet/vendor_modules' + end + end + class WindowsRunMode < RunMode def conf_dir which_dir(File.join(windows_common_base("puppet/etc")), "~/.puppetlabs/etc/puppet") From 19788bac964079cb4833c46f185887b3395e2a63 Mon Sep 17 00:00:00 2001 From: Ewoud Kohl van Wijngaarden Date: Tue, 15 Jun 2021 13:08:21 +0200 Subject: [PATCH 2/2] [WIP] Use Linux FHS mode --- lib/puppet/util/run_mode.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/util/run_mode.rb b/lib/puppet/util/run_mode.rb index 00aac0cb910..88950e0d2dd 100644 --- a/lib/puppet/util/run_mode.rb +++ b/lib/puppet/util/run_mode.rb @@ -16,7 +16,7 @@ def self.[](name) if Puppet::Util::Platform.windows? @run_modes[name] ||= WindowsRunMode.new(name) else - @run_modes[name] ||= UnixRunMode.new(name) + @run_modes[name] ||= LinuxFHSRunMode.new(name) end end