Skip to content

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

Closed
AruneshDwivedi wants to merge 3 commits into
project-copacetic:mainfrom
AruneshDwivedi:fix/chiseled-apt-get-missing
Closed

AruneshDwivedi wants to merge 3 commits into
project-copacetic:mainfrom
AruneshDwivedi:fix/chiseled-apt-get-missing

Conversation

@AruneshDwivedi

Copy link
Copy Markdown
Contributor

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 <[email protected]>

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 Outdated
Comment on lines +261 to +264
dm.hasAptGet = dm.probeAptGet(ctx, imageStateCurrent)
if !dm.hasAptGet {
dm.isDistroless = true
}
Comment thread pkg/pkgmgr/dpkg.go Resolved
@AruneshDwivedi

Copy link
Copy Markdown
Contributor 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.

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs.
Thank you for your contributions.

@github-actions github-actions Bot added the stale label Aug 29, 2026
AruneshDwivedi and others added 2 commits August 29, 2026 18:45
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Signed-off-by: Arunesh Dwivedi <[email protected]>
@robert-cronin

Copy link
Copy Markdown
Contributor

Thanks for working on this and for helping surface the apt-less Chiseled-image case. It looks like this PR has since been superseded by #1667, which now covers the broader full-status workflow with test coverage on main, so I think we can close this one.

@github-actions github-actions Bot removed the stale label Aug 31, 2026
@sozercan sozercan closed this Sep 2, 2026
@github-project-automation github-project-automation Bot moved this from 🆕 New to ✅ Done in Copacetic Workboard Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants