Git commit 4a2c0a8fe776490fde92bec120bfae51d9e9c982 by Ignacy Kajdan. Committed on 21/01/2022 at 17:40. Pushed by mpyne into branch 'master'.
Use XDG_STATE_HOME for persistent data file M +3 -3 doc/index.docbook M +3 -3 doc/man-kdesrc-build.1.docbook M +7 -7 kdesrc-run M +8 -8 modules/ksb/BuildContext.pm https://invent.kde.org/sdk/kdesrc-build/commit/4a2c0a8fe776490fde92bec120bfae51d9e9c982 diff --git a/doc/index.docbook b/doc/index.docbook index 5c223cd..19ad36a 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -2795,9 +2795,9 @@ cannot figure out what you mean using <link linkend="conf-branch">branch</link>. persistent data. The default is to store this data in a file called <filename>.kdesrc-build-data</filename>, placed in the same directory as the configuration file in use. If the global configuration file is in use, it will -be saved to <filename>~/.cache/kdesrc-build-data</filename> -(<filename>$XDG_CONFIG_HOME/kdesrc-build-data</filename>, if -<envar>$XDG_CONFIG_HOME</envar> is set). If you have multiple available +be saved to <filename>~/.local/state/kdesrc-build-data</filename> +(<filename>$XDG_STATE_HOME/kdesrc-build-data</filename>, if +<envar>$XDG_STATE_HOME</envar> is set). If you have multiple available configurations in the same directory, you may want to manually set this option, so that different configurations do not end up with conflicting persistent data. </para> diff --git a/doc/man-kdesrc-build.1.docbook b/doc/man-kdesrc-build.1.docbook index 7d105cf..c33327f 100644 --- a/doc/man-kdesrc-build.1.docbook +++ b/doc/man-kdesrc-build.1.docbook @@ -1171,9 +1171,9 @@ directory</emphasis> when kdesrc-build is run, this file will be used for the configuration instead of <filename>~/.config/kdesrc-buildrc</filename>. </para> -<para><filename>~/.cache/kdesrc-build-data</filename> -(<filename>$XDG_CACHE_HOME/kdesrc-buildrc</filename>, if -<envar>$XDG_CACHE_HOME</envar> is set) - <command>kdesrc-build</command> uses +<para><filename>~/.local/state/kdesrc-build-data</filename> +(<filename>$XDG_STATE_DIR/kdesrc-buildrc</filename>, if +<envar>$XDG_STATE_DIR</envar> is set) - <command>kdesrc-build</command> uses this file to store persistent data (such as last CMake options used, last revision successfully installed, etc.). It can be safely deleted. </para> diff --git a/kdesrc-run b/kdesrc-run index 1e5e651..b27d82a 100755 --- a/kdesrc-run +++ b/kdesrc-run @@ -66,15 +66,15 @@ if ($#ARGV == -1 && not $optListInstalled) { my $module = shift @ARGV; my $exec = $optExec // $module; -# According to XDG spec, if $XDG_CACHE_HOME is not set, then we should default -# to ~/.cache -my $xdgCacheHome = $ENV{XDG_CACHE_HOME} // "$ENV{HOME}/.cache"; -my $cacheFileName = "kdesrc-build-data"; -my @possibleCachePaths = ("./.$cacheFileName", "$xdgCacheHome/$cacheFileName"); -my $buildDataFile = first { -e $_ } (@possibleCachePaths); +# According to XDG spec, if $XDG_STATE_HOME is not set, then we should default +# to ~/.local/state +my $xdgStateHome = $ENV{XDG_STATE_HOME} // "$ENV{HOME}/.local/state"; +my $dataFileName = "kdesrc-build-data"; +my @possibleDataPaths = ("./.$dataFileName", "$xdgStateHome/$dataFileName"); +my $buildDataFile = first { -e $_ } (@possibleDataPaths); if (not defined $buildDataFile) { - say qq("$cacheFileName" file is not available. Exit now.); + say qq("$dataFileName" file is not available. Exit now.); exit 1; } diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm index ba2e158..1f4ec09 100644 --- a/modules/ksb/BuildContext.pm +++ b/modules/ksb/BuildContext.pm @@ -35,10 +35,10 @@ use ksb::KDEProjectsReader 0.50; use File::Temp qw(tempfile); use File::Spec; # rel2abs -# According to XDG spec, if $XDG_CACHE_HOME is not set, then we should -# default to ~/.cache -my $xdgCacheHome = $ENV{XDG_CACHE_HOME} // "$ENV{HOME}/.cache"; -my $xdgCacheHomeShort = $xdgCacheHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ +# According to XDG spec, if $XDG_STATE_HOME is not set, then we should +# default to ~/.local/state +my $xdgStateHome = $ENV{XDG_STATE_HOME} // "$ENV{HOME}/.local/state"; +my $xdgStateHomeShort = $xdgStateHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ # According to XDG spec, if $XDG_CONFIG_HOME is not set, then we should # default to ~/.config my $xdgConfigHome = $ENV{XDG_CONFIG_HOME} // "$ENV{HOME}/.config"; @@ -581,7 +581,7 @@ processed correctly, however, it's recommended to move it to the new location. Please move b[~/.kdesrc-buildrc] to b[$xdgConfigHomeShort/kdesrc-buildrc] You may also move (or delete) the b[global cache file], as it won't be read from -the current location: b[~/.kdesrc-build-data] to b[$xdgCacheHomeShort/kdesrc-build-data] +the current location: b[~/.kdesrc-build-data] to b[$xdgStateHomeShort/kdesrc-build-data] (overwrite if needed). EOM } @@ -804,10 +804,10 @@ sub persistentOptionFileName } else { my $configDir = $self->baseConfigDirectory(); if ($configDir eq $xdgConfigHome) { - # Global config is used - store the cache file in $xdgCacheHome - $file = $xdgCacheHome . '/' . $PERSISTENT_FILE_NAME; + # Global config is used - store the data file in $xdgStateHome + $file = $xdgStateHome . '/' . $PERSISTENT_FILE_NAME; } else { - # Local config is used - store the cache file in the same directory + # Local config is used - store the data file in the same directory $file = $configDir . '/.' . $PERSISTENT_FILE_NAME; } }
