[sdk/kdesrc-build] /: Remove update-shellrc step

Andrew Shark null at kde.org
Thu Feb 15 11:45:10 GMT 2024


Git commit 5d7dcacee6fd89feae01f197e278f61a1ddead8b by Andrew Shark.
Committed on 15/02/2024 at 11:44.
Pushed by ashark into branch 'master'.

Remove update-shellrc step

It basically just added to the shellrc the path to the running script. That is not handled correctly in all cases.

Also, it tried to add kdesrc-run bash autocompletion, but the code was not handling all cases correctly anyway.

Instead, we will offer to install the file in the correct place in the first place.
Regarding PATH, that should be in user's control.

M  +1    -1    README.md
M  +0    -1    completions/zsh/_kdesrc-build
M  +1    -13   doc/man-kdesrc-build.1.docbook
M  +1    -12   doc/supported-cmdline-params.docbook
M  +0    -4    kdesrc-build
M  +3    -4    modules/ksb/Cmdline.pm
M  +0    -78   modules/ksb/FirstRun.pm
M  +0    -1    scripts/gen_zsh_completions.py

https://invent.kde.org/sdk/kdesrc-build/-/commit/5d7dcacee6fd89feae01f197e278f61a1ddead8b

diff --git a/README.md b/README.md
index c4aaa3fb..c95e6d8b 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ $ kdesrc-build --initial-setup
 ```
 
 This will install the distribution packages dependencies required by `kdesrc-build`,
-generate a configuration file, and add itself to your path for convenience.
+generate a configuration file.
 
 ### Download the KDE project and dependency data:
 
diff --git a/completions/zsh/_kdesrc-build b/completions/zsh/_kdesrc-build
index 8dccee6f..ce83af68 100644
--- a/completions/zsh/_kdesrc-build
+++ b/completions/zsh/_kdesrc-build
@@ -78,7 +78,6 @@ _arguments \
   "(--stop-on-failure --no-stop-on-failure)"{--stop-on-failure,--no-stop-on-failure}"[Stops/Does not stop the build as soon as a package fails to build]" \
   "--tag""[Download a specific release of a module]"":argument:" \
   "--uninstall""[Uninstalls the module]" \
-  "--update-shellrc""[Installs Plasma env vars (~/.bashrc)]" \
   "(--use-clean-install --no-use-clean-install)"{--use-clean-install,--no-use-clean-install}"[Run make uninstall directly before running make install]" \
   "(--use-idle-io-priority --no-use-idle-io-priority)"{--use-idle-io-priority,--no-use-idle-io-priority} \
   "(--use-inactive-modules --no-use-inactive-modules)"{--use-inactive-modules,--no-use-inactive-modules}"[Allow kdesrc-build to also clone and pull from repositories marked as inactive]" \
diff --git a/doc/man-kdesrc-build.1.docbook b/doc/man-kdesrc-build.1.docbook
index 352da7ff..f97209c9 100644
--- a/doc/man-kdesrc-build.1.docbook
+++ b/doc/man-kdesrc-build.1.docbook
@@ -130,7 +130,7 @@ combining short options into one at this point. (E.g. running
     default configuration file setup, and changes to your ~/.bashrc to make the
     software installed by &kdesrc-build; accessible.
 
-    This is exactly equivalent to using "--install-distro-packages --generate-config --update-shellrc" at the same time.
+    This is exactly equivalent to using "--install-distro-packages --generate-config" at the same time.
 </para>
 </listitem>
 </varlistentry>
@@ -160,18 +160,6 @@ Generate the &kdesrc-build; configuration file.
 </listitem>
 </varlistentry>
 
-<varlistentry>
-<term>
-<option>--update-shellrc</option>
-</term>
-
-<listitem>
-<para>
-Edit the "~/.bashrc" (or other shell rc file) to add &kdesrc-build; to your $PATH variable and enable autocompletion.
-</para>
-</listitem>
-</varlistentry>
-
 <varlistentry>
 <term>
 <option>-p, --pretend</option>
diff --git a/doc/supported-cmdline-params.docbook b/doc/supported-cmdline-params.docbook
index c3202192..a6d1a9aa 100644
--- a/doc/supported-cmdline-params.docbook
+++ b/doc/supported-cmdline-params.docbook
@@ -564,12 +564,11 @@ software to run.
 <itemizedlist>
 <listitem><para>Installing known dependencies (on supported &Linux; distributions)</para></listitem>
 <listitem><para>Adding required environment variables to <literal>~/.bashrc</literal></para></listitem>
-<listitem><para>Setting up a <link linkend="setup-rcfile">configuration file</link></para></listitem>
 </itemizedlist>
 <para>This option is exactly equivalent to using
     <option><link linkend="cmdline-install-distro-packages">--install-distro-packages</link></option>
     <option><link linkend="cmdline-generate-config">--generate-config</link></option>
-    <option><link linkend="cmdline-update-shellrc">--update-shellrc</link></option> at the same time.
+    at the same time.
 </para>
 </listitem>
 </varlistentry>
@@ -593,16 +592,6 @@ Generate the &kdesrc-build; configuration file.
 </listitem>
 </varlistentry>
 
-<varlistentry id="cmdline-update-shellrc">
-<term><option><link linkend="cmdline-update-shellrc">--update-shellrc</link></option></term>
-<listitem><para>
-Edit the "~/.bashrc" (or other shell rc file) to add &kdesrc-build; to your <envar>$PATH</envar> variable and enable autocompletion.
-</para>
-<para>See also <option><link linkend="cmdline-initial-setup">--initial-setup</link></option></para>
-</listitem>
-</varlistentry>
-
-
 </variablelist>
 </sect2>
 
diff --git a/kdesrc-build b/kdesrc-build
index 9caeb9cb..1db44550 100755
--- a/kdesrc-build
+++ b/kdesrc-build
@@ -91,7 +91,6 @@ eval {
     if (grep { $_ eq "--initial-setup" } @ARGV) {
         push @setup_steps, "install-distro-packages";
         push @setup_steps, "generate-config";
-        push @setup_steps, "update-shellrc";
     } else {
         if (grep {$_ eq "--install-distro-packages"} @ARGV) {
             push @setup_steps, "install-distro-packages";
@@ -99,9 +98,6 @@ eval {
         if (grep {$_ eq "--generate-config"} @ARGV) {
             push @setup_steps, "generate-config";
         }
-        if (grep {$_ eq "--update-shellrc"} @ARGV) {
-            push @setup_steps, "update-shellrc";
-        }
     }
 
     if (@setup_steps) {
diff --git a/modules/ksb/Cmdline.pm b/modules/ksb/Cmdline.pm
index 933a82fd..a7d6e51b 100644
--- a/modules/ksb/Cmdline.pm
+++ b/modules/ksb/Cmdline.pm
@@ -343,8 +343,7 @@ sub _showHelpAndExit
             --refresh-build        Start the build from scratch.
               (or -r)
             --rc-file=<filename>   Read configuration from filename instead of default.
-            --initial-setup        Installs Plasma env vars (~/.bashrc), required
-                                   system pkgs, and a base kdesrc-buildrc.
+            --initial-setup        Installs required system pkgs, and a base kdesrc-buildrc.
 
             --resume-from=<pkg>    Skips modules until just before or after the given
             --resume-after=<pkg>       package, then operates as normal.
@@ -371,7 +370,7 @@ sub _showHelpAndExit
             It looks like kdesrc-build has not yet been setup. For easy setup, run:
                 $0 --initial-setup
 
-            This will adjust your ~/.bashrc to find installed software, run your system's
+            This will run your system's
             package manager to install required dependencies, and setup a kdesrc-buildrc
             that can be edited from there.
             DONE
@@ -397,7 +396,7 @@ sub _showOptionsSpecifiersAndExit
     my @supportedOptions = _supportedOptions();
 
     # The initial setup options are handled outside of Cmdline (in the starting script).
-    my @initial_options = ("initial-setup", "install-distro-packages", "generate-config", "update-shellrc");
+    my @initial_options = ("initial-setup", "install-distro-packages", "generate-config");
 
     foreach my $option (@supportedOptions, @initial_options) {
         print "$option\n";
diff --git a/modules/ksb/FirstRun.pm b/modules/ksb/FirstRun.pm
index 6ea64db5..701bcf24 100644
--- a/modules/ksb/FirstRun.pm
+++ b/modules/ksb/FirstRun.pm
@@ -67,8 +67,6 @@ sub setupUserSystem
     $baseDir = shift;
     my @setup_steps = @_;
     my $os = ksb::OSSupport->new;
-    my $envShell = $ENV{'SHELL'} // 'undefined';
-    my $shellName = (split '/', $envShell)[-1];
 
     eval {
         if (grep { $_ eq "install-distro-packages" } @setup_steps) {
@@ -88,10 +86,6 @@ sub setupUserSystem
             }
             _setupBaseConfiguration();
         }
-        if (grep { $_ eq "update-shellrc" } @setup_steps) {
-            say colorize("=== update-shellrc ===");
-            _setupShellRcFile($shellName);
-        }
     };
 
     if (had_an_exception($@)) {
@@ -353,78 +347,6 @@ DONE
         or _throw("Error closing $xdgConfigHomeShort/kdesrc-buildrc: $!");
 }
 
-sub _setupShellRcFile
-{
-    my ($shellName) = @_;
-    my $rcFilepath = undef;
-    my $printableRcFilepath = undef;
-    my $extendedShell = 1;
-
-    if ($shellName eq 'bash') {
-        $rcFilepath = "$ENV{'HOME'}/.bashrc";
-    } elsif ($shellName eq 'zsh') {
-        if (defined $ENV{'ZDOTDIR'}) {
-            $rcFilepath = "$ENV{'ZDOTDIR'}/.zshrc";
-        } else {
-            $rcFilepath = "$ENV{'HOME'}/.zshrc";
-        }
-    } elsif ($shellName eq 'fish') {
-      if (defined($ENV{'XDG_CONFIG_HOME'})) {
-        $rcFilepath = "$ENV{'XDG_CONFIG_HOME'}/fish/conf.d/kdesrc-build.fish";
-      } else {
-        $rcFilepath = "$ENV{'HOME'}/.config/fish/conf.d/kdesrc-build.fish";
-      }
-    } else {
-        $rcFilepath = "$ENV{'HOME'}/.profile";
-        say colorize(" y[b[*] Couldn't detect the shell, using $rcFilepath.");
-        $extendedShell = 0;
-    }
-
-    $printableRcFilepath = $rcFilepath;
-    $printableRcFilepath =~ s/^$ENV{HOME}/~/;
-
-    open(my $file, '<', "$baseDir/data/kdesrc-run-completions.sh") or _throw("Cannot open file \"$baseDir/data/kdesrc-run-completions.sh\"");
-    my $kdesrc_run_completions = do { local $/; <$file> };
-    close($file);
-    # Used for bash/zsh and requires non-POSIX syntax support.
-    my $EXT_SHELL_RC_SNIPPET = $kdesrc_run_completions . SHELL_SEPARATOR_SNIPPET;
-    my $addToShell = yesNoPrompt(colorize(" b[*] Update your b[y[$printableRcFilepath]?"));
-
-    if ($addToShell) {
-        open(my $rcFh, '>>', $rcFilepath)
-            or _throw("Couldn't open $rcFilepath: $!");
-
-        say $rcFh '';
-
-        if ($shellName ne 'fish') {
-          say $rcFh BASE_SHELL_SNIPPET . "export PATH=\"$baseDir:\$PATH\"\n";
-
-          say $rcFh $EXT_SHELL_RC_SNIPPET
-              if $extendedShell;
-        } else {
-          say $rcFh BASE_SHELL_SNIPPET . "fish_add_path --global $baseDir\n";
-        }
-
-        close($rcFh)
-            or _throw("Couldn't save changes to $rcFilepath: $!");
-
-        say colorize(<<DONE);
-
-     - Added b[y[kdesrc-build] directory into PATH
-     - Added b[y[kdesrc-run] shell function
- b[*] b[g[Shell rc-file is successfully setup].
-DONE
-    } else {
-        say colorize(<<DONE);
-
- b[*] You can manually configure your shell rc-file with the snippet below:
-DONE
-        say BASE_SHELL_SNIPPET . "export PATH=\"$baseDir:\$PATH\"\n";
-        say $EXT_SHELL_RC_SNIPPET
-            if $extendedShell;
-    }
-}
-
 sub _findBestInstallCmd
 {
     my $os = shift;
diff --git a/scripts/gen_zsh_completions.py b/scripts/gen_zsh_completions.py
index 08adcce2..545a9d9f 100644
--- a/scripts/gen_zsh_completions.py
+++ b/scripts/gen_zsh_completions.py
@@ -186,7 +186,6 @@ short_descriptions = {  # contains one of the options (any of them) from set, an
     "--stop-on-failure": "Stops/Does not stop the build as soon as a package fails to build",
     "--tag": "Download a specific release of a module",
     "--uninstall": "Uninstalls the module",
-    "--update-shellrc": "Installs Plasma env vars (~/.bashrc)",
     "--use-clean-install": "Run make uninstall directly before running make install",
     "--use-idle-io-priority ": "Use lower priority for disk and other I/O",
     "--use-inactive-modules": "Allow kdesrc-build to also clone and pull from repositories marked as inactive",


More information about the kde-doc-english mailing list