From 9bbf34e760b2e2a45697e9de48f6533cd46675db Mon Sep 17 00:00:00 2001 From: Rikard Nordgren Date: Wed, 8 May 2024 11:07:34 +0200 Subject: [PATCH] Update selection of path to psn.conf Fix problem with desktop not being used when using the latest File::HomeDir. Introduce env variable PSNCONFPATH as an option --- .../release_notes/release_notes_PsN_5_4_0.txt | 2 +- doc/psn_configuration.tex | 2 +- lib/PsN.pm | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/development/release_notes/release_notes_PsN_5_4_0.txt b/development/release_notes/release_notes_PsN_5_4_0.txt index ad289e85..d84d11b9 100644 --- a/development/release_notes/release_notes_PsN_5_4_0.txt +++ b/development/release_notes/release_notes_PsN_5_4_0.txt @@ -6,7 +6,7 @@ Changes and bug fixes from PsN 5.3.1 to 5.4.0 ___General___ * Using File::Copy::copy instead of File::Copy::cp everywhere. This will use the default file permissions for the destination file. - +* The environment variable PSNCONFPATH can be used to set a preferred path where to find psn.conf ___common_options___ diff --git a/doc/psn_configuration.tex b/doc/psn_configuration.tex index a44138e0..0d613c95 100644 --- a/doc/psn_configuration.tex +++ b/doc/psn_configuration.tex @@ -23,7 +23,7 @@ \section{psn.conf overview} In psn.conf it is also possible to specify personal default values, see more information below. Comment lines in psn.conf start with a semicolon (;). Throughout the default psn.conf distributed with PsN there are examples of settings for UNIX and Windows. The user can review the settings, add and remove semicolons, and change selected paths. \subsection{Location of psn.conf} -PsN will look for psn.conf at two different places. Primarily (depending on operative system) in the user's home directory (UNIX) or on the user's desktop (Windows) and then in the PsN installation directory. If psn.conf is found in the home directory (UNIX) or on the user's desktop (Windows) the settings in this psn.conf will override the settings in the system-wide (PsN installation directory) present psn.conf, which is important to remember when trying to sort out a psn.conf-related problem. +PsN will look for psn.conf at two different places. Primarily (depending on operative system) in the user's home directory (UNIX) or on the user's desktop (Windows) and then in the PsN installation directory. If psn.conf is found in the home directory (UNIX) or on the user's desktop (Windows) the settings in this psn.conf will override the settings in the system-wide (PsN installation directory) present psn.conf, which is important to remember when trying to sort out a psn.conf-related problem. It is also possible to set the path to psn.conf by using the \verb|PSNCONFPATH| environment variable. \subsection{Sections in psn.conf} The organizing of settings in psn.conf is important. They must be set in the correct section.\\ diff --git a/lib/PsN.pm b/lib/PsN.pm index 823e6b8c..588eb0a2 100644 --- a/lib/PsN.pm +++ b/lib/PsN.pm @@ -20,8 +20,6 @@ $lib_dir = Cwd::abs_path($volume . $directory); $Rscripts_dir = get_Rscripts_dir($lib_dir); -$config_file = $lib_dir . '/psn.conf'; - use File::HomeDir; use ext::Config::Tiny; @@ -39,8 +37,16 @@ our @nm7_extensions = ('.ext','.cov','.cor','.coi','.phi','.phm', '.shk','.grd', '.imp','.npd','.npe','.npi','.fgh','.log.xml','.cpu','.shm','.agh', '.vpd','.clt','.npl', '.ets'); #nm74 -if( -e home() . "/psn.conf" ){ - $config_file = home() . "/psn.conf"; +my $envconfig = $ENV{PSNCONFPATH}; + +if (defined $envconfig and -e "$envconfig/psn.conf") { + $config_file = "$envconfig/psn.conf"; +} elsif (-e File::HomeDir::my_home . "/psn.conf") { + $config_file = File::HomeDir::my_home . "/psn.conf"; +} elsif (-e File::HomeDir::my_desktop . "/psn.conf") { + $config_file = File::HomeDir::my_desktop . "/psn.conf"; +} else { + $config_file = $lib_dir . '/psn.conf'; } sub get_Rscripts_dir{