#2345: Fix DOCKER_EDITION ignored on Linux - #2362
Conversation
…x' into 2345-docker-edition-ignored-Linux # Conflicts: # cli/src/main/java/com/devonfw/tools/ide/tool/docker/Docker.java
Coverage Report for CI Build 32823580782Warning Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes. Coverage decreased (-0.05%) to 73.426%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions138 previously-covered lines in 6 files lost coverage.
Coverage Stats💛 - Coveralls |
There was a problem hiding this comment.
The default native package installation is implemented in GlobalToolCommandlet#getInstallPackageManagerCommands. It retrieves the native packages defined by the tool and passes the resolved IDEasy version to each package installation:
IDEasy/cli/src/main/java/com/devonfw/tools/ide/tool/GlobalToolCommandlet.java
Lines 201 to 204 in f145266
This behavior works for packages that are installed from a package repository such as Rancher Desktop. The package name and resolved version can be combined to create a version specific package.
For APT, NativePackageManager#getPackageSpec creates this package specification by appending the resolved version and a wildcard to the package name:
For a regular repository package, this produces a valid package:
rancher-desktop=1.20.0*
Docker Desktop requires a different installation because it is distributed as a separate Debian package. Applying the default version logic to a downloaded local file would produce an invalid APT argument:
/tmp/docker-desktop-amd64.deb=4.34.0*
| } | ||
|
|
||
| ToolRepository toolRepository = this.context.getDefaultToolRepository(); | ||
| Path downloadedDeb = toolRepository.download(this.tool, EDITION_DOCKER, resolvedVersion, this); |
There was a problem hiding this comment.
getInstallPackageManagerCommands overrides the default installation only for the docker edition. The implementation uses the configured ToolRepository to download the Debian package matching the resolved Docker Desktop version
| + "sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", | ||
| "sudo apt update" | ||
| ), | ||
| List.of() |
There was a problem hiding this comment.
Using the path returned by ToolRepository ensures that installs the exact artifact resolved through the generated ide-urls metadata instead of downloading the latest unversioned Docker Desktop package.
| ), | ||
| List.of() | ||
| ); | ||
| return List.of(dockerDesktopInstallPackage.install(null)); |
There was a problem hiding this comment.
The package is installed with install(null), which is intentional. It prevents NativePackageManager#getPackageSpec from appending the resolved version to the local .deb path (e.g. /tmp/docker-desktop-amd64.deb instead of /tmp/docker-desktop-amd64.deb=4.34.0*).
| ) | ||
| ) | ||
| ); | ||
| } |
There was a problem hiding this comment.
The existing Rancher Desktop installation remains unchanged.
The regular NativePackage definition for the Docker edition is still required. This definition uses the installed package name docker-desktop, rather than the temporary download path. The package name is needed for package-related operations after installation, especially uninstallation. This allows to create the correct uninstall command:
sudo apt -y autoremove --purge docker-desktop
| @Override | ||
| protected List<NativePackage> getNativePackages() { | ||
|
|
||
| if (EDITION_DOCKER.equals(getConfiguredEdition())) { | ||
| return List.of( | ||
| new NativePackage( | ||
| NativePackageManager.APT, | ||
| List.of("docker-desktop"), | ||
| List.of("--allow-downgrades"), | ||
| List.of(), | ||
| List.of( | ||
| "sudo rm -f /etc/apt/sources.list.d/docker.list", | ||
| "sudo rm -f /etc/apt/keyrings/docker.asc" | ||
| ) | ||
| ) | ||
| ); | ||
| } |
There was a problem hiding this comment.
IMHO we should not download the package as part of getPackageManagerCommands(). It feels a bit unexpected to perform a side effect while merely resolving the package manager commands.
Instead, we could download the .deb earlier as part of the installation flow (for example by overriding doInstall()), store the downloaded path, and then pass that path through getNativePackages() just like we do for other native packages.
Something along these lines:
| @Override | |
| protected List<NativePackage> getNativePackages() { | |
| if (EDITION_DOCKER.equals(getConfiguredEdition())) { | |
| return List.of( | |
| new NativePackage( | |
| NativePackageManager.APT, | |
| List.of("docker-desktop"), | |
| List.of("--allow-downgrades"), | |
| List.of(), | |
| List.of( | |
| "sudo rm -f /etc/apt/sources.list.d/docker.list", | |
| "sudo rm -f /etc/apt/keyrings/docker.asc" | |
| ) | |
| ) | |
| ); | |
| } | |
| private Path downloadedDebPackageForDocker; | |
| @Override | |
| protected ToolInstallation doInstall(ToolInstallRequest request) { | |
| if (EDITION_DOCKER.equals(getConfiguredEdition())) { | |
| downloadDebPackageStepAndSetPackagePath(request.getRequested().getResolvedVersion()); | |
| } | |
| return super.doInstall(request); | |
| } | |
| private void downloadDebPackageStepAndSetPackagePath(VersionIdentifier resolvedVersion) { | |
| ToolRepository toolRepository = this.context.getDefaultToolRepository(); | |
| this.downloadedDebPackageForDocker = toolRepository.download(this.tool, EDITION_DOCKER, resolvedVersion, this); | |
| } | |
| @Override | |
| protected List<NativePackage> getNativePackages() { | |
| if (EDITION_DOCKER.equals(getConfiguredEdition())) { | |
| return List.of( | |
| new NativePackage( | |
| NativePackageManager.APT, | |
| List.of(downloadedDebPackageForDocker.toString()), | |
| List.of("--allow-downgrades"), | |
| List.of( | |
| "sudo install -m 0755 -d /etc/apt/keyrings", | |
| "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc", | |
| "sudo chmod a+r /etc/apt/keyrings/docker.asc", | |
| "echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] " | |
| + "https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \\\"$VERSION_CODENAME\\\") stable\" | " | |
| + "sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", | |
| "sudo apt update" | |
| ), | |
| List.of( | |
| "sudo rm -f /etc/apt/sources.list.d/docker.list", | |
| "sudo rm -f /etc/apt/keyrings/docker.asc" | |
| ) | |
| ); | |
| } |
| @Override | ||
| protected List<PackageManagerCommand> getInstallPackageManagerCommands(VersionIdentifier resolvedVersion) { | ||
| if (!EDITION_DOCKER.equals(getConfiguredEdition())) { | ||
| return super.getInstallPackageManagerCommands(resolvedVersion); | ||
| } | ||
|
|
||
| ToolRepository toolRepository = this.context.getDefaultToolRepository(); | ||
| Path downloadedDeb = toolRepository.download(this.tool, EDITION_DOCKER, resolvedVersion, this); | ||
|
|
||
| NativePackage dockerDesktopInstallPackage = new NativePackage( | ||
| NativePackageManager.APT, | ||
| List.of(downloadedDeb.toString()), | ||
| List.of("--allow-downgrades"), | ||
| List.of( | ||
| "sudo install -m 0755 -d /etc/apt/keyrings", | ||
| "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc", | ||
| "sudo chmod a+r /etc/apt/keyrings/docker.asc", | ||
| "echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] " | ||
| + "https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \\\"$VERSION_CODENAME\\\") stable\" | " | ||
| + "sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", | ||
| "sudo apt update" | ||
| ), | ||
| List.of() | ||
| ); | ||
| return List.of(dockerDesktopInstallPackage.install(null)); |
There was a problem hiding this comment.
If the previous changes (https://github.com/devonfw/IDEasy/pull/2362/changes#r3871801542) have already been applied, these lines should no longer be necessary:
| @Override | |
| protected List<PackageManagerCommand> getInstallPackageManagerCommands(VersionIdentifier resolvedVersion) { | |
| if (!EDITION_DOCKER.equals(getConfiguredEdition())) { | |
| return super.getInstallPackageManagerCommands(resolvedVersion); | |
| } | |
| ToolRepository toolRepository = this.context.getDefaultToolRepository(); | |
| Path downloadedDeb = toolRepository.download(this.tool, EDITION_DOCKER, resolvedVersion, this); | |
| NativePackage dockerDesktopInstallPackage = new NativePackage( | |
| NativePackageManager.APT, | |
| List.of(downloadedDeb.toString()), | |
| List.of("--allow-downgrades"), | |
| List.of( | |
| "sudo install -m 0755 -d /etc/apt/keyrings", | |
| "sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc", | |
| "sudo chmod a+r /etc/apt/keyrings/docker.asc", | |
| "echo \"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] " | |
| + "https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \\\"$VERSION_CODENAME\\\") stable\" | " | |
| + "sudo tee /etc/apt/sources.list.d/docker.list > /dev/null", | |
| "sudo apt update" | |
| ), | |
| List.of() | |
| ); | |
| return List.of(dockerDesktopInstallPackage.install(null)); |
This PR fixes #2345
On Linux, setting
DOCKER_EDITION=dockerhad no effect because the Docker Desktop URL metadata did not contain a Linux download URL. As a result, Docker Desktop could not be selected and Rancher Desktop was installed instead.While adding Linux support, the Docker Desktop URL updater also had to be adjusted because the previous release notes URL no longer provided the expected content.
Docker Desktop installation on Linux
Docker Desktop requires a different installation than Rancher Desktop. Rancher Desktop is available as a package from its configured package repository and can therefore be installed directly by its package name.
Docker Desktop, however is distributed as a separate Debian package. According to the official Docker Desktop , the Docker package repository must first be configured, the Docker Desktop
.debpackage must then be downloaded separately, and finally the local package must be installed using:Implemented changes:
DockerDesktopUrlUpdaterDocker.javato resolve thedockeredition on Linux whenDOCKER_EDITION=dockeris configured.docs.docker.com/desktop/release-notestodocs.docker.com/desktop/release-notes.md.ToolRepository..debfiledocker-desktopas the native package name for version detection and uninstallation.Testing instructions
urls-statusdirectory and clone theide-urls-statusrepository:git clone https://github.com/devonfw/ide-urls-status.git <path-to-ide-urls-status>UpdateInitiator <path-to-ide-urls> <path-to-ide-urls-status> PT1H dockeride set-edition docker dockeride install dockerdpkg-query -W docker-desktopide uninstall dockerdpkg-query -W docker-desktopChecklist for this PR
Make sure everything is checked before merging this PR. For further info please also see
our DoD.
mvn clean testlocally all tests pass and build is successful#«issue-id»: «brief summary»(e.g.#921: fixed setup.batand notfeature/921 fixed setup.bat). If no issue ID exists, title only.In Progressand assigned to you or there is no issue (might happen for very small PRs)with
internalpom.xmlfiles or otherwise if runtime dependencies changed, you have updated our LICENSE.asciidoc