Skip to content

fix: detect missing apt-get in chiseled images and fall back to tooling container#1634

Open
AruneshDwivedi wants to merge 1 commit into
project-copacetic:mainfrom
AruneshDwivedi:fix/chiseled-apt-get-missing
Open

fix: detect missing apt-get in chiseled images and fall back to tooling container#1634
AruneshDwivedi wants to merge 1 commit into
project-copacetic:mainfrom
AruneshDwivedi:fix/chiseled-apt-get-missing

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

Some Debian-based images like dotnet/aspnet:8.0-noble-chiseled-extra have a dpkg status file but no apt-get binary. installUpdates was running apt-get update directly on the target image, which fails with "exec: apt-get: executable file not found in $PATH".

Now probeAptGet checks for apt-get availability after detecting DPKGStatusFile. When apt-get is absent, the code sets isDistroless=true and falls back to unpackAndMergeUpdates, which runs apt-get in the tooling container instead of the target image.

…ng container

Some Debian-based images (e.g., dotnet/aspnet:8.0-noble-chiseled-extra) have
a dpkg status file but no apt-get binary. Previously, installUpdates would
attempt to run apt-get update on the target image, failing with 'exec: apt-get:
executable file not found in /var/home/kushald/.local/bin:/var/home/kushald/.local/bin:/var/home/kushald/.local/bin:/var/home/kushald/.local/bin:/var/home/kushald/.local/bin:/var/home/kushald/.local/bin:/var/home/kushald/.nvm/versions/node/v24.15.0/bin:/var/home/kushald/.local/bin:/var/home/kushald/bin:/var/home/kushald/.hermes/hermes-agent/venv/bin:/var/home/kushald/.hermes/hermes-agent/node_modules/.bin:/var/home/kushald/.hermes/node/bin:/var/home/kushald/.local/bin:/var/home/kushald/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/var/home/kushald/.local/share/JetBrains/Toolbox/scripts'. Now probeAptGet checks for apt-get
availability after detecting DPKGStatusFile, and falls back to the tooling
container path (unpackAndMergeUpdates) when it's absent.

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a failure when patching Debian-based "chiseled" images (e.g. dotnet/aspnet:8.0-noble-chiseled-extra) that ship a dpkg status file but no apt-get binary. Previously InstallUpdates would run apt-get update directly against such target images and fail with exec: apt-get: executable file not found in $PATH. The change adds a probeAptGet step in probeDPKGStatus so that, when apt-get is missing, the manager flips to the distroless code path that runs apt-get inside the tooling container instead.

Changes:

  • Added a hasAptGet field to dpkgManager.
  • In the DPKGStatusFile branch, probe the target image for apt-get; when absent, set isDistroless = true.
  • Added probeAptGet, which runs a shell probe in the target image and uses buildkit.TryExtractFileFromState to detect a marker file.

Comment thread pkg/pkgmgr/dpkg.go
Comment on lines +261 to +264
dm.hasAptGet = dm.probeAptGet(ctx, imageStateCurrent)
if !dm.hasAptGet {
dm.isDistroless = true
}
Comment thread pkg/pkgmgr/dpkg.go
Comment on lines +324 to +327
state := imageState.Run(
llb.Shlex(fmt.Sprintf(`sh -c 'command -v apt-get > /dev/null && touch %s'`, aptGetMarker)),
llb.WithCustomName("Probing for apt-get"),
).Root()
@AruneshDwivedi

Copy link
Copy Markdown
Author

Thanks for the review. The first point about empty packageInfo is not an issue in this code — probeAptGet sets isDistroless for status-file images but probeDPKGStatus returns nil immediately after, so InstallUpdates never reaches unpackAndMergeUpdates for this status type. The isDistroless flag is only consulted after probeDPKGStatus returns nil. For the second point about the probe command — fixed by adding || true so the shell always exits 0 when apt-get is absent, leaving the marker file absent rather than failing the build step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🆕 New

Development

Successfully merging this pull request may close these issues.

2 participants