-
Notifications
You must be signed in to change notification settings - Fork 164
feat: add QEMU_ADDITIONAL_PACKAGES environment variable #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
antitree
merged 10 commits into
chainguard-dev:main
from
antitree:feat/qemu-additional-packages
Jan 13, 2026
Merged
feat: add QEMU_ADDITIONAL_PACKAGES environment variable #2266
antitree
merged 10 commits into
chainguard-dev:main
from
antitree:feat/qemu-additional-packages
Jan 13, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add support for QEMU_ADDITIONAL_PACKAGES environment variable that allows users to specify additional packages to install in the QEMU microVM during initialization. The variable accepts a comma-separated list of package names (e.g., "hello-wolfi,nginx-stable,strace") and passes them to microvm-init via the kernel command line as melange.additional_packages=<list>. Input validation prevents injection attacks by only allowing alphanumeric characters, hyphens, underscores, commas, and dots. Invalid input is rejected with a warning. Usage: QEMU_ADDITIONAL_PACKAGES=hello-wolfi,strace melange build mypackage.yaml Note: This requires a corresponding update to microvm-init package to read and process the melange.additional_packages kernel parameter. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Update to use strings.SplitSeq() instead of strings.Split() for better efficiency with the iterator pattern in Go 1.24+. Addresses golangci-lint modernize check.
egibs
reviewed
Dec 10, 2025
egibs
reviewed
Dec 10, 2025
…L_PACKAGES Addresses PR feedback from @egibs and @89luca89: - Extract getAdditionalPackages() function for parsing env var - Extract getPackageCacheSuffix() function for cache key generation - Use SHA256 hash instead of truncation to avoid collisions - Add comprehensive test coverage for both functions - Fix variable shadowing issue Tests verify: - Package parsing and validation - Security (injection prevention) - Cache suffix generation with SHA256 - Hash determinism and collision prevention 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
egibs
reviewed
Jan 13, 2026
89luca89
requested changes
Jan 13, 2026
Co-authored-by: Evan Gibler <[email protected]> Signed-off-by: antitree <[email protected]>
antitree
commented
Jan 13, 2026
Contributor
Author
antitree
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
factored in @egibs change
Signed-off-by: antitree <[email protected]>
egibs
reviewed
Jan 13, 2026
89luca89
requested changes
Jan 13, 2026
The merge introduced a bug where additionalPkgs parameter was being shadowed by a local variable that called getAdditionalPackages again. This defeats the purpose of passing the parameter and causes the function to be called twice unnecessarily. Remove the duplicate call to use the passed parameter correctly.
egibs
approved these changes
Jan 13, 2026
89luca89
approved these changes
Jan 13, 2026
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for the
QEMU_ADDITIONAL_PACKAGESenvironment variable, which allows users to specify additional packages to include in the initramfs image during QEMU VM initialization. This complements the existingTESTINGenvironment variable feature gate.Changes
QEMU_ADDITIONAL_PACKAGESsupport inpkg/container/qemu_runner.gohello-wolfi,nginx-stable,strace)^[a-zA-Z0-9_,.-]+$)How It Works
Without QEMU_ADDITIONAL_PACKAGES:
With QEMU_ADDITIONAL_PACKAGES=hello-wolfi,strace:
Packages are installed into the initramfs during the apko build, so they're available immediately when the VM boots - no runtime
apk addneeded!Usage
Use Cases
strace,gdb,tcpdumpfor debugging buildsSecurity
The implementation validates input to prevent shell injection attacks. Only alphanumeric characters, hyphens, underscores, commas, and dots are allowed in package names. Suspicious input is rejected with a warning.
Test Results
Verified that packages are successfully added to the initramfs:
The package is installed in the initramfs and available at boot time ✅