Skip to content

feat(images): suggest packages for missing commands in WSL - #20629

Open
Muhammad Falak R Wani (mfrw) wants to merge 3 commits into
4.0from
mfrw/wsl-command-not-found
Open

Muhammad Falak R Wani (mfrw) wants to merge 3 commits into
4.0from
mfrw/wsl-command-not-found

Conversation

@mfrw

Copy link
Copy Markdown
Member

Stacked on #20628: the first commit here is that PR. Please review the last two commits. I'll rebase once #20628 merges.

This installs PackageKit-command-not-found with the dnf5 backend in the WSL image. An interactive shell then names the package that provides a missing command:

bash: strace: command not found...
The package providing this file is: 'strace'

feat(PackageKit): publish PackageKit and appstream-data to Base

  • Both components publish only to SDK today. appstream-data comes in with PackageKit through appstream's (appstream-data if PackageKit) dependency.
  • This adds both to base-packages, and bumps them so that their next build publishes there.
  • Every binary RPM of both components installs from Base plus the promoted RPMs alone, so no SDK exceptions are needed.

feat(images): suggest packages for missing commands in WSL

  • Adds PackageKit-command-not-found and PackageKit-backend-dnf5 to wsl.xml.
  • WSL users have no password and no polkit agent, so the install that command-not-found offers by default can't be authorized. config.sh therefore sets SingleInstall and MultipleInstall to warn, and users install with sudo dnf install.
  • New static tests cover the packages, that policy, and the gettext guard from fix(PackageKit): stop command-not-found recursing without gettext #20628.

Testing (aarch64):

  • Built the WSL image locally against Base plus the rebuilt PackageKit and appstream-data RPMs.
    • static-image-checks: 62 passed, 38 skipped.
    • The three new tests fail on the current published image, as expected.
    • Footprint: 491 MB installed, 196 MB .wsl.
  • Booted the image with systemd, as the OOBE user:
    • The first miss takes about 8.5 s while PackageKit downloads metadata. Later misses take 0.04 s.
    • docker lists docker-cli and podman-docker, and gti suggests git.
    • bash -lc strace prints a single "command not found".
  • check_base_promotions.py passes against 4.0, and also from fix(PackageKit): stop command-not-found recursing without gettext #20628's head.

Fixes: https://mariner-org.visualstudio.com/mariner/_workitems/edit/25555

The non-interactive fallback in /etc/profile.d/PackageKit.sh prints its
message with "$(gettext PackageKit 'command not found')". When gettext
is not in PATH, that lookup re-enters command_not_found_handle, which
takes the same branch and forks again without bound. On an image
without gettext-runtime, such as the WSL image, one missing command in
a non-interactive login shell (bash -lc, sudo -i, su -) exhausts the
process table.

Backport the upstream fix (PackageKit/PackageKit#1052): call gettext
only when "type -P" finds it, and print the untranslated message
otherwise. Register it as Patch0502, in the spec's proposed-upstream
range. patch-add would pick Patch3002, which falls in the RHEL-only
%autopatch range and is never applied here.

Move PackageKit into its own comp.toml to carry the overlay.

Tested with the rebuilt 1.3.6-3 on the Azure Linux 4 WSL rootfs:
"bash -lc strace" now prints a single "command not found" and returns
127, where 1.3.6-2 spawned 300+ nested shells until it hit the PID
limit. Interactive shells still offer to install the package.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
The WSL image is about to install PackageKit-command-not-found, which
names the package that provides a missing command. PackageKit and
appstream-data publish only to SDK today. appstream-data comes in with
PackageKit through appstream's "(appstream-data if PackageKit)"
dependency.

Add both components to base-packages, and bump them so that their
next build publishes there. Every binary RPM of both components
installs from Base plus the promoted RPMs alone, so no SDK exceptions
are needed.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Install PackageKit-command-not-found with the dnf5 backend, so that an
interactive shell names the package that provides a missing command:

  bash: strace: command not found...
  The package providing this file is: 'strace'

WSL users have no password and no polkit agent, so the install that
command-not-found offers by default cannot be authorized. Set
SingleInstall and MultipleInstall to warn in config.sh, and let users
install with "sudo dnf install". Add static tests for the packages,
that policy, and the gettext guard in the profile.d handler.

Once PackageKit has metadata, a lookup takes about 0.04 s. The first
miss after installation waits about 9 s for the metadata download.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
@mfrw
Muhammad Falak R Wani (mfrw) requested a review from a team as a code owner December 1, 2026 10:29
Copilot AI balanced review requested due to automatic review settings December 1, 2026 10:29

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.

🟡 Changes recommended

The PackageKit and appstream-data publication-channel changes from SDK to Base still require maintainer sign-off, which the rebuild bumps do not replace.

1 open issue
What changed in this PR

Adds missing-command package suggestions to Azure Linux’s WSL image, building on the gettext recursion fix from #20628.

Changes:

  • Promotes PackageKit and appstream-data from SDK to Base, with rebuild bumps.
  • Installs PackageKit’s command-not-found helper and dnf5 backend, configured to suggest packages without offering installation.
  • Adds static checks for package presence, warning-only policy, and the inherited gettext guard.
File Description
specs/​p/​PackageKit/​PackageKit.spec Renders the inherited patch registration and updated release.
specs/​p/​PackageKit/​command-not-found-dont-recurse-without-gettext.patch Generated copy of the #20628 recursion fix.
specs/​a/​appstream-data/​appstream-data.spec Advances the release for Base publication.
locks/​PackageKit.lock Updates the fingerprint and rebuild counter.
locks/​appstream-data.lock Updates the fingerprint and rebuild counter.
base/​images/​tests/​cases/​static/​wsl/​test_wsl.py Adds three command-not-found configuration checks.
base/​images/​teams/​wsl.xml Includes the helper and dnf5 backend.
base/​images/​config.sh Sets WSL’s PackageKit install policies to warn.
base/​comps/​PackageKit/​PackageKit.comp.toml Dedicated component definition inherited from #20628.
base/​comps/​PackageKit/​overlays/​0001-command-not-found-no-gettext-recursion.overlay.toml Inherited overlay registering the gettext fix as Patch0502.
base/​comps/​PackageKit/​command-not-found-dont-recurse-without-gettext.patch Inherited source patch preventing recursive gettext lookup.
base/​comps/​components.toml Removes the inline definition moved by #20628.
base/​comps/​components-publish-channels.toml Routes PackageKit and appstream-data builds to Base.

Review effort: Balanced

"apache-resource-bundles",
"apiguardian",
"appstream",
"appstream-data",
@mfrw

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
2 pipeline(s) were filtered out due to trigger conditions.

This branch has not been deployed

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants