From 30b9a6ac1250d5c97fb90b1518860c6bbc1c5006 Mon Sep 17 00:00:00 2001 From: leonrohne27 Date: Wed, 30 Oct 2024 11:25:21 +0100 Subject: [PATCH 1/4] #415: Added log info before sudo pw request Added a method that will inform the user for what process he will need to enter his root-password --- .../tools/ide/tool/GlobalToolCommandlet.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java index 961846709..3c0d23d70 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java @@ -55,6 +55,8 @@ protected boolean runWithPackageManager(boolean silent, String... commandStrings */ protected boolean runWithPackageManager(boolean silent, List pmCommands) { + logPackageManagerCommands(pmCommands); + for (PackageManagerCommand pmCommand : pmCommands) { PackageManager packageManager = pmCommand.packageManager(); Path packageManagerPath = this.context.getPath().findBinary(Path.of(packageManager.getBinaryName())); @@ -70,6 +72,19 @@ protected boolean runWithPackageManager(boolean silent, List pmCommands) { + StringBuilder commandLog = new StringBuilder("We need to run the following privileged command(s):\n"); + + for (PackageManagerCommand pmCommand : pmCommands) { + for (String command : pmCommand.commands()) { + commandLog.append(command).append("\n"); + } + } + commandLog.append("This will require root permissions!"); + + this.context.info(commandLog.toString()); + } + /** * Executes the provided package manager command. * From b80a029aac88343e0216c089324b23f860f4b5d1 Mon Sep 17 00:00:00 2001 From: leonrohne27 Date: Wed, 30 Oct 2024 12:12:52 +0100 Subject: [PATCH 2/4] #415: Added changelog entry --- CHANGELOG.adoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 214b24775..c8e6af73a 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -6,6 +6,7 @@ This file documents all notable changes to https://github.com/devonfw/IDEasy[IDE Release with new features and bugfixes: +* https://github.com/devonfw/IDEasy/issues/415[#415]: Added a message that will inform the user for what process he will need to enter his sudo- password The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/15?closed=1[milestone 2024.11.001]. From b2332102a0e754c855703493c3da9f050e6d19b5 Mon Sep 17 00:00:00 2001 From: leonrohne27 Date: Thu, 31 Oct 2024 16:36:41 +0100 Subject: [PATCH 3/4] #415: Changed logPackageManagerCommands Changed logPackageManagerCommands so that it only prints out the output for the single PackageManagerCommand that will be executed --- .../tools/ide/tool/GlobalToolCommandlet.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java index 3c0d23d70..9f0d5860f 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java @@ -54,9 +54,7 @@ protected boolean runWithPackageManager(boolean silent, String... commandStrings * @return {@code true} if installation or uninstallation succeeds with any of the package manager commands, {@code false} otherwise. */ protected boolean runWithPackageManager(boolean silent, List pmCommands) { - - logPackageManagerCommands(pmCommands); - + for (PackageManagerCommand pmCommand : pmCommands) { PackageManager packageManager = pmCommand.packageManager(); Path packageManagerPath = this.context.getPath().findBinary(Path.of(packageManager.getBinaryName())); @@ -72,17 +70,13 @@ protected boolean runWithPackageManager(boolean silent, List pmCommands) { - StringBuilder commandLog = new StringBuilder("We need to run the following privileged command(s):\n"); + private void logPackageManagerCommands(PackageManagerCommand pmCommand) { - for (PackageManagerCommand pmCommand : pmCommands) { - for (String command : pmCommand.commands()) { - commandLog.append(command).append("\n"); - } + this.context.info("We need to run the following privileged command(s):"); + for (String command : pmCommand.commands()) { + this.context.info(command); } - commandLog.append("This will require root permissions!"); - - this.context.info(commandLog.toString()); + this.context.info("This will require root permissions!"); } /** @@ -95,6 +89,7 @@ private void logPackageManagerCommands(List pmCommands) { private boolean executePackageManagerCommand(PackageManagerCommand pmCommand, boolean silent) { String bashPath = this.context.findBashRequired(); + logPackageManagerCommands(pmCommand); for (String command : pmCommand.commands()) { ProcessContext pc = this.context.newProcess().errorHandling(ProcessErrorHandling.LOG_WARNING).executable(bashPath) .addArgs("-c", command); From 26b2501b5f999516f18bed07d9640730cb87addb Mon Sep 17 00:00:00 2001 From: leonrohne27 Date: Mon, 4 Nov 2024 10:08:46 +0100 Subject: [PATCH 4/4] #415: Changed loglevel from INFO to INTERACTION and removed whitespace --- .../com/devonfw/tools/ide/tool/GlobalToolCommandlet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java index 9f0d5860f..9a5bb6d92 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java @@ -54,7 +54,7 @@ protected boolean runWithPackageManager(boolean silent, String... commandStrings * @return {@code true} if installation or uninstallation succeeds with any of the package manager commands, {@code false} otherwise. */ protected boolean runWithPackageManager(boolean silent, List pmCommands) { - + for (PackageManagerCommand pmCommand : pmCommands) { PackageManager packageManager = pmCommand.packageManager(); Path packageManagerPath = this.context.getPath().findBinary(Path.of(packageManager.getBinaryName())); @@ -72,11 +72,11 @@ protected boolean runWithPackageManager(boolean silent, List