diff options
Diffstat (limited to 'community/kdesrc-build/0001-Adhere-to-XDG-Base-Directory-specification.patch')
-rw-r--r-- | community/kdesrc-build/0001-Adhere-to-XDG-Base-Directory-specification.patch | 417 |
1 files changed, 0 insertions, 417 deletions
diff --git a/community/kdesrc-build/0001-Adhere-to-XDG-Base-Directory-specification.patch b/community/kdesrc-build/0001-Adhere-to-XDG-Base-Directory-specification.patch deleted file mode 100644 index 0398fc4d8e7..00000000000 --- a/community/kdesrc-build/0001-Adhere-to-XDG-Base-Directory-specification.patch +++ /dev/null @@ -1,417 +0,0 @@ -From bc391ece1ee8f7eecabb69e68053049e700fef05 Mon Sep 17 00:00:00 2001 -From: Ignacy Kajdan <ignacy.kajdan@gmail.com> -Date: Mon, 20 Dec 2021 14:57:26 +0100 -Subject: [PATCH] Adhere to XDG Base Directory specification - ---- - kdesrc-build | 16 ++++++--- - kdesrc-build-setup | 55 ++++++++++++++++------------- - kdesrc-run | 10 ++++-- - modules/ksb/Application.pm | 20 +++++++++-- - modules/ksb/BuildContext.pm | 69 +++++++++++++++++++++++++++---------- - modules/ksb/FirstRun.pm | 16 ++++++--- - modules/ksb/Module.pm | 4 +-- - 7 files changed, 131 insertions(+), 59 deletions(-) - -diff --git a/kdesrc-build b/kdesrc-build -index f6978fa..d95d75a 100755 ---- a/kdesrc-build -+++ b/kdesrc-build -@@ -1,8 +1,9 @@ - #!/usr/bin/env perl - --# Script to handle building KDE from source code. All of the configuration is --# stored in the file ./kdesrc-buildrc (or ~/.kdesrc-buildrc, if that's not --# present). -+# Script to handle building KDE from source code. All of the configuration is -+# stored in the file ./kdesrc-buildrc. If that file does not exist, -+# ~/.config/kdesrc-buildrc ($XDG_CONFIG_HOME/kdesrc-buildrc, if $XDG_CONFIG_HOME -+# environment variable is set) will be used. - # - # Please also see the documentation that should be included with this program, - # in the doc/ directory. -@@ -123,7 +124,14 @@ Couldn't load the base platform for kdesrc-build! - $@ - DONE - -- if (! -e "kdesrc-buildrc" && ! -e "$ENV{HOME}/.kdesrc-buildrc") { -+ # 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"; -+ my @possibleConfigPaths = ("./kdesrc-buildrc", -+ "$xdgConfigHome/kdesrc-buildrc", -+ "$ENV{HOME}/.kdesrc-buildrc"); -+ if (!grep { -e $_ } (@possibleConfigPaths)) { -+ - say STDERR <<~DONE; - It appears you've not run kdesrc-build before. - -diff --git a/kdesrc-build-setup b/kdesrc-build-setup -index 996e1dd..0f704b7 100755 ---- a/kdesrc-build-setup -+++ b/kdesrc-build-setup -@@ -300,13 +300,17 @@ my @chosenModules = getListOptions( - }, - ); - --my $outputFileName = "$ENV{HOME}/.kdesrc-buildrc"; -+# 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"; -+my $xdgConfigHomeShort = $xdgConfigHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+my $outputFile = "$xdgConfigHome/kdesrc-buildrc"; -+my $outputFileShort = $outputFile =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ - my $output; # Will be output filehandle. - --while (-e $outputFileName) { -- (my $printableName = $outputFileName) =~ s/^$ENV{HOME}/~/; -+while (-e $outputFile) { - my $outputChoice = getMenuOption( -- "$printableName already exists, what do you want to do?", -+ "$outputFileShort already exists, what do you want to do?", - [ - backup => 'Make a backup, then overwrite with the new configuration', - custom => 'Write the new configuration to a different file', -@@ -320,20 +324,21 @@ while (-e $outputFileName) { - } - - if ($outputChoice eq 'custom') { -- $outputFileName = getUserInput('Enter desired configuration file name.'); -- $outputFileName =~ s/^~/$ENV{HOME}/; -+ $outputFile = getUserInput('Enter desired configuration file name.'); -+ $outputFile =~ s/^~/$ENV{HOME}/; -+ $outputFileShort = $outputFile =~ s/^$ENV{HOME}/~/r; - } - - if ($outputChoice eq 'backup') { -- -- copy($outputFileName, "$outputFileName~") or do { -+ copy($outputFile, "$outputFile~") or do { - my $error = "$!"; - showInfo(<<EOF); --Failed to make backup of $outputFileName, due to error $error. -+Failed to make backup of $outputFileShort, due to error $error. - Configuration will be written to a temporary file instead. - EOF - -- ($output, $outputFileName) = tempfile("kdesrc-buildrc-XXXX"); -+ ($output, $outputFile) = tempfile("kdesrc-buildrc-XXXX"); -+ $outputFileShort = $outputFile =~ s/^$ENV{HOME}/~/r; - }; - - last; -@@ -342,10 +347,10 @@ EOF - - # Filehandle could already be opened as a tempfile. - if (!$output) { -- open ($output, '>', $outputFileName) or do { -+ open ($output, '>', $outputFile) or do { - my $error = "$!"; - showInfo (<<EOF); --Unable to open output file $outputFileName for writing due to error $error. -+Unable to open output file $outputFileShort for writing due to error $error. - EOF - die "$!"; - } -@@ -473,9 +478,12 @@ EOF - # Assume we can refer to files present alongside kdesrc-build in the source - # directory - my $basedir = dirname(abs_path($0)); -+my $baseDirShort = $basedir =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+ - if (! -e "$basedir/kf5-frameworks-build-include") { - # Check if it's installed to a share/ prefix - $basedir = abs_path(dirname($0) . "/../share/kdesrc-build/"); -+ $baseDirShort = $basedir =~ s/^$ENV{HOME}/~/r; - - if (! -e "$basedir/kf5-frameworks-build-include") { - close $output; -@@ -549,8 +557,7 @@ EOF - - close($output); - --$outputFileName =~ s/^$ENV{HOME}/~/; --showInfo("Generated configuration has been written to $outputFileName"); -+showInfo("Generated configuration has been written to $outputFileShort"); - - if (!@chosenModules) { - showInfo(<<EOF); -@@ -564,19 +571,19 @@ EOF - - # Say same thing in text mode just in case. - system('clear'); --say "Generated configuration has been written to $outputFileName"; --say "Sample configuration files are available in $basedir/*-build-include"; -+say "Generated configuration has been written to $outputFileShort"; -+say "Sample configuration files are available in $baseDirShort"; - --if ($outputFileName ne '~/.kdesrc-buildrc') { -+if ($outputFile ne "$xdgConfigHome/kdesrc-buildrc") { - say <<EOF; - --Note that your configuration file in $outputFileName will --NOT BE USED unless you either: --1. Overwrite your ~/.kdesrc-buildrc with $outputFileName, or --2. Copy $outputFileName to be called 'kdesrc-buildrc' in some directory -- and ALWAYS run kdesrc-build from the directory, or --3. ALWAYS pass the "--rc-file $outputFileName" option to kdesrc-build when you -- run it. -+Do note, that your configuration file $outputFileShort will NOT BE USED, -+unless you will do one of the following: -+- Overwrite $xdgConfigHomeShort/kdesrc-buildrc with $outputFileShort -+- Copy $outputFileShort to some directory and rename it to "kdesrc-buildrc", -+ then ALWAYS run kdesrc-build from that directory -+- ALWAYS pass the "--rc-file $outputFileShort" option to kdesrc-build when -+ you run it - EOF - } - -diff --git a/kdesrc-run b/kdesrc-run -index b9cfcb9..1e5e651 100755 ---- a/kdesrc-run -+++ b/kdesrc-run -@@ -66,11 +66,15 @@ if ($#ARGV == -1 && not $optListInstalled) { - my $module = shift @ARGV; - my $exec = $optExec // $module; - --my $buildDataFile = first { -e $_ } --('./.kdesrc-build-data', "$ENV{HOME}/.kdesrc-build-data"); -+# 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); - - if (not defined $buildDataFile) { -- say qq(".kdesrc-build-data" file is not available. Exit now.); -+ say qq("$cacheFileName" file is not available. Exit now.); - exit 1; - } - -diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm -index 907e63f..d4b17b5 100644 ---- a/modules/ksb/Application.pm -+++ b/modules/ksb/Application.pm -@@ -2733,7 +2733,16 @@ sub performInitialUserSetup - # Shows a help message and version. Does not exit. - sub _showHelpMessage - { -+ # 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"; -+ my $xdgConfigHomeShort = $xdgConfigHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+ -+ my $pwd = $ENV{PWD}; -+ my $pwdShort = $pwd =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+ - my $scriptVersion = scriptVersion(); -+ - say <<DONE; - kdesrc-build $scriptVersion - Copyright (c) 2003 - 2020 Michael Pyne <mpyne\@kde.org> and others, and is -@@ -2742,7 +2751,8 @@ distributed under the terms of the GNU GPL v2. - This script automates the download, build, and install process for KDE software - using the latest available source code. - --Configuration is controlled from "\$PWD/kdesrc-buildrc" or "~/.kdesrc-buildrc". -+Configuration is controlled from "$pwdShort/kdesrc-buildrc" or -+"$xdgConfigHomeShort/kdesrc-build/kdesrc-buildrc". - See kdesrc-buildrc-sample for an example. - - Usage: \$ $0 [--options] [module names] -@@ -2779,8 +2789,12 @@ More docs at https://docs.kde.org/?application=kdesrc-build - Supported cmdline options: https://docs.kde.org/trunk5/en/kdesrc-build/kdesrc-build/cmdline.html - DONE - -- # Look for indications this is the first run. -- if (! -e "./kdesrc-buildrc" && ! -e "$ENV{HOME}/.kdesrc-buildrc") { -+ # Look for indications that this is the first run -+ my @possibleConfigPaths = ("./kdesrc-buildrc", -+ "$xdgConfigHome/kdesrc-buildrc", -+ "$ENV{HOME}/.kdesrc-buildrc"); -+ -+ if (!grep { -e $_ } (@possibleConfigPaths)) { - say <<DONE; - ** ** ** ** ** - It looks like kdesrc-build has not yet been setup. For easy setup, run: -diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm -index aab5174..869baad 100644 ---- a/modules/ksb/BuildContext.pm -+++ b/modules/ksb/BuildContext.pm -@@ -35,13 +35,21 @@ 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_CONFIG_HOME is not set, then we should -+# default to ~/.config -+my $xdgConfigHome = $ENV{XDG_CONFIG_HOME} // "$ENV{HOME}/.config"; -+my $xdgConfigHomeShort = $xdgConfigHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+ - my @DefaultPhases = qw/update build install/; --my @rcfiles = ("./kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc"); -+my @rcfiles = ("./kdesrc-buildrc", -+ "$xdgConfigHome/kdesrc-buildrc", -+ "$ENV{HOME}/.kdesrc-buildrc"); - my $LOCKFILE_NAME = '.kdesrc-lock'; -- --# The # will be replaced by the directory the rc File is stored in. --my $PERSISTENT_FILE_NAME = '#/.kdesrc-build-data'; -- -+my $PERSISTENT_FILE_NAME = 'kdesrc-build-data'; - my $SCRIPT_VERSION = scriptVersion(); - - # Should be used for internal state that shouldn't be exposed as a hidden -@@ -576,6 +584,20 @@ sub loadRcFile - if (open ($fh, '<', "$file")) - { - $self->{rcFile} = File::Spec->rel2abs($file); -+ -+ # Check if the config file is stored in the old location -+ $file =~ s/^$ENV{HOME}/~/; -+ if ($file eq '~/.kdesrc-buildrc') -+ { -+ error (<<EOM); -+ -+Your b[global configuration file] is stored in the old location. It will still be -+processed correctly, however, it's recommended to move it to the new location. -+ -+Please, move b[~/.kdesrc-buildrc] to b[$xdgConfigHomeShort/kdesrc-buildrc] -+EOM -+ } -+ - return $fh; - } - } -@@ -610,11 +632,9 @@ b[No configuration file is present.] - kdesrc-build requires a configuration file to select which KDE software modules - to build, what options to build them with, the path to install to, etc. - --kdesrc-build looks for its configuration in the file `kdesrc-buildrc' in --whatever directory kdesrc-build is run from. -- --If no such file exists, kdesrc-build tries to use `~/.kdesrc-buildrc' (note the --leading `.') -+When run, kdesrc-build will use `kdesrc-buildrc' config file located in the -+current working directory. If no such file exists, kdesrc-build will use -+`$xdgConfigHomeShort/kdesrc-buildrc' instead. - - A sample configuration suitable for KDE 4 software is included at the file - `kdesrc-buildrc-sample' which can be copied to the correct location and then -@@ -764,18 +784,31 @@ sub setOption - # - - # Returns the name of the file to use for persistent data. --# Supports expanding '#' at the beginning of the filename to the directory --# containing the rc-file in use, but only for the default name at this --# point. - sub persistentOptionFileName - { - my $self = shift; - my $filename = $self->getOption('persistent-data-file'); - - if (!$filename) { -- $filename = $PERSISTENT_FILE_NAME; -- my $dir = $self->baseConfigDirectory(); -- $filename =~ s/^#/$dir/; -+ # Check if the cache file is stored in the old location -+ if (-e "$ENV{HOME}/.kdesrc-build-data") -+ { -+ error (<<EOM); -+Your b[global cache file] is stored in the old location. It will still be -+processed correctly, however, it's recommended to move it to the new location. -+ -+Please, move b[~/.kdesrc-build-data] to b[$xdgCacheHomeShort/kdesrc-build-data] -+EOM -+ } -+ -+ my $configDir = $self->baseConfigDirectory(); -+ if ($configDir eq $xdgConfigHome) { -+ # Global config is used - store the cache file in $xdgCacheHome -+ $filename = $xdgCacheHome . '/' . $PERSISTENT_FILE_NAME; -+ } else { -+ # Local config is used - store the cache file in the same directory -+ $filename = $configDir . '/.' . $PERSISTENT_FILE_NAME; -+ } - } - else { - # Tilde-expand -@@ -786,7 +819,7 @@ sub persistentOptionFileName - } - - # Reads in all persistent options from the file where they are kept --# (.kdesrc-build-data) for use in the program. -+# (kdesrc-build-data) for use in the program. - # - # The directory used is the same directory that contains the rc file in use. - sub loadPersistentOptions -@@ -838,7 +871,7 @@ sub loadPersistentOptions - $self->{persistent_options} = $persistent_options; - } - --# Writes out the persistent options to the file .kdesrc-build-data. -+# Writes out persistent options to the kdesrc-build-data file. - # - # The directory used is the same directory that contains the rc file in use. - sub storePersistentOptions -diff --git a/modules/ksb/FirstRun.pm b/modules/ksb/FirstRun.pm -index b4750c4..6b5f696 100644 ---- a/modules/ksb/FirstRun.pm -+++ b/modules/ksb/FirstRun.pm -@@ -194,7 +194,13 @@ sub _getNumCoresForLowMemory - sub _setupBaseConfiguration - { - my $baseDir = shift; -- my @knownLocations = ("$ENV{PWD}/kdesrc-buildrc", "$ENV{HOME}/.kdesrc-buildrc"); -+ # 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"; -+ my $xdgConfigHomeShort = $xdgConfigHome =~ s/^$ENV{HOME}/~/r; # Replace $HOME with ~ -+ my @knownLocations = ("$ENV{PWD}/kdesrc-buildrc", -+ "$xdgConfigHome/kdesrc-buildrc", -+ "$ENV{HOME}/.kdesrc-buildrc"); - my $locatedFile = first { -e $_ } @knownLocations; - my $printableLocatedFile = undef; - -@@ -228,14 +234,14 @@ DONE - $sampleRc =~ s/%\{num_cores_low}/$numCoresLow/g; - $sampleRc =~ s/%\{base_dir}/$baseDir/g; - -- open my $sampleFh, '>', "$ENV{HOME}/.kdesrc-buildrc" -- or _throw("Couldn't open new ~/.kdesrc-buildrc: $!"); -+ open my $sampleFh, '>', "$xdgConfigHome/kdesrc-buildrc" -+ or _throw("Couldn't open new $xdgConfigHomeShort/kdesrc-buildrc: $!"); - - print $sampleFh $sampleRc -- or _throw("Couldn't write to ~/.kdesrc-buildrc: $!"); -+ or _throw("Couldn't write to $xdgConfigHomeShort/kdesrc-buildrc: $!"); - - close $sampleFh -- or _throw("Error closing ~/.kdesrc-buildrc: $!"); -+ or _throw("Error closing $xdgConfigHomeShort/kdesrc-buildrc: $!"); - } - - sub _setupShellRcFile -diff --git a/modules/ksb/Module.pm b/modules/ksb/Module.pm -index 993d85f..d098b74 100644 ---- a/modules/ksb/Module.pm -+++ b/modules/ksb/Module.pm -@@ -981,9 +981,9 @@ sub destDir - # avoid spamming - if (!$self->getOption('#warned-deprecated-ignore-kde-structure')) { - if($oldlayout eq 'true' || $oldlayout == 1) { -- warning("the option b[ignore-kde-structure true] is deprecated. Please substitute the option b[directory-layout flat] in your ~/.kdesrc-buildrc file."); -+ warning("The option b[ignore-kde-structure true] is deprecated. Please replace it with b[directory-layout flat] in your configuration file."); - } else { -- warning("The option b[ignore-kde-structure false] is deprecated. Please substitute the option b[directory-layout invent] in your ~/.kdesrc-buildrc file."); -+ warning("The option b[ignore-kde-structure false] is deprecated. Please replace it with b[directory-layout invent] in your configuration file."); - } - } - # no or equivalent layout configured, assume the user wants to use flat layout --- -GitLab - |