diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 918ac0f87e..0c29d1af75 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -27,6 +27,7 @@ Release with new features and bugfixes: * https://github.com/devonfw/IDEasy/issues/2114[#2114]: Fix false "Cygwin is not supported" warning in Git Bash * https://github.com/devonfw/IDEasy/issues/865[#865]: az not working on Mac * https://github.com/devonfw/IDEasy/issues/2026[#2026]: Create UvRepository and UvBasedCommandlet +* https://github.com/devonfw/IDEasy/issues/2007[#2007]: Support Docker on Arch Linux with pacman and yay The full list of changes for this release can be found in https://github.com/devonfw/IDEasy/milestone/46?closed=1[milestone 2026.07.001]. diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/NativePackageManager.java b/cli/src/main/java/com/devonfw/tools/ide/tool/NativePackageManager.java index 51cc195e9b..19aae19e09 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/NativePackageManager.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/NativePackageManager.java @@ -14,7 +14,10 @@ public enum NativePackageManager { YUM, /** DaNdiFied yum (DNF) is the package manager of RPM package based Linux distributions like Fedora. It is the successor of {@link #YUM}. */ - DNF; + DNF, + + /** Pacman is the package manager of Arch Linux based distributions. */ + PACMAN; /** * Extracts the package manager from the provided command string. @@ -37,6 +40,9 @@ public static NativePackageManager extractPackageManager(String command) { if (command.contains("dnf")) { return DNF; } + if (command.contains("pacman")) { + return PACMAN; + } throw new IllegalArgumentException("Unknown package manager in command: " + command); } diff --git a/cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java b/cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java index 4533c2fe99..4bee8c719d 100644 --- a/cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java +++ b/cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java @@ -93,7 +93,8 @@ protected List getInstallPackageManagerCommands() { "echo 'deb [signed-by=/usr/share/keyrings/isv-rancher-stable-archive-keyring.gpg]" + " https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/ ./' |" + " sudo dd status=none of=/etc/apt/sources.list.d/isv-rancher-stable.list", "sudo apt update", - String.format("sudo apt install -y --allow-downgrades rancher-desktop=%s*", resolvedVersion)))); + String.format("sudo apt install -y --allow-downgrades rancher-desktop=%s*", resolvedVersion))), + new PackageManagerCommand(NativePackageManager.PACMAN, List.of("yay -S --needed --noconfirm rancher-desktop"))); } @Override @@ -132,6 +133,9 @@ private VersionIdentifier getDockerDesktopVersionWindows() { private VersionIdentifier getDockerDesktopVersionLinux() { + if (!isCommandAvailable("apt")) { + return null; + } String dockerDesktopVersionLinuxCommand = "apt list --installed | grep docker-desktop | awk '{print $2}'"; String output = this.context.newProcess().runAndGetSingleOutput("bash", "-lc", dockerDesktopVersionLinuxCommand); return super.resolveVersionWithPattern(output, DOCKER_DESKTOP_LINUX_VERSION_PATTERN); @@ -175,6 +179,8 @@ private List getPackageManagerCommandsUninstall() { new PackageManagerCommand(NativePackageManager.ZYPPER, List.of("sudo zypper remove rancher-desktop"))); pmCommands.add( new PackageManagerCommand(NativePackageManager.APT, List.of("sudo apt -y autoremove rancher-desktop"))); + pmCommands.add( + new PackageManagerCommand(NativePackageManager.PACMAN, List.of("sudo pacman -Rs --noconfirm rancher-desktop"))); return pmCommands; } diff --git a/cli/src/test/java/com/devonfw/tools/ide/tool/NativePackageManagerTest.java b/cli/src/test/java/com/devonfw/tools/ide/tool/NativePackageManagerTest.java new file mode 100644 index 0000000000..65f01203ae --- /dev/null +++ b/cli/src/test/java/com/devonfw/tools/ide/tool/NativePackageManagerTest.java @@ -0,0 +1,42 @@ +package com.devonfw.tools.ide.tool; + +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.Test; + +/** + * Test of {@link NativePackageManager}. + */ +class NativePackageManagerTest extends Assertions { + + /** + * Test of {@link NativePackageManager#extractPackageManager(String)} for every supported package manager. + */ + @Test + void testExtractPackageManager() { + + assertThat(NativePackageManager.extractPackageManager("sudo apt install -y rancher-desktop")).isEqualTo(NativePackageManager.APT); + assertThat(NativePackageManager.extractPackageManager("yum install rancher-desktop")).isEqualTo(NativePackageManager.YUM); + assertThat(NativePackageManager.extractPackageManager("sudo zypper install rancher-desktop")).isEqualTo(NativePackageManager.ZYPPER); + assertThat(NativePackageManager.extractPackageManager("dnf install rancher-desktop")).isEqualTo(NativePackageManager.DNF); + assertThat(NativePackageManager.extractPackageManager("sudo pacman -Rs --noconfirm rancher-desktop")).isEqualTo(NativePackageManager.PACMAN); + } + + /** + * Test of {@link NativePackageManager#extractPackageManager(String)} for a command without a recognized package manager. + */ + @Test + void testExtractPackageManagerThrowsForUnknownCommand() { + + assertThatThrownBy(() -> NativePackageManager.extractPackageManager("brew install rancher-desktop")).isInstanceOf(IllegalArgumentException.class); + } + + /** + * Test of {@link NativePackageManager#getBinaryName()}. + */ + @Test + void testGetBinaryName() { + + assertThat(NativePackageManager.APT.getBinaryName()).isEqualTo("apt"); + assertThat(NativePackageManager.PACMAN.getBinaryName()).isEqualTo("pacman"); + } +}